From 98ad8eaf04c96c352d28379981b71b2cfeeb27d5 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 00:37:37 +0000 Subject: [PATCH 01/96] feat(breg): replay stewardship, proposal parties and facility roles Signed-off-by: Jeremi Joslin --- .../tests/support/breg_native_service.rs | 6 +- .../registry-adapter/tests/facade_refusals.rs | 2 +- .../__test__/proposals.test.js | 9 +- crates/registry-breg-client-node/client.d.ts | 18 +- crates/registry-breg-client-node/src/lib.rs | 2 + .../python/registry_breg_client/__init__.pyi | 2 + crates/registry-breg-client-py/src/lib.rs | 4 + .../tests/python/test_proposals.py | 13 +- crates/registry-breg-client/src/error.rs | 12 +- crates/registry-breg-client/src/metadata.rs | 70 +- .../src/metadata_tests.rs | 47 + crates/registry-breg-client/src/proposal.rs | 19 + .../tests/proposal_party.rs | 33 + .../tests/write_http_boundary.rs | 6 + .../tests/support/citizen_project.rs | 2 +- crates/registry-breg/Cargo.toml | 5 + crates/registry-breg/src/access.rs | 114 +- crates/registry-breg/src/api/actions.rs | 19 + .../src/api/actions/availability.rs | 40 + crates/registry-breg/src/api/attachments.rs | 32 +- crates/registry-breg/src/api/context.rs | 16 + crates/registry-breg/src/api/mod.rs | 154 +- crates/registry-breg/src/api/proposals.rs | 297 +- .../src/api/proposals/answers.rs | 12 +- .../src/api/tests/immediate_action_tests.rs | 154 +- crates/registry-breg/src/artifacts.rs | 47 +- crates/registry-breg/src/auth.rs | 4 +- crates/registry-breg/src/compiler.rs | 24 +- .../src/compiler/disclosure/reach.rs | 42 +- .../registry-breg/src/compiler/statistics.rs | 21 +- crates/registry-breg/src/contract.rs | 374 +- crates/registry-breg/src/contract/sentinel.rs | 286 +- crates/registry-breg/src/disclosure.rs | 27 + .../src/evidence_source/tests.rs | 36 +- crates/registry-breg/src/fixtures.rs | 102 +- .../registry-breg/src/fixtures/proposals.rs | 1 + crates/registry-breg/src/generated_ddl.rs | 340 +- .../registry-breg/src/history_maintenance.rs | 1 + crates/registry-breg/src/history_schema.rs | 1 + crates/registry-breg/src/immediate_actions.rs | 395 +- crates/registry-breg/src/ingestion_store.rs | 4 +- crates/registry-breg/src/lib.rs | 1 + crates/registry-breg/src/membership.rs | 1425 ++++- crates/registry-breg/src/migration.rs | 12 + .../registry-breg/src/migration_reconcile.rs | 2 + crates/registry-breg/src/model.rs | 39 +- crates/registry-breg/src/mutation.rs | 277 +- crates/registry-breg/src/mutation/action.rs | 557 +- .../src/mutation/action/membership.rs | 713 +++ .../registry-breg/src/mutation/membership.rs | 356 ++ crates/registry-breg/src/mutation/proposal.rs | 779 ++- .../src/mutation/proposal/additions.rs | 1 + .../src/mutation/proposal/asks.rs | 1 + .../mutation/proposal/context_projection.rs | 77 +- crates/registry-breg/src/package.rs | 35 +- .../src/package/tests/immediate_actions.rs | 4 +- .../src/postgres/cancellation.rs | 65 +- crates/registry-breg/src/postgres/catalog.rs | 21 +- crates/registry-breg/src/postgres/config.rs | 56 +- crates/registry-breg/src/postgres/context.rs | 266 +- .../registry-breg/src/postgres/interlock.rs | 8 +- crates/registry-breg/src/postgres/mod.rs | 14 +- crates/registry-breg/src/postgres/mutation.rs | 117 +- crates/registry-breg/src/postgres/proposal.rs | 284 +- .../src/postgres/proposal_context.rs | 127 +- .../registry-breg/src/postgres/rehearsal.rs | 12 +- crates/registry-breg/src/postgres/schema.rs | 41 +- crates/registry-breg/src/problem.rs | 12 + .../registry-breg/src/proposal_artifacts.rs | 7 + crates/registry-breg/src/proposal_ddl.rs | 72 +- crates/registry-breg/src/proposal_hooks.rs | 5 +- crates/registry-breg/src/proposal_prepare.rs | 77 +- .../src/proposal_prepare/tests.rs | 4 +- .../registry-breg/src/proposal_retention.rs | 2 +- crates/registry-breg/src/proposal_store.rs | 39 +- crates/registry-breg/src/proposal_subject.rs | 181 + crates/registry-breg/src/runtime_config.rs | 74 + .../tests/action_handler_benchmark_tests.rs | 4 +- .../tests/action_outcome_wasm_parity_tests.rs | 4 +- .../tests/artifacts_response_schema_tests.rs | 4 +- .../src/tests/wasm_runtime_tests.rs | 2 +- crates/registry-breg/src/tooling.rs | 79 + .../registry-breg/tests/access_explanation.rs | 137 +- crates/registry-breg/tests/access_log.rs | 2 +- .../registry-breg/tests/access_sentinels.rs | 2 +- .../tests/action_evidence_compiler.rs | 4 +- .../tests/action_handler_declaration.rs | 2 +- .../tests/attachment_promotion_compiler.rs | 2 +- .../registry-breg/tests/compiled_ddl_pins.rs | 140 +- .../registry-breg/tests/compiler_contract.rs | 16 +- .../tests/compiler_statistics.rs | 47 +- crates/registry-breg/tests/data_operations.rs | 6 +- .../registry-breg/tests/disclosure/fields.rs | 3 +- .../registry-breg/tests/disclosure/history.rs | 6 +- .../tests/disclosure/proposals.rs | 5 +- .../registry-breg/tests/disclosure/writes.rs | 11 +- .../registry-breg/tests/disclosure_compile.rs | 68 +- .../tests/disclosure_exposure.rs | 5 +- .../tests/explicit_row_authority.rs | 28 +- .../tests/field_encryption_contract.rs | 4 +- crates/registry-breg/tests/fixture_tooling.rs | 16 +- .../absent-optional-action-inputs.yaml | 2 +- .../tests/fixtures/authority-mapping.yaml | 4 +- .../tests/fixtures/event-record/shapes.yaml | 4 +- .../fixtures/fixed-optional-action-input.yaml | 2 +- .../fixtures/fixture-tooling/journeys.yaml | 6 + .../fixtures/fixture-tooling/project.yaml | 2 +- .../fixture-tooling/terminal-failure.yaml | 2 + .../tests/generated_identifier_compiler.rs | 6 +- .../tests/golden/membership-access.json | 113 + .../tests/golden/membership-ddl.json | 334 ++ .../tests/golden/membership-ddl.sha256 | 1 + .../tests/golden/membership-revision.txt | 1 + .../tests/golden/membership_refusals.json | 336 ++ .../tests/golden/metrics-scrape-sampled.txt | 1 + .../tests/golden/metrics-scrape-unsampled.txt | 1 + crates/registry-breg/tests/http_auth.rs | 2 +- crates/registry-breg/tests/http_read_only.rs | 11 +- .../tests/immediate_action_compiler.rs | 14 +- .../tests/immediate_action_handler.rs | 2 +- .../tests/import_grant_admission.rs | 2 +- .../registry-breg/tests/issuer_portability.rs | 2 +- .../registry-breg/tests/membership_access.rs | 147 +- .../tests/membership_authoring.rs | 619 +++ crates/registry-breg/tests/migration_plan.rs | 4 +- .../migration_review_permission_order.rs | 2 +- .../tests/native_plan_security.rs | 2 +- crates/registry-breg/tests/odrl_export.rs | 51 +- .../tests/ordered_plan_contract.rs | 2 +- .../tests/package_change_plan.rs | 73 +- .../tests/postgres_access_log.rs | 26 +- .../tests/postgres_action_handlers.rs | 4 +- crates/registry-breg/tests/postgres_batch.rs | 10 +- .../tests/postgres_client_capabilities.rs | 4 +- .../tests/postgres_compiled_schema.rs | 14 +- .../tests/postgres_consent_access.rs | 2 +- .../tests/postgres_constraint_races.rs | 2 +- .../tests/postgres_data_export.rs | 4 +- .../tests/postgres_data_facility.rs | 6 +- .../tests/postgres_derived_values.rs | 4 +- .../tests/postgres_event_record_examples.rs | 2 +- .../tests/postgres_event_record_reader.rs | 4 +- .../tests/postgres_field_encryption.rs | 2 +- .../tests/postgres_fixture_journeys.rs | 9 +- ...tgres_generated_identifier_batch_import.rs | 4 +- .../tests/postgres_generated_identifiers.rs | 2 +- .../tests/postgres_history_commit.rs | 2 +- .../tests/postgres_history_erasure.rs | 4 +- .../tests/postgres_history_migration.rs | 4 +- .../tests/postgres_history_rebaseline.rs | 2 +- .../tests/postgres_hook_changes.rs | 88 +- .../tests/postgres_immediate_actions.rs | 2 +- .../tests/postgres_import_authority.rs | 6 +- .../tests/postgres_ingestion_contract.rs | 4 +- .../tests/postgres_ingestion_receipts.rs | 4 +- .../tests/postgres_ingestion_runs.rs | 10 +- crates/registry-breg/tests/postgres_kernel.rs | 2 +- .../tests/postgres_membership_access.rs | 183 +- .../registry-breg/tests/postgres_migration.rs | 208 +- .../registry-breg/tests/postgres_mutation.rs | 34 +- .../tests/postgres_mutation_logical_names.rs | 2 +- .../tests/postgres_native_retention.rs | 2 +- .../registry-breg/tests/postgres_package.rs | 2 +- .../postgres_package/compiler_upgrade.rs | 2 +- .../postgres_package/migration_capacity.rs | 2 +- .../tests/postgres_package/policy_upgrade.rs | 12 +- .../postgres_package/reference_upgrade.rs | 2 +- .../tests/postgres_pilot_acceptance.rs | 14 +- .../registry-breg/tests/postgres_proposal.rs | 227 +- ...postgres_proposal_generated_identifiers.rs | 4 +- .../tests/postgres_proposal_guard_failure.rs | 2 +- .../tests/postgres_proposal_human_recovery.rs | 2 +- .../postgres_proposal_recovery_permissions.rs | 2 +- .../postgres_proposal_review_delivery.rs | 2 +- .../tests/postgres_proposal_s3.rs | 2 +- .../tests/postgres_proposal_security.rs | 969 +++- .../postgres_proposal_shape_activation.rs | 2 +- .../tests/postgres_proposal_subject.rs | 1592 ++++++ .../tests/postgres_proposal_task_authority.rs | 4 +- .../tests/postgres_read_dependencies.rs | 4 +- .../tests/postgres_record_attachments.rs | 10 +- .../postgres_record_profile_conformance.rs | 2 +- .../tests/postgres_record_timer_clock.rs | 2 +- .../tests/postgres_record_timer_retention.rs | 2 +- .../tests/postgres_record_timers.rs | 2 +- .../tests/postgres_reference_integrity.rs | 8 +- .../tests/postgres_spatial_migration.rs | 2 +- .../tests/postgres_spatial_storage.rs | 6 +- .../tests/postgres_statistics_exact.rs | 2 +- .../tests/postgres_statistics_http.rs | 2 +- .../tests/postgres_statistics_measures.rs | 2 +- .../tests/postgres_tombstone_revision.rs | 2 +- .../tests/postgres_webhook_delivery.rs | 4 +- .../tests/postgres_webhook_outbox.rs | 2 +- .../tests/postgres_workspace_metadata.rs | 4 +- .../tests/proposal_default_grants.rs | 2 +- .../proposal_generated_identifier_policies.rs | 4 +- .../tests/proposal_party_compiler.rs | 511 ++ .../tests/proposal_status_contract.rs | 3 + .../registry-breg/tests/refactor_contract.rs | 4 +- .../registry-breg/tests/row_boundary_sets.rs | 2 +- .../tests/schema_fingerprint_rehearsal.rs | 5 +- crates/registry-breg/tests/script_baseline.rs | 2 +- .../tests/standing_agent_ceiling.rs | 18 +- .../registry-breg/tests/steward_authoring.rs | 1130 ++++ .../tests/support/action_evidence_provider.rs | 4 + .../tests/support/event_record_registry.rs | 2 +- .../tests/support/membership_targets.rs | 112 + .../support/membership_write_journeys.rs | 4924 +++++++++++++++++ .../tests/support/membership_write_project.rs | 336 ++ .../tests/support/pilot_acceptance_harness.rs | 2 + .../support/postgres_membership_writes.rs | 583 ++ .../tests/support/proposal_additions.rs | 2 +- .../support/proposal_additions_authority.rs | 2 +- .../tests/support/proposal_hooks_model.rs | 2 +- .../tests/support/proposal_review_asks.rs | 59 +- .../tests/task_grant_row_findings.rs | 8 +- .../tests/value_type_consistency.rs | 4 +- .../tests/wasm_handler_admission.rs | 2 +- .../src/action_handler_test.rs | 2 +- crates/registry-bregctl/src/check.rs | 4 +- .../src/consent_module/module.yaml | 1 + .../src/consent_module/profiles.yaml | 5 +- crates/registry-bregctl/src/data_lifecycle.rs | 6 +- crates/registry-bregctl/src/explain_report.rs | 13 +- crates/registry-bregctl/src/lib.rs | 25 +- crates/registry-bregctl/tests/cli.rs | 39 +- .../tests/cli/migration_capacity.rs | 2 +- .../tests/explain_contract.rs | 37 + .../src/task_grants/native_exchange_tests.rs | 11 +- .../src/task_grants/native_resource.rs | 10 +- .../tests/support/breg_service.rs | 4 +- .../src/observability/golden-scrape.txt | 1 + .../src/observability/golden-scrape.txt | 1 + .../src/refusal.rs | 9 +- crates/registry-rstack-dev/src/products.rs | 167 + crates/registry-scheduling/src/metrics.rs | 2 +- .../breg/client.d.ts | 18 +- .../content/docs/configure/breg-access.mdx | 295 +- .../src/content/docs/configure/breg-mcp.mdx | 2 +- .../content/docs/configure/breg-proposals.mdx | 122 +- docs/site/src/content/docs/configure/breg.mdx | 4 +- .../explanation/where-authority-lives.mdx | 33 +- .../site/src/content/docs/operate/adapter.mdx | 4 +- .../src/content/docs/operate/coordinator.mdx | 2 +- .../src/content/docs/operate/documents.mdx | 2 +- .../src/content/docs/operate/messaging.mdx | 2 +- .../src/content/docs/operate/scheduling.mdx | 2 +- .../src/content/docs/reference/breg-api.mdx | 11 +- .../reference/coordinator-configuration.mdx | 2 +- .../reference/messaging-configuration.mdx | 2 +- docs/site/src/content/docs/security/breg.mdx | 191 +- .../src/content/docs/security/casework.mdx | 2 +- .../src/content/docs/security/coordinator.mdx | 2 +- .../src/content/docs/security/documents.mdx | 2 +- .../src/content/docs/security/evidence.mdx | 2 +- docs/site/src/content/docs/security/index.mdx | 2 +- .../src/content/docs/security/messaging.mdx | 2 +- .../site/src/content/docs/security/render.mdx | 2 +- .../src/content/docs/security/scheduling.mdx | 2 +- docs/site/src/data/breg-api.yaml | 2 + .../examples/kobotoolbox-breg/registry.yaml | 2 +- .../qfield-postgis/registry/registry.yaml | 2 +- products/breg/AGENTS.md | 14 +- products/breg/CHANGELOG.md | 21 + .../asset-site-placement/registry.yaml | 4 +- .../asset-site-placement/tests/journeys.yaml | 8 + .../breg/acceptance/business/registry.yaml | 2 +- .../acceptance/business/tests/journeys.yaml | 3 + .../breg/acceptance/facility/registry.yaml | 2 +- .../acceptance/facility/tests/journeys.yaml | 12 +- .../generated-identifiers/registry.yaml | 2 +- .../breg/acceptance/inspection/registry.yaml | 2 +- .../acceptance/inspection/tests/journeys.yaml | 6 + .../registry/registry.yaml | 2 +- .../explain/AccessExplanation.schema.json | 112 +- .../contracts/security-invariant-matrix.yaml | 30 +- .../contracts/security-test-traceability.yaml | 28 + products/breg/examples/README.md | 4 + products/breg/examples/facility/registry.yaml | 4 +- products/breg/examples/minimal/registry.yaml | 2 +- .../organisation-stewardship/README.md | 55 + .../dev-journeys.yaml | 14 + .../organisation-stewardship/dev.yaml | 45 + .../organisation-stewardship/registry.yaml | 286 + .../organisation-stewardship/service.yaml | 20 + .../tests/journeys.yaml | 186 + .../required-attachment/registry.yaml | 2 +- .../examples/reviewed-change/registry.yaml | 2 +- .../action-plan-branches/registry.yaml | 2 +- .../fixtures/authoring-display/registry.yaml | 2 +- .../modules/consent-tenure-right/module.yaml | 5 + .../consent-land-registry/registry.yaml | 10 +- .../modules/consent-person/module.yaml | 1 + .../consent-person-registry/registry.yaml | 7 +- .../registry.yaml | 21 +- .../breg/scripts/test-adopter-workflow.sh | 14 +- products/breg/scripts/test-postgres.sh | 1 + .../breg/scripts/test_validate_product.py | 7 +- products/breg/scripts/validate_product.py | 3 +- .../examples/canonical-review/README.md | 2 +- .../scripts/real_service_fixtures.py | 2 +- products/evidence/OPERATOR-CONTRACT.md | 2 +- products/platform/CHANGELOG.md | 1 + .../journeys/projects/composed_fixtures.py | 2 +- 305 files changed, 22476 insertions(+), 1705 deletions(-) create mode 100644 crates/registry-breg-client/tests/proposal_party.rs create mode 100644 crates/registry-breg/src/mutation/action/membership.rs create mode 100644 crates/registry-breg/src/mutation/membership.rs create mode 100644 crates/registry-breg/src/proposal_subject.rs create mode 100644 crates/registry-breg/tests/golden/membership-access.json create mode 100644 crates/registry-breg/tests/golden/membership-ddl.json create mode 100644 crates/registry-breg/tests/golden/membership-ddl.sha256 create mode 100644 crates/registry-breg/tests/golden/membership-revision.txt create mode 100644 crates/registry-breg/tests/golden/membership_refusals.json create mode 100644 crates/registry-breg/tests/membership_authoring.rs create mode 100644 crates/registry-breg/tests/postgres_proposal_subject.rs create mode 100644 crates/registry-breg/tests/proposal_party_compiler.rs create mode 100644 crates/registry-breg/tests/steward_authoring.rs create mode 100644 crates/registry-breg/tests/support/membership_targets.rs create mode 100644 crates/registry-breg/tests/support/membership_write_journeys.rs create mode 100644 crates/registry-breg/tests/support/membership_write_project.rs create mode 100644 crates/registry-breg/tests/support/postgres_membership_writes.rs create mode 100644 products/breg/examples/organisation-stewardship/README.md create mode 100644 products/breg/examples/organisation-stewardship/dev-journeys.yaml create mode 100644 products/breg/examples/organisation-stewardship/dev.yaml create mode 100644 products/breg/examples/organisation-stewardship/registry.yaml create mode 100644 products/breg/examples/organisation-stewardship/service.yaml create mode 100644 products/breg/examples/organisation-stewardship/tests/journeys.yaml diff --git a/crates/registry-adapter-connectors/tests/support/breg_native_service.rs b/crates/registry-adapter-connectors/tests/support/breg_native_service.rs index 34d3bf8cf0..e19ddf1372 100644 --- a/crates/registry-adapter-connectors/tests/support/breg_native_service.rs +++ b/crates/registry-adapter-connectors/tests/support/breg_native_service.rs @@ -450,9 +450,9 @@ impl Breg { {"action": "register-household", "operations": ["start"], "targets": [{"recordType": "household", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]} ], "proposals": [ - {"action": "propose-item", "operations": ["get", "submit"], "ownership": "caller", "targets": [{"recordType": "item", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]}, - {"action": "manual-item", "operations": ["get", "submit", "apply"], "ownership": "caller", "targets": [{"recordType": "item", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]}, - {"action": "register-household", "operations": ["get", "submit"], "ownership": "caller", "targets": [{"recordType": "household", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]} + {"action": "propose-item", "operations": ["get", "submit"], "party": "owner", "targets": [{"recordType": "item", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]}, + {"action": "manual-item", "operations": ["get", "submit", "apply"], "party": "owner", "targets": [{"recordType": "item", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]}, + {"action": "register-household", "operations": ["get", "submit"], "party": "owner", "targets": [{"recordType": "household", "rowBoundaries": [{"field": "owner", "claim": "sub", "operator": "equals"}]}]} ] } }} diff --git a/crates/registry-adapter/tests/facade_refusals.rs b/crates/registry-adapter/tests/facade_refusals.rs index 21e2fcddad..b418ddb0a1 100644 --- a/crates/registry-adapter/tests/facade_refusals.rs +++ b/crates/registry-adapter/tests/facade_refusals.rs @@ -340,7 +340,7 @@ async fn every_refusal_keeps_its_answer_and_is_counted_and_logged_under_its_chec expected.values().sum::(), "no other check was counted: {counted:?}" ); - assert_eq!(counted.len(), 45, "every check is declared at zero"); + assert_eq!(counted.len(), 46, "every check is declared at zero"); let stderr = served.wait_for_stderr("\"request refused\"", STDERR_WAIT); std::thread::sleep(Duration::from_millis(300)); diff --git a/crates/registry-breg-client-node/__test__/proposals.test.js b/crates/registry-breg-client-node/__test__/proposals.test.js index 4d5a2a21b8..6069f44aac 100644 --- a/crates/registry-breg-client-node/__test__/proposals.test.js +++ b/crates/registry-breg-client-node/__test__/proposals.test.js @@ -9,7 +9,7 @@ const id = '00000000-0000-4000-8000-000000000001'; const metadata = { id: 'proposal-client', version: '1', revision, metadataVersion: '2', recordTypes: [], operations: [], proposals: {method: 'GET', path: '/v1/proposals', accessProfiles: ['author'], - actions: [{actionId: 'correct', accessProfile: 'author', operations: ['get', 'list', 'submit'], readableInputs: [], readableContextFields: []}], + actions: [{actionId: 'correct', accessProfile: 'author', party: 'owner', operations: ['get', 'list', 'submit'], readableInputs: [], writableInputs: ['address'], readableContextFields: []}], get: {method: 'GET', path: '/v1/proposals/{proposal_id}', accessProfiles: ['author']}}, actions: [{id: 'correct', apiName: 'correct', revision, display: {}, execution: {mode: 'proposal'}, attachments: [{id: 'supporting-file', required: true, contentTypes: ['application/pdf'], maximumBytes: 1024}], @@ -17,12 +17,12 @@ const metadata = { {id: 'address', apiName: 'address', required: true, nullable: false, classification: 'internal', schema: {type: 'string', minLength: 1, maxLength: 100}, fieldType: {type: 'string', minimumLength: 1, maximumLength: 100}}, - ], referenceInputs: [], requiredConditionKeys: [], resultEffects: [], + ], referenceInputs: [], requiredConditionKeys: [], resultEffects: [], subject: {input: 'address'}, writableInputs: ['address'], access: {selectedProfile: 'author'}, routes: {start: {method: 'POST', path: '/v1/actions/correct/proposals', operationId: 'actions.correct.start', requiresIdempotencyKey: true, inputSchema: 'action-correct-invoke-input', responseSchema: 'action-correct-invoke-response'}}, bounds: {maximumTargets: 16, maximumFieldMutations: 128, maximumSnapshotBytes: 2097152}}], }; -const proposal = {id, actionId: 'correct', actionRevision: revision, submissionVersion: 1, revision: 1, state: 'draft', links: { +const proposal = {id, actionId: 'correct', actionRevision: revision, submissionVersion: 1, revision: 1, state: 'draft', partyRole: 'owner', links: { self: {method: 'GET', path: `/v1/proposals/${id}`, accessProfile: 'author', operation: 'get'}, edit: {method: 'POST', path: `/v1/proposals/${id}/edit`, accessProfile: 'author', operation: 'edit', ifMatch: '"draft-condition"'}, submit: {method: 'POST', path: `/v1/proposals/${id}/submit`, accessProfile: 'author', operation: 'submit', ifMatch: '"draft-condition"'}, @@ -86,10 +86,13 @@ test('proposal object methods preserve exact bodies and refuse JSON strings befo const client = new BaseRegistryClient({baseUrl: `http://127.0.0.1:${server.address().port}/tenant/`}); const contract = await client.registryContract('author'); assert.deepEqual(contract.proposalActions, metadata.proposals.actions); + assert.equal(contract.actions[0].subjectInput, 'address'); + assert.deepEqual(contract.actions[0].writableInputs, ['address']); assert.deepEqual(contract.actions[0].attachments, metadata.actions[0].attachments); const getBinding = contract.selectProposalGet('author'); const located = await client.getProposal(getBinding, id); assert.equal(located.identifier, id); + assert.equal(JSON.parse(located.documentJson).partyRole, 'owner'); assert.equal(requests.at(-1).url, `/tenant/v1/proposals/${id}?accessProfile=author`); const getCount = requests.length; for (const invalid of ['../secret', id.toUpperCase(), '00000000-0000-0000-0000-00000000000A']) { diff --git a/crates/registry-breg-client-node/client.d.ts b/crates/registry-breg-client-node/client.d.ts index 649d277ddc..b8b235cb19 100644 --- a/crates/registry-breg-client-node/client.d.ts +++ b/crates/registry-breg-client-node/client.d.ts @@ -517,8 +517,15 @@ export interface BRegOperationDescriptor { export interface BRegProposalActionDescriptor { readonly actionId: string readonly accessProfile: string + /** The Proposal party this entry is bound to; absent for an entry bound to no party. */ + readonly party?: BRegProposalPartyRole readonly operations: ReadonlyArray readonly readableInputs: ReadonlyArray + /** + * The inputs this entry may set through Start, Edit, Revise or Rebase; + * absent from a server that predates the member. Empty when it writes none. + */ + readonly writableInputs?: ReadonlyArray readonly readableContextFields: ReadonlyArray } @@ -567,6 +574,13 @@ export interface BRegActionDescriptor { readonly targetRecordType: string }> readonly requiredConditionKeys: ReadonlyArray + /** The input that names the person a Proposal is about, or `null` when the Action declares none. */ + readonly subjectInput: string | null + /** + * The inputs the selected profile may set, or `null` for an immediate Action + * or a server that predates the member. + */ + readonly writableInputs: ReadonlyArray | null readonly resultEffects: ReadonlyArray<{ readonly effect: string readonly recordType: string @@ -1102,6 +1116,8 @@ export interface BRegProposalReviewDocument { } /** Who is expected to act next, derived by BReg. */ export type BRegProposalTurn = 'party' | 'official' | 'nobody' +/** Which party of a Proposal a party-bound entry admitted the caller as. */ +export type BRegProposalPartyRole = 'owner' | 'subject' export type BRegProposalStatus = 'draft' | 'awaiting-party' | 'in-review' | 'approved' | 'processing' | 'applied' | 'rejected' | 'cancelled' /** The review decision on one submission. The public reason is the only reviewer text BReg serves. */ export interface BRegProposalDecision { readonly status: 'approved' | 'rejected' | 'changes-requested' | 'answered'; readonly decidedAt: string; readonly publicReason?: string } @@ -1114,7 +1130,7 @@ export interface BRegProposalSubmission { readonly decision?: BRegProposalDecision readonly handoffRefusal?: BRegProposalHandoffRefusal } -export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } +export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } export declare class BRegProposal { private constructor(); private readonly __opaque: void; readonly responseEtag: string | null; readonly identifier: string; readonly actionIdentifier: string; readonly documentJson: string; readonly inputJson?: string | null } export declare class BRegProposalGetBinding { private constructor(); private readonly __opaque: void } export declare class BRegProposalReviewBinding { private constructor(); private readonly __opaque: void } diff --git a/crates/registry-breg-client-node/src/lib.rs b/crates/registry-breg-client-node/src/lib.rs index 0ea6c03e26..81ce45814e 100644 --- a/crates/registry-breg-client-node/src/lib.rs +++ b/crates/registry-breg-client-node/src/lib.rs @@ -2367,6 +2367,8 @@ fn action_descriptor_value(value: ®istry_breg_client::BRegActionDescriptor) - "targetRecordType": input.target_record_type(), })).collect::>(), "requiredConditionKeys": value.required_condition_keys(), + "subjectInput": value.subject_input(), + "writableInputs": value.writable_inputs(), "resultEffects": value.result_effects().iter().map(|effect| json!({ "effect": effect.effect_identifier(), "recordType": effect.record_type_identifier(), "operation": effect.operation().as_str(), diff --git a/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi b/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi index 4a50bb57c6..546d385d60 100644 --- a/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi +++ b/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi @@ -319,8 +319,10 @@ class BRegRecoveredAction: ... class BRegProposalActionDescriptor(TypedDict): action_id: str access_profile: str + party: Literal['owner', 'subject'] | None operations: Sequence[str] readable_inputs: Sequence[str] + writable_inputs: Sequence[str] | None readable_context_fields: Sequence[str] class BRegProposalReviewDocument(TypedDict): diff --git a/crates/registry-breg-client-py/src/lib.rs b/crates/registry-breg-client-py/src/lib.rs index a01525d68f..7c598def4e 100644 --- a/crates/registry-breg-client-py/src/lib.rs +++ b/crates/registry-breg-client-py/src/lib.rs @@ -1287,6 +1287,8 @@ fn action_value(value: &breg_client_sdk::BRegActionDescriptor) -> Value { "target_record_type": input.target_record_type(), })).collect::>(), "required_condition_keys": value.required_condition_keys(), + "subject_input": value.subject_input(), + "writable_inputs": value.writable_inputs(), "result_effects": value.result_effects().iter().map(|effect| json!({ "effect": effect.effect_identifier(), "record_type": effect.record_type_identifier(), @@ -1566,7 +1568,9 @@ impl Metadata { fn proposal_actions<'py>(&self, py: Python<'py>) -> PyResult> { json_to_python(py, &Value::Array(self.inner.proposal_actions().iter().map(|entry| json!({ "action_id": entry.action_identifier(), "access_profile": entry.access_profile(), + "party": entry.party(), "operations": entry.operations(), "readable_inputs": entry.readable_inputs(), + "writable_inputs": entry.writable_inputs(), "readable_context_fields": entry.readable_context_fields(), })).collect())) } diff --git a/crates/registry-breg-client-py/tests/python/test_proposals.py b/crates/registry-breg-client-py/tests/python/test_proposals.py index 674e03fe28..6ddce52a2e 100644 --- a/crates/registry-breg-client-py/tests/python/test_proposals.py +++ b/crates/registry-breg-client-py/tests/python/test_proposals.py @@ -15,7 +15,7 @@ 'id': 'proposal-lookup', 'version': '1', 'revision': REVISION, 'metadataVersion': '2', 'recordTypes': [], 'operations': [], 'actions': [], 'proposals': {'method': 'GET', 'path': '/v1/proposals', 'accessProfiles': [], - 'actions': [{'actionId': 'correct', 'accessProfile': 'reader', 'operations': ['get'], 'readableInputs': ['address-line'], 'readableContextFields': []}], + 'actions': [{'actionId': 'correct', 'accessProfile': 'reader', 'party': 'subject', 'operations': ['get'], 'readableInputs': ['address-line'], 'writableInputs': [], 'readableContextFields': []}], 'get': {'method': 'GET', 'path': '/v1/proposals/{proposal_id}', 'accessProfiles': ['reader']}}, } PROPOSAL = { @@ -110,8 +110,10 @@ def log_message(self, *args): client = BaseRegistryClient(f'http://127.0.0.1:{server.server_port}/') metadata = client.registry_contract('writer') self.assertEqual(metadata.proposal_actions, [ - {'action_id': 'correct', 'access_profile': 'queue', 'operations': ['list'], 'readable_inputs': [], 'readable_context_fields': []}, - {'action_id': 'correct', 'access_profile': 'executor', 'operations': ['apply'], 'readable_inputs': [], 'readable_context_fields': []}]) + {'action_id': 'correct', 'access_profile': 'queue', 'party': None, 'operations': ['list'], 'readable_inputs': [], + 'writable_inputs': None, 'readable_context_fields': []}, + {'action_id': 'correct', 'access_profile': 'executor', 'party': None, 'operations': ['apply'], 'readable_inputs': [], + 'writable_inputs': None, 'readable_context_fields': []}]) self.assertEqual(metadata.actions[0]['attachments'], [{'id': 'supporting-file', 'required': True, 'content_types': ['application/pdf'], 'maximum_bytes': 1024}]) with self.assertRaises(BaseRegistryClientError): @@ -204,8 +206,9 @@ def log_message(self, *args): try: client = BaseRegistryClient(f'http://127.0.0.1:{server.server_port}/tenant/') metadata = client.registry_contract('reader') - self.assertEqual(metadata.proposal_actions, [{'action_id': 'correct', 'access_profile': 'reader', - 'operations': ['get'], 'readable_inputs': ['address-line'], 'readable_context_fields': []}]) + self.assertEqual(metadata.proposal_actions, [{'action_id': 'correct', 'access_profile': 'reader', 'party': 'subject', + 'operations': ['get'], 'readable_inputs': ['address-line'], + 'writable_inputs': [], 'readable_context_fields': []}]) with self.assertRaises(BaseRegistryClientError): metadata.select_proposals('reader') binding = metadata.select_proposal_get('reader') diff --git a/crates/registry-breg-client/src/error.rs b/crates/registry-breg-client/src/error.rs index b45093ce73..fdf70c275c 100644 --- a/crates/registry-breg-client/src/error.rs +++ b/crates/registry-breg-client/src/error.rs @@ -168,6 +168,8 @@ pub enum BRegProblemCode { ProfileNotAuthorized, ProposalRejected, ProposalReviewResultMismatch, + ProposalSubjectChanged, + ProposalSubjectNotCaller, ProposalSubmissionExpired, QueryCursorInvalid, QueryFilterRequired, @@ -189,7 +191,7 @@ pub enum BRegProblemCode { } impl BRegProblemCode { - pub const ALL: [Self; 48] = [ + pub const ALL: [Self; 50] = [ Self::AccessProfileAmbiguous, Self::ActionEvidenceFailed, Self::ActionGuardFailed, @@ -220,6 +222,8 @@ impl BRegProblemCode { Self::ProfileNotAuthorized, Self::ProposalRejected, Self::ProposalReviewResultMismatch, + Self::ProposalSubjectChanged, + Self::ProposalSubjectNotCaller, Self::ProposalSubmissionExpired, Self::QueryCursorInvalid, Self::QueryFilterRequired, @@ -273,6 +277,8 @@ impl BRegProblemCode { Self::ProfileNotAuthorized => "profile.not-authorized", Self::ProposalRejected => "proposal.rejected", Self::ProposalReviewResultMismatch => "proposal.review-result-mismatch", + Self::ProposalSubjectChanged => "proposal.subject-changed", + Self::ProposalSubjectNotCaller => "proposal.subject-not-caller", Self::ProposalSubmissionExpired => "proposal.submission-expired", Self::QueryCursorInvalid => "query.cursor-invalid", Self::QueryFilterRequired => "query.filter-required", @@ -309,6 +315,7 @@ impl BRegProblemCode { Self::LookupUnresolved | Self::ResourceNotFound => 404, Self::IngestionProfileMismatch | Self::ProfileNotAuthorized + | Self::ProposalSubjectNotCaller | Self::WriteOutsideBoundary => 403, Self::AttachmentSlotWriteOnce | Self::AttachmentLimitReached @@ -319,6 +326,7 @@ impl BRegProblemCode { | Self::IngestionRunNotOpen | Self::MutationConflict | Self::ProposalRejected + | Self::ProposalSubjectChanged | Self::StatisticalDatasetVersionConflict => 409, Self::IdempotencyExpired | Self::IngestionReceiptErased @@ -430,6 +438,8 @@ impl BRegProblemCode { } Self::PreconditionFailed => "The mutation precondition failed.", Self::ProposalReviewResultMismatch => "The current review result does not match the retained approval.", + Self::ProposalSubjectChanged => "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.", + Self::ProposalSubjectNotCaller => "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.", Self::PreconditionRequired => "The mutation precondition is required.", Self::ProfileNotAuthorized => "No access profile admits this caller for this request.", Self::ProposalRejected => { diff --git a/crates/registry-breg-client/src/metadata.rs b/crates/registry-breg-client/src/metadata.rs index 76a01d4c98..103388cfe0 100644 --- a/crates/registry-breg-client/src/metadata.rs +++ b/crates/registry-breg-client/src/metadata.rs @@ -1052,8 +1052,12 @@ impl fmt::Debug for BRegActionAttachmentDescriptor { pub struct BRegProposalActionDescriptor { action_id: String, access_profile: String, + #[serde(skip_serializing_if = "Option::is_none")] + party: Option, operations: Vec, readable_inputs: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + writable_inputs: Option>, readable_context_fields: Vec, } @@ -1064,12 +1068,24 @@ impl BRegProposalActionDescriptor { pub fn access_profile(&self) -> &str { &self.access_profile } + /// The Proposal party this entry is bound to; `None` for an entry bound + /// to no party, such as an officer's. + #[must_use] + pub const fn party(&self) -> Option { + self.party + } pub fn operations(&self) -> &[String] { &self.operations } pub fn readable_inputs(&self) -> &[String] { &self.readable_inputs } + /// The inputs this entry may set through Start, Edit, Revise or Rebase. + /// Empty when it writes none; `None` from a server that predates the + /// member. + pub fn writable_inputs(&self) -> Option<&[String]> { + self.writable_inputs.as_deref() + } pub fn readable_context_fields(&self) -> &[String] { &self.readable_context_fields } @@ -1103,6 +1119,8 @@ pub struct BRegActionDescriptor { attachments: Vec, reference_inputs: Vec, required_condition_keys: Vec, + subject_input: Option, + writable_inputs: Option>, result_effects: Vec, access_profile: String, invoke_path: Option, @@ -1138,6 +1156,16 @@ impl BRegActionDescriptor { pub const fn application(&self) -> Option<&BRegActionApplication> { self.application.as_ref() } + /// The input that names the person a Proposal is about. `None` when the + /// Action declares no subject or the selected profile cannot read it. + pub fn subject_input(&self) -> Option<&str> { + self.subject_input.as_deref() + } + /// The inputs the selected profile may set. `None` for an immediate + /// Action or a server that predates the member. + pub fn writable_inputs(&self) -> Option<&[String]> { + self.writable_inputs.as_deref() + } #[must_use] pub fn identifier(&self) -> &str { &self.id @@ -3456,6 +3484,28 @@ fn parse_actions(value: Value) -> Result, BRegMetadata .map(parse_action_result_effect) .collect::, _>>()?; ensure_unique(result_effects.iter().map(|effect| effect.effect.as_str()))?; + let subject_input = action + .remove("subject") + .map(|value| { + let mut subject = object(value)?; + let input = identifier(required(&mut subject, "input")?)?; + finish(subject)?; + Ok::<_, BRegMetadataError>(input) + }) + .transpose()?; + if subject_input + .as_ref() + .is_some_and(|subject| !inputs.iter().any(|input| input.id == *subject)) + { + return Err(metadata_error(BRegMetadataErrorKind::DanglingReference)); + } + let writable_inputs = action + .remove("writableInputs") + .map(identifier_array) + .transpose()?; + if let Some(writable) = &writable_inputs { + ensure_unique(writable.iter().map(String::as_str))?; + } let mut access = object(required(&mut action, "access")?)?; let access_profile = identifier(required(&mut access, "selectedProfile")?)?; @@ -3552,6 +3602,8 @@ fn parse_actions(value: Value) -> Result, BRegMetadata attachments, reference_inputs, required_condition_keys, + subject_input, + writable_inputs, result_effects, access_profile, invoke_path, @@ -3573,7 +3625,14 @@ fn parse_proposal_actions( let mut entry = object(value)?; let action_id = identifier(required(&mut entry, "actionId")?)?; let access_profile = identifier(required(&mut entry, "accessProfile")?)?; - if !identities.insert((action_id.clone(), access_profile.clone())) { + let party = entry + .remove("party") + .map(|value| { + serde_json::from_value::(value) + .map_err(|_| metadata_error(BRegMetadataErrorKind::Shape)) + }) + .transpose()?; + if !identities.insert((action_id.clone(), access_profile.clone(), party)) { return Err(metadata_error(BRegMetadataErrorKind::DuplicateIdentifier)); } let operations = identifier_array(required(&mut entry, "operations")?)?; @@ -3587,6 +3646,13 @@ fn parse_proposal_actions( { return Err(metadata_error(BRegMetadataErrorKind::Shape)); } + let writable_inputs = entry + .remove("writableInputs") + .map(identifier_array) + .transpose()?; + if let Some(writable) = &writable_inputs { + ensure_unique(writable.iter().map(String::as_str))?; + } let readable_context_fields = entry .remove("readableContextFields") .map(api_name_array) @@ -3608,8 +3674,10 @@ fn parse_proposal_actions( Ok(BRegProposalActionDescriptor { action_id, access_profile, + party, operations, readable_inputs, + writable_inputs, readable_context_fields, }) }) diff --git a/crates/registry-breg-client/src/metadata_tests.rs b/crates/registry-breg-client/src/metadata_tests.rs index 4917abe9ea..cd5e093e02 100644 --- a/crates/registry-breg-client/src/metadata_tests.rs +++ b/crates/registry-breg-client/src/metadata_tests.rs @@ -955,6 +955,53 @@ fn scalar_api_names_and_query_field_identities_remain_strict() { assert!(BRegMetadata::from_slice(&serde_json::to_vec(&source).unwrap()).is_err()); } +#[test] +fn proposal_inventory_keeps_one_entry_per_party_and_its_writable_inputs() { + let mut source = proposal_action_metadata(); + source["proposals"]["actions"] = json!([ + {"actionId":"correct-address","accessProfile":"citizen","party":"owner","operations":["get","edit"], + "readableInputs":["address"],"writableInputs":["address"],"readableContextFields":[]}, + {"actionId":"correct-address","accessProfile":"citizen","party":"subject","operations":["get"], + "readableInputs":["address"],"writableInputs":[],"readableContextFields":[]} + ]); + let metadata = parse(&source); + let entries = metadata.proposal_actions(); + assert_eq!(entries.len(), 2); + assert_eq!( + entries[0].party(), + Some(crate::BRegProposalPartyRole::Owner) + ); + assert_eq!( + entries[0].writable_inputs(), + Some(&["address".to_owned()][..]) + ); + assert_eq!( + entries[1].party(), + Some(crate::BRegProposalPartyRole::Subject) + ); + assert_eq!(entries[1].writable_inputs(), Some(&[][..])); + assert_eq!( + serde_json::to_value(entries).unwrap(), + source["proposals"]["actions"] + ); + let mut duplicate = source.clone(); + duplicate["proposals"]["actions"][1]["party"] = json!("owner"); + assert_eq!( + BRegMetadata::from_slice(&serde_json::to_vec(&duplicate).unwrap()) + .unwrap_err() + .kind(), + BRegMetadataErrorKind::DuplicateIdentifier + ); + let mut unknown = source; + unknown["proposals"]["actions"][1]["party"] = json!("representative"); + assert_eq!( + BRegMetadata::from_slice(&serde_json::to_vec(&unknown).unwrap()) + .unwrap_err() + .kind(), + BRegMetadataErrorKind::Shape + ); +} + #[test] fn proposal_inventory_preserves_exact_profile_operations_and_readable_inputs() { let mut source = proposal_action_metadata(); diff --git a/crates/registry-breg-client/src/proposal.rs b/crates/registry-breg-client/src/proposal.rs index e4d0d45efa..26b72a152d 100644 --- a/crates/registry-breg-client/src/proposal.rs +++ b/crates/registry-breg-client/src/proposal.rs @@ -624,6 +624,8 @@ pub struct BRegProposal { application_status: Option, #[serde(default, skip_serializing_if = "Option::is_none")] turn: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + party_role: Option, #[serde( default, skip_serializing_if = "Option::is_none", @@ -637,7 +639,24 @@ pub struct BRegProposal { #[serde(skip)] source: Option, } +/// Which party of a Proposal a party-bound grant admitted the caller as. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum BRegProposalPartyRole { + /// The caller filed the Proposal. + Owner, + /// The Proposal is about the caller, who may not have filed it. + Subject, +} + impl BRegProposal { + /// The party a party-bound grant admitted the caller as. `None` for an + /// officer's read and from a server that predates the member. + #[must_use] + pub const fn party_role(&self) -> Option { + self.party_role + } /// Only input fields explicitly disclosed to the selected caller profile. pub fn input(&self) -> Option<&serde_json::Map> { self.input.as_ref() diff --git a/crates/registry-breg-client/tests/proposal_party.rs b/crates/registry-breg-client/tests/proposal_party.rs new file mode 100644 index 0000000000..855c5e766e --- /dev/null +++ b/crates/registry-breg-client/tests/proposal_party.rs @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 +//! The Proposal document names the party a party-bound grant admitted. +use registry_breg_client::{BRegProposal, BRegProposalPartyRole}; +use serde_json::{json, Value}; + +fn proposal(party: Option<&str>) -> Value { + let mut value = json!({"id":"00000000-0000-4000-8000-000000000001","actionId":"apply-for-licence", + "actionRevision":format!("sha256:{}","a".repeat(64)),"submissionVersion":1,"revision":2, + "state":"submitted","turn":"official","effectDigest":format!("sha256:{}","b".repeat(64)),"links":{}}); + if let Some(party) = party { + value["partyRole"] = json!(party); + } + value +} + +fn decode(value: &Value) -> Result { + BRegProposal::from_slice(&serde_json::to_vec(value).unwrap()) +} + +#[test] +fn party_role_decodes_and_stays_closed() { + assert_eq!( + decode(&proposal(Some("subject"))).unwrap().party_role(), + Some(BRegProposalPartyRole::Subject) + ); + assert_eq!( + decode(&proposal(Some("owner"))).unwrap().party_role(), + Some(BRegProposalPartyRole::Owner) + ); + // An officer's read carries none. + assert_eq!(decode(&proposal(None)).unwrap().party_role(), None); + assert!(decode(&proposal(Some("representative"))).is_err()); +} diff --git a/crates/registry-breg-client/tests/write_http_boundary.rs b/crates/registry-breg-client/tests/write_http_boundary.rs index 0741dbaa76..36a654a892 100644 --- a/crates/registry-breg-client/tests/write_http_boundary.rs +++ b/crates/registry-breg-client/tests/write_http_boundary.rs @@ -2255,6 +2255,12 @@ fn problem_detail(code: BRegProblemCode) -> &'static str { "The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt." } Code::ProposalReviewResultMismatch => "The current review result does not match the retained approval.", + Code::ProposalSubjectChanged => { + "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal." + } + Code::ProposalSubjectNotCaller => { + "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself." + } Code::ProposalSubmissionExpired => { "The review result and application receipt of the submission are no longer retained." } diff --git a/crates/registry-breg-mcp/tests/support/citizen_project.rs b/crates/registry-breg-mcp/tests/support/citizen_project.rs index 6d916ff35e..f670514d69 100644 --- a/crates/registry-breg-mcp/tests/support/citizen_project.rs +++ b/crates/registry-breg-mcp/tests/support/citizen_project.rs @@ -37,7 +37,7 @@ pub fn project() -> Value { "permissions":{"records":[{"recordType":"person-address","operations":["get","list"], "readableFields":["address-line","locality","postal-code"],"rowBoundaries":boundary}], "actions":[{"action":"correct-address","operations":["start"],"targets":targets}], - "proposals":[{"action":"correct-address","operations":operations,"ownership":"caller", + "proposals":[{"action":"correct-address","operations":operations,"party":"owner", "readableInputs":inputs,"targets":targets}]}}); if actor == "agent" { profile["requiredPurposes"] = json!(["address-correction"]); diff --git a/crates/registry-breg/Cargo.toml b/crates/registry-breg/Cargo.toml index e31e51cb05..98d4aa1280 100644 --- a/crates/registry-breg/Cargo.toml +++ b/crates/registry-breg/Cargo.toml @@ -473,6 +473,11 @@ name = "postgres_proposal_security" path = "tests/postgres_proposal_security.rs" required-features = ["postgres-test"] +[[test]] +name = "postgres_proposal_subject" +path = "tests/postgres_proposal_subject.rs" +required-features = ["postgres-test"] + [[test]] name = "postgres_proposal_s3" path = "tests/postgres_proposal_s3.rs" diff --git a/crates/registry-breg/src/access.rs b/crates/registry-breg/src/access.rs index d1c9f26081..97768a6f33 100644 --- a/crates/registry-breg/src/access.rs +++ b/crates/registry-breg/src/access.rs @@ -8,8 +8,9 @@ use serde::Serialize; use crate::compiler::operation_id; use crate::contract::{ AccessProfileSource, AccessRequirementsSource, ActorKindSource, BoundaryOperator, - Classification, ConsentIssuerSource, EntitySource, FieldTypeSource, MembershipBoundarySource, - Operation, ProjectAccessProfileSource, RegistryProject, RowBoundarySource, + Classification, ConsentIssuerSource, EntitySource, ExpandedMembershipBoundarySource, + FieldTypeSource, MembershipBoundarySource, Operation, ProjectAccessProfileSource, + RegistryProject, RowBoundarySource, }; use crate::diagnostics::Diagnostic; use crate::model::{ @@ -114,28 +115,42 @@ pub(crate) fn check_profile( path: &str, errors: &mut Vec, ) { - for scope in requirements - .required_scopes - .difference(&profile.required_scopes) - { + check_profile_authority( + requirements, + &profile.required_scopes, + &profile.required_purposes, + path, + errors, + ); + for boundary in &requirements.row_boundaries { + if !profile.row_boundaries.contains(boundary) { + errors.push(Diagnostic::error( + "breg.access.requirements-row-boundary-missing", + format!("{path}.rowBoundaries[field={}]", boundary.field), + "Include the Record type's exact field, claim and operator binding. Request filters and other claim names do not satisfy this requirement.", + )); + } + } +} + +pub(crate) fn check_profile_authority( + requirements: &AccessRequirementsSource, + required_scopes: &crate::contract::UniqueSet, + required_purposes: &crate::contract::UniqueSet, + path: &str, + errors: &mut Vec, +) { + for scope in requirements.required_scopes.difference(required_scopes) { errors.push(Diagnostic::error("breg.access.requirements-scope-missing", format!("{path}.requiredScopes[value={scope}]"), "add the record type's mandatory scope to this profile; granting other scopes does not satisfy it")); } if !requirements.allowed_purposes.is_empty() - && (profile.required_purposes.is_empty() - || !profile - .required_purposes - .is_subset(&requirements.allowed_purposes)) + && (required_purposes.is_empty() + || !required_purposes.is_subset(&requirements.allowed_purposes)) { errors.push(Diagnostic::error("breg.access.requirements-purpose-widened", format!("{path}.requiredPurposes"), "require a nonempty subset of the record type's allowedPurposes; an empty list allows every purpose")); } - for boundary in &requirements.row_boundaries { - if !profile.row_boundaries.contains(boundary) { - errors.push(Diagnostic::error("breg.access.requirements-row-boundary-missing", format!("{path}.rowBoundaries[field={}]", boundary.field), - "include the record type's exact field, claim, and operator binding; request filters and other claim names do not satisfy this requirement")); - } - } } const TASK_GRANT_ROWS_UNBOUND: &str = "breg.access-profile.task-grant-rows-unbound"; @@ -377,7 +392,7 @@ pub(crate) fn compiled_access_findings( grant.entity_target_locks().map(move |target| { ( &target.entity_id, - &target.row_boundaries, + target.row_boundaries.is_empty() && target.membership_boundaries.is_empty(), format!( "actions[id={}].permissions[profile={}].targets[recordType={}].rowBoundaries", action.id, grant.profile_id, target.entity_id @@ -392,7 +407,7 @@ pub(crate) fn compiled_access_findings( grant.targets.iter().map(move |target| { ( &target.entity_id, - &target.row_boundaries, + target.row_boundaries.is_empty() && target.membership_boundaries.is_empty(), format!( "actions[id={}].execution.proposal.permissions[profile={}].targets[recordType={}].rowBoundaries", action.id, grant.profile_id, target.entity_id @@ -400,8 +415,8 @@ pub(crate) fn compiled_access_findings( ) }) }); - for (entity_id, boundaries, path) in action_targets.chain(proposal_targets) { - if boundaries.is_empty() + for (entity_id, unbounded, path) in action_targets.chain(proposal_targets) { + if unbounded && entities .get(entity_id) .is_some_and(|entity| entity.classification != Classification::Public) @@ -852,7 +867,7 @@ fn inspect_record_profile( profile: &AccessProfileSource, ) -> serde_json::Value { let mut value = serde_json::to_value(profile).expect("compiled access profile serializes"); - if profile.row_boundaries.is_empty() { + if profile.row_boundaries.is_empty() && profile.membership_boundaries.is_empty() { value["rowBoundaries"] = serde_json::json!("unrestricted"); } value["allowCount"] = serde_json::json!(profile.allow_count); @@ -879,8 +894,11 @@ pub struct RowReachExplanation { pub rows: &'static str, pub row_boundaries: Vec, #[serde(skip_serializing_if = "Vec::is_empty")] - pub membership_boundaries: Vec, + pub membership_boundaries: Vec, pub owner_only: bool, + /// The Proposal party the grant is bound to, for a Proposal target. + #[serde(skip_serializing_if = "Option::is_none")] + pub party: Option, /// Action target authority is enforced only while the named Action runs. /// It is an additional grant and never becomes ordinary Record CRUD. #[serde(skip_serializing_if = "Option::is_none")] @@ -911,14 +929,41 @@ fn row_reach( entities: &BTreeMap, actions: &CompiledActionInventory, ) -> Vec { + let record_memberships = |entries: &[MembershipBoundarySource]| { + entries + .iter() + .filter_map(|entry| match entry { + MembershipBoundarySource::Expanded(entry) => Some(entry.clone()), + MembershipBoundarySource::Declared(_) => None, + }) + .collect() + }; + let target_memberships = |entries: &[crate::model::CompiledMembershipBoundary]| { + entries + .iter() + .filter_map(|entry| { + let declaration = entities + .get(&entry.membership_entity)? + .membership + .as_ref()?; + Some(ExpandedMembershipBoundarySource { + field: entry.field.clone(), + membership_entity: entry.membership_entity.clone(), + membership_key_field: declaration.key.clone(), + principal_field: declaration.principal.clone(), + active_field: declaration.active.clone(), + }) + }) + .collect() + }; let mut reach = Vec::new(); let mut add = |entity: &str, profile: &str, source_path: String, surface, boundaries: &[RowBoundarySource], - memberships: &[MembershipBoundarySource], - owner, + memberships: Vec, + party: Option, action_target_authority| { reach.push(RowReachExplanation { entity: entity.to_owned(), @@ -932,8 +977,9 @@ fn row_reach( (false, false) => "claim_and_membership_bound", }, row_boundaries: boundaries.to_vec(), - membership_boundaries: memberships.to_vec(), - owner_only: owner, + membership_boundaries: memberships, + owner_only: party == Some(crate::contract::ProposalParty::Owner), + party, action_target_authority, }); }; @@ -946,8 +992,8 @@ fn row_reach( format!("{path}.rowBoundaries"), "record", &profile.row_boundaries, - &profile.membership_boundaries, - false, + record_memberships(&profile.membership_boundaries), + None, None, ); for grant in &profile.read_paths { @@ -960,8 +1006,8 @@ fn row_reach( format!("{path}.readPaths[path={}]", grant.path), "read_path", &profile.row_boundaries, - &profile.membership_boundaries, - false, + record_memberships(&profile.membership_boundaries), + None, None, ); } @@ -979,8 +1025,8 @@ fn row_reach( ), "action_target", &target.row_boundaries, - &[], - false, + target_memberships(&target.membership_boundaries), + None, Some(ActionTargetAuthorityExplanation { enforcement: "runtime_enforced", record_grant_relationship: "additional", @@ -1028,8 +1074,8 @@ fn row_reach( ), "proposal_target", &target.row_boundaries, - &[], - grant.ownership == Some(crate::contract::ProposalOwnership::Caller), + target_memberships(&target.membership_boundaries), + grant.party, None, ); } diff --git a/crates/registry-breg/src/api/actions.rs b/crates/registry-breg/src/api/actions.rs index 30a9d2c214..47d66c802d 100644 --- a/crates/registry-breg/src/api/actions.rs +++ b/crates/registry-breg/src/api/actions.rs @@ -191,6 +191,7 @@ fn authorize_action_mode<'a>( Some(selected), crate::postgres::ProposalAuthorityOperation::Start, None, + proposals::PartySelection::Any, ) .map_err(|err| match err { proposals::ProposalAdmissionError::Refused(check) => check, @@ -295,6 +296,18 @@ fn authorize_action_mode<'a>( target_authority, grant.results.clone(), ) + .with_target_memberships( + grant + .entity_target_locks() + .filter(|target| !target.membership_boundaries.is_empty()) + .map(|target| { + ( + target.entity_id.clone(), + target.membership_boundaries.clone(), + ) + }) + .collect(), + ) .with_audit_context(claims) .with_task_grant(task_grant), admitted_profiles: vec![selected.to_owned()], @@ -563,6 +576,9 @@ pub(super) async fn dispatch( } } } + Err(MutationError::MembershipPreconditionFailed) => { + membership_precondition_problem(&correlation) + } Err(error) => mutation_problem(error), } } @@ -581,6 +597,9 @@ pub(super) async fn dispatch( Err(crate::mutation::MutationError::PreconditionFailed) => { concealed(FailedCheck::RowBoundary) } + Err(MutationError::MembershipPreconditionFailed) => { + concealed(FailedCheck::Membership) + } Err(error) => mutation_problem(error), } } diff --git a/crates/registry-breg/src/api/actions/availability.rs b/crates/registry-breg/src/api/actions/availability.rs index 15db17d548..ec1d31755f 100644 --- a/crates/registry-breg/src/api/actions/availability.rs +++ b/crates/registry-breg/src/api/actions/availability.rs @@ -6,6 +6,7 @@ use super::*; use crate::contract::FieldTypeSource; +use crate::postgres::ActionTargetMembershipObservation; pub(super) enum Availability { Satisfied { @@ -115,6 +116,12 @@ pub(super) async fn observe( record_id, &guard_fields, &boundaries, + action + .context + .target_memberships() + .get(target) + .map(Vec::as_slice) + .unwrap_or_default(), correlation, ) .await? @@ -184,6 +191,7 @@ pub(in crate::api) async fn observe_target( record_id: &str, guard_fields: &BTreeSet, boundaries: &[crate::postgres::RowBoundaryContext], + memberships: &[crate::model::CompiledMembershipBoundary], correlation: &RequestCorrelation, ) -> Result, Response> { let target = &entity.id; @@ -196,6 +204,13 @@ pub(in crate::api) async fn observe_target( .filter(|boundary| boundary.field() != entity.canonical_id.id) .map(|boundary| boundary.field().to_owned()), ) + // The canonical identifier is the row itself, not a readable field. + .chain( + memberships + .iter() + .filter(|boundary| boundary.field != entity.canonical_id.id) + .map(|boundary| boundary.field.clone()), + ) .collect::>(); let Some(route) = service .registry @@ -222,6 +237,7 @@ pub(in crate::api) async fn observe_target( if let Some(refusal) = field_encryption_refusal(service, entity) { return Err(refusal); } + let membership_context = (!memberships.is_empty()).then(|| surface.context.clone()); let read = service .records .get(RecordReadRequest { @@ -286,6 +302,30 @@ pub(in crate::api) async fn observe_target( { return Err(concealed(FailedCheck::RowBoundary)); } + if let Some(context) = &membership_context { + let mutations = service.mutations.as_ref().ok_or_else(unavailable)?; + let observation = mutations + .observe_action_target_membership( + context, + entity, + Uuid::parse_str(record_id).map_err(|_| unavailable())?, + i64::try_from(revision).map_err(|_| unavailable())?, + memberships, + &fields, + ) + .await + .map_err(|_| unavailable())?; + match observation { + ActionTargetMembershipObservation::Authorized => {} + ActionTargetMembershipObservation::OutsideBoundary => { + return Err(concealed(FailedCheck::Membership)); + } + ActionTargetMembershipObservation::Withheld => return Ok(None), + ActionTargetMembershipObservation::Missing => { + return Err(concealed(FailedCheck::Visibility)); + } + } + } Ok(Some(ObservedTarget { revision, current })) } diff --git a/crates/registry-breg/src/api/attachments.rs b/crates/registry-breg/src/api/attachments.rs index eba680ff4a..b287a926ad 100644 --- a/crates/registry-breg/src/api/attachments.rs +++ b/crates/registry-breg/src/api/attachments.rs @@ -143,10 +143,10 @@ async fn authorize<'a>( None }; let slot = addition_slot.unwrap_or(slot); - let grant = proposal.permissions.iter().find(|grant| { - grant.profile_id == authority.common.access_profile() - && grant.operations.contains(&operation) - }); + // The entry that admitted the caller, party included, decides the slot. + let grant = authority + .permission(proposal) + .filter(|grant| grant.operations.contains(&operation)); let allowed = grant.is_some_and(|grant| match operation { ProposalOperation::Get => grant.readable_attachments.contains(slot), ProposalOperation::GetReviewContext => match context_source { @@ -254,6 +254,23 @@ async fn mutate( ) .await } + MutationError::MembershipPreconditionFailed => { + super::proposals::admitted_http_refusal_with( + mutations, + &authority, + mutation_method(removal, addition), + &correlation, + || { + if addition { + concealed(FailedCheck::Membership) + } else { + // Count the generic 412 only after audit accepts it. + membership_precondition_problem(&correlation) + } + }, + ) + .await + } MutationError::PreconditionFailed if addition => { super::proposals::admitted_http_refusal( mutations, @@ -388,6 +405,12 @@ async fn mutate( "", service.field_encryption.as_deref(), ), + Err(MutationError::MembershipPreconditionFailed) if addition => { + concealed(FailedCheck::Membership) + } + Err(MutationError::MembershipPreconditionFailed) => { + membership_precondition_problem(&correlation) + } Err(MutationError::PreconditionFailed) => precondition_failed(), Err(error) => super::proposals::proposal_target_problem(error), } @@ -510,6 +533,7 @@ async fn download_file( .header(VARY, "authorization") .body(Body::from(bytes)) .unwrap_or_else(|_| unavailable()), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), Err(error) => super::proposals::proposal_target_problem(error), } diff --git a/crates/registry-breg/src/api/context.rs b/crates/registry-breg/src/api/context.rs index 2a1071e4bd..56930ef8ee 100644 --- a/crates/registry-breg/src/api/context.rs +++ b/crates/registry-breg/src/api/context.rs @@ -626,6 +626,7 @@ pub struct AuthorizedActionContext { purpose: Option, selected_profile: String, target_authority: BTreeMap>, + target_memberships: BTreeMap>, result_effects: BTreeSet, audit_context: Option, task_grant: Option, @@ -647,6 +648,7 @@ impl AuthorizedActionContext { purpose, selected_profile, target_authority, + target_memberships: BTreeMap::new(), result_effects, audit_context: None, task_grant: None, @@ -654,6 +656,20 @@ impl AuthorizedActionContext { } } + pub(crate) fn with_target_memberships( + mut self, + memberships: BTreeMap>, + ) -> Self { + self.target_memberships = memberships; + self + } + + pub(crate) fn target_memberships( + &self, + ) -> &BTreeMap> { + &self.target_memberships + } + pub(crate) fn with_audit_context(mut self, claims: &VerifiedRequestClaims) -> Self { self.audit_context = crate::audit::RequestAuditContext::from_claims(claims); self.caller_issuer = claims.caller_issuer().map(str::to_owned); diff --git a/crates/registry-breg/src/api/mod.rs b/crates/registry-breg/src/api/mod.rs index 3fa675c1d9..f80aa02145 100644 --- a/crates/registry-breg/src/api/mod.rs +++ b/crates/registry-breg/src/api/mod.rs @@ -777,6 +777,13 @@ async fn registry_metadata( .as_array() .cloned() .unwrap_or_default(); + // A reader sees the effects on the Record types this document shows it. + let visible_record_types = metadata["recordTypes"] + .as_array() + .into_iter() + .flatten() + .filter_map(|record_type| record_type["id"].as_str().map(str::to_owned)) + .collect::>(); // A lifecycle reader can describe the inputs it may inspect without // acquiring authority to start another Proposal. for (action_id, profile_id, operation) in &visible_proposals { @@ -799,11 +806,12 @@ async fn registry_metadata( let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution else { continue; }; - let Some(grant) = proposal - .permissions - .iter() - .find(|grant| &grant.profile_id == profile_id) - else { + let Some(grant) = proposal.permissions.iter().find(|grant| { + &grant.profile_id == profile_id + && grant + .operations + .contains(&crate::model::ProposalOperation::Get) + }) else { continue; }; let mut description = @@ -818,7 +826,19 @@ async fn registry_metadata( .expect("Action description") .remove("conditionRoute"); description["requiredConditionKeys"] = json!([]); - description["resultEffects"] = json!([]); + description["writableInputs"] = json!([]); + // The effects a Proposal applies, limited to Record types this + // document already shows the reader; no Action grant is involved. + description["resultEffects"] = json!(action + .effects + .iter() + .filter(|effect| visible_record_types.contains(&effect.target.entity_id)) + .map(|effect| json!({ + "effect": effect.id, + "recordType": effect.target.entity_id, + "operation": crate::artifacts::operation_name(effect.operation), + })) + .collect::>()); if let Some(attachments) = description["attachments"].as_array_mut() { attachments.retain(|slot| { slot["id"] @@ -840,6 +860,16 @@ async fn registry_metadata( .is_some_and(|id| grant.readable_inputs.contains(id)) }); } + // The subject input is named only to a reader that can read it. + if !description["subject"]["input"] + .as_str() + .is_some_and(|id| grant.readable_inputs.contains(id)) + { + description + .as_object_mut() + .expect("Action description") + .remove("subject"); + } action_metadata.push(description); } if !action_metadata.is_empty() { @@ -856,34 +886,62 @@ async fn registry_metadata( .filter(|(_, _, operation)| *operation == crate::model::ProposalOperation::Get) .map(|(_, profile, _)| profile) .collect::>(); - let mut inventory = BTreeMap::<(&str, &str), Vec<&str>>::new(); - for (action, profile, operation) in &visible_proposals { - inventory - .entry((action.as_str(), profile.as_str())) - .or_default() - .push(operation.as_str()); + // One entry for each visible grant: a profile with an owner and a + // subject entry for one Action has two. + let mut inventory = Vec::new(); + let mut described = BTreeSet::new(); + for (action_id, profile, _) in &visible_proposals { + if !described.insert((action_id, profile)) { + continue; + } + let Some(action) = service + .registry + .actions() + .actions + .iter() + .find(|candidate| &candidate.id == action_id) + else { + continue; + }; + let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution + else { + continue; + }; + for grant in proposal + .permissions + .iter() + .filter(|grant| &grant.profile_id == profile) + { + let operations = grant + .operations + .iter() + .filter(|operation| { + visible_proposals.contains(&( + action_id.clone(), + profile.clone(), + **operation, + )) + }) + .map(|operation| operation.as_str()) + .collect::>(); + if operations.is_empty() { + continue; + } + let mut entry = json!({ + "actionId": action_id, "accessProfile": profile, "operations": operations, + "readableInputs": if operations.contains(&"get") { grant.readable_inputs.clone() } else { BTreeSet::new() }, + "writableInputs": crate::artifacts::proposal_writable_inputs(action, grant), + "readableContextFields": if operations.contains(&"get-review-context") || operations.contains(&"get-task-grant-context") { grant.readable_context_fields.clone() } else { BTreeSet::new() }, + }); + if let Some(party) = grant.party { + entry["party"] = json!(party); + } + inventory.push(entry); + } } metadata["proposals"] = json!({"method":"GET","path":"/v1/proposals", "accessProfiles":list_profiles, "get":{"method":"GET","path":"/v1/proposals/{proposal_id}","accessProfiles":get_profiles}, - "actions":inventory.into_iter().map(|((action,profile),operations)|json!({ - "actionId":action,"accessProfile":profile,"operations":operations, - "readableInputs":if operations.contains(&"get") { service.registry.actions().actions.iter() - .find(|candidate| candidate.id == action) - .and_then(|candidate| match &candidate.execution { - crate::model::CompiledActionExecution::Proposal { proposal } => proposal.permissions.iter() - .find(|grant| grant.profile_id == profile), - _ => None, - }).map(|grant| grant.readable_inputs.clone()).expect("visible Proposal grant") - } else { BTreeSet::new() }, - "readableContextFields":if operations.contains(&"get-review-context") || operations.contains(&"get-task-grant-context") { service.registry.actions().actions.iter() - .find(|candidate| candidate.id == action) - .and_then(|candidate| match &candidate.execution { - crate::model::CompiledActionExecution::Proposal { proposal } => proposal.permissions.iter() - .find(|grant| grant.profile_id == profile), - _ => None, - }).map(|grant| grant.readable_context_fields.clone()).expect("visible Proposal task-context grant") - } else { BTreeSet::new() } - })).collect::>()}); + "actions":inventory}); } // A peer that runs in lock-step with this engine release, such as a // Casework source adapter, compares this header with its own release and @@ -1470,6 +1528,7 @@ fn proposal_link_access( crate::model::ProposalOperation::Get, ), None, + proposals::PartySelection::Any, )?; authority .task_grant @@ -2109,7 +2168,7 @@ async fn create_dispatch( public_deployment_prefix(&service), service.field_encryption.as_deref(), ), - Err(error) => mutation_problem_for_fields(error, &surface.readable_fields), + Err(error) => mutation_problem_for_fields(error, &surface.readable_fields, &correlation), } } @@ -2288,7 +2347,7 @@ async fn patch_dispatch( public_deployment_prefix(&service), service.field_encryption.as_deref(), ), - Err(error) => mutation_problem_for_fields(error, &surface.readable_fields), + Err(error) => mutation_problem_for_fields(error, &surface.readable_fields, &correlation), } } @@ -2441,7 +2500,7 @@ async fn batch_dispatch( public_deployment_prefix(&service), service.field_encryption.as_deref(), ), - Err(error) => mutation_problem_for_fields(error, &surface.readable_fields), + Err(error) => mutation_problem_for_fields(error, &surface.readable_fields, &correlation), } } @@ -2592,7 +2651,7 @@ async fn tombstone_dispatch( public_deployment_prefix(&service), service.field_encryption.as_deref(), ), - Err(error) => mutation_problem_for_fields(error, &surface.readable_fields), + Err(error) => mutation_problem_for_fields(error, &surface.readable_fields, &correlation), } } @@ -2914,6 +2973,7 @@ fn visible_proposal_operations( Some(&grant.profile_id), crate::postgres::ProposalAuthorityOperation::Lifecycle(*operation), None, + proposals::PartySelection::Any, ) .is_some() { @@ -6065,6 +6125,11 @@ fn attachment_slot_problem(problem: ProblemCode, slot: &str) -> Response { ) } +fn membership_precondition_problem(correlation: &RequestCorrelation) -> Response { + crate::correlation::record_refusal_check(FailedCheck::Membership, correlation); + precondition_failed() +} + fn mutation_problem(error: MutationError) -> Response { let check = error.failed_check(); let response = mutation_problem_response(error); @@ -6082,10 +6147,14 @@ fn mutation_problem_response(error: MutationError) -> Response { MutationError::InvalidRequestAt(location) => invalid_request_at(&location), MutationError::AuthorizationRefused(_) | MutationError::PreconditionFailed + | MutationError::MembershipPreconditionFailed | MutationError::ProposalTargetChanged | MutationError::FieldGuardFailed { .. } | MutationError::ProposalGuardFailed(_) | MutationError::TimerGenerationUnsupported => precondition_failed(), + MutationError::MembershipWriteOutsideBoundary => { + refusal_problem(ProblemCode::WriteOutsideBoundary, FailedCheck::Membership) + } MutationError::WriteOutsideBoundary => { refusal_problem(ProblemCode::WriteOutsideBoundary, FailedCheck::RowBoundary) } @@ -6093,6 +6162,11 @@ fn mutation_problem_response(error: MutationError) -> Response { fixed_problem(ProblemCode::MutationConflict) } MutationError::ProposalRejected => fixed_problem(ProblemCode::ProposalRejected), + MutationError::ProposalSubjectNotCaller => refusal_problem( + ProblemCode::ProposalSubjectNotCaller, + FailedCheck::Ownership, + ), + MutationError::ProposalSubjectChanged => fixed_problem(ProblemCode::ProposalSubjectChanged), MutationError::AttachmentSlotWriteOnce => { fixed_problem(ProblemCode::AttachmentSlotWriteOnce) } @@ -6122,6 +6196,7 @@ fn mutation_problem_response(error: MutationError) -> Response { // the match stays exhaustive over the whole closed vocabulary. MutationError::Unavailable | MutationError::RetryableConflict + | MutationError::MembershipKeyDrift | MutationError::CommitUnresolved | MutationError::MigrationLockHeld | MutationError::PostureMismatch { .. } @@ -6158,8 +6233,10 @@ fn mutation_problem_response(error: MutationError) -> Response { fn mutation_problem_for_fields( error: MutationError, readable_fields: &BTreeSet, + correlation: &RequestCorrelation, ) -> Response { match error { + MutationError::MembershipPreconditionFailed => membership_precondition_problem(correlation), MutationError::InvalidTimerWindow { at_field, not_after_field, @@ -6363,7 +6440,7 @@ mod held_body_encryption_tests { secret ] }}, - "accessProfiles":{"caseworker": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"caseworker": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"case","rowBoundaries":"unrestricted","operations":["get","list","create","patch"], "readableFields":["label","secret"],"writableFields":["label","secret"] }]}}} @@ -6882,6 +6959,10 @@ mod refusal_check_tests { MutationError::WriteOutsideBoundary, FailedCheck::RowBoundary, ), + ( + MutationError::MembershipWriteOutsideBoundary, + FailedCheck::Membership, + ), ( MutationError::FieldGuardFailed { input: "input".to_owned(), @@ -6894,6 +6975,7 @@ mod refusal_check_tests { } for error in [ MutationError::PreconditionFailed, + MutationError::MembershipPreconditionFailed, MutationError::Conflict, MutationError::Unavailable, ] { diff --git a/crates/registry-breg/src/api/proposals.rs b/crates/registry-breg/src/api/proposals.rs index c560c9cabc..65fddb83c4 100644 --- a/crates/registry-breg/src/api/proposals.rs +++ b/crates/registry-breg/src/api/proposals.rs @@ -7,7 +7,7 @@ use super::*; mod answers; use crate::model::{ CompiledAction, CompiledActionExecution, CompiledActionRoute, CompiledProposalPermission, - CompiledRegistry, HttpMethod, ProposalOperation, + CompiledRegistry, HttpMethod, ProposalOperation, ProposalParty, }; use crate::postgres::{ProposalAuthority, ProposalAuthorityOperation, RowBoundaryContext}; pub(super) use answers::answer; @@ -283,8 +283,157 @@ pub(crate) fn authorize( selected: Option<&str>, operation: ProposalAuthorityOperation, proposal_id: Option, + parties: PartySelection, ) -> Option { - authorize_checked(registry, action, claims, selected, operation, proposal_id).ok() + authorize_checked( + registry, + action, + claims, + selected, + operation, + proposal_id, + parties, + ) + .ok() +} + +/// Which of a profile's Proposal entries may admit the caller. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) enum PartySelection { + /// Any entry that holds the operation: Start, and admission to a route + /// before any Proposal is read. The transaction still checks the party. + Any, + /// The entry bound to exactly this party, or to none. + Exact(Option), + /// The entry that governs the caller on one Proposal. An entry bound to + /// no party governs alone. Otherwise the owner entry governs a caller who + /// filed the Proposal, then the subject entry a caller who is its + /// subject; the governing entry alone decides the operation and every + /// projection. A caller who is neither is admitted by any entry holding + /// the operation and then refused as concealed. + Proposal { owner: bool, subject: bool }, +} + +/// The admission's human test: a verified person acting for no one else and +/// under no task grant. Only such a caller is ever matched as a subject. +pub(crate) fn acts_for_self(claims: &VerifiedRequestClaims) -> bool { + claims.actor_kind() == Some(registry_platform_oidc::ActorKind::Human) + && claims.actor_subject().is_none() + && claims.grant().is_none() +} + +pub(crate) fn select_proposal_grant<'a>( + proposal: &'a crate::model::CompiledProposalPolicy, + profile: &str, + operation: ProposalOperation, + parties: PartySelection, +) -> Option<&'a CompiledProposalPermission> { + let entries = proposal + .permissions + .iter() + .filter(|grant| grant.profile_id == profile) + .collect::>(); + let holds = |grant: &&&CompiledProposalPermission| grant.operations.contains(&operation); + match parties { + PartySelection::Any => entries.iter().find(holds).copied(), + PartySelection::Exact(party) => entries + .iter() + .filter(|grant| grant.party == party) + .find(holds) + .copied(), + PartySelection::Proposal { owner, subject } => { + match governing_entry(&entries, owner, subject) { + Some(grant) => holds(&&grant).then_some(grant), + None => entries.iter().find(holds).copied(), + } + } + } +} + +/// The entry of one profile that governs a caller on one Proposal: the entry +/// bound to no party, else the owner entry for its owner, else the subject +/// entry for its subject. +fn governing_entry<'a>( + entries: &[&'a CompiledProposalPermission], + owner: bool, + subject: bool, +) -> Option<&'a CompiledProposalPermission> { + let party = |party| { + entries + .iter() + .find(|grant| grant.party == Some(party)) + .copied() + }; + entries + .iter() + .find(|grant| grant.party.is_none()) + .copied() + .or_else(|| owner.then(|| party(ProposalParty::Owner)).flatten()) + .or_else(|| subject.then(|| party(ProposalParty::Subject)).flatten()) +} + +/// Whether the caller is the Proposal's subject and the subject entry that +/// governs them, in a profile they reach, does not hold `operation`. The +/// subject can already read the Proposal, so the refusal need not conceal it. +/// An owner's refusals stay concealed, as every other refusal after a +/// Proposal lookup is. +fn party_entry_lacks_operation( + action: &CompiledAction, + claims: &VerifiedRequestClaims, + selected: Option<&str>, + operation: ProposalAuthorityOperation, + parties: PartySelection, +) -> bool { + let ( + CompiledActionExecution::Proposal { proposal }, + ProposalAuthorityOperation::Lifecycle(operation), + PartySelection::Proposal { owner, subject }, + ) = (&action.execution, operation, parties) + else { + return false; + }; + let profiles = proposal + .permissions + .iter() + .map(|grant| grant.profile_id.as_str()) + .filter(|profile| selected.is_none_or(|selected| selected == *profile)) + .filter(|profile| claims.reaches_profile(profile)) + .collect::>(); + profiles.into_iter().any(|profile| { + let entries = proposal + .permissions + .iter() + .filter(|grant| grant.profile_id == profile) + .collect::>(); + governing_entry(&entries, owner, subject).is_some_and(|grant| { + grant.party == Some(ProposalParty::Subject) && !grant.operations.contains(&operation) + }) + }) +} + +/// Whether the subject entry still admits the caller to read the Proposal, +/// row boundaries and the transaction check included. A subject whose +/// target has left their reach is answered as a stranger is. +async fn subject_still_reads( + service: &HttpService, + mutations: &crate::postgres::PostgresRecordMutationService, + action: &CompiledAction, + claims: &VerifiedRequestClaims, + selected: Option<&str>, + id: Uuid, +) -> bool { + let Ok(reader) = authorize_checked( + &service.registry, + action, + claims, + selected, + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Get), + Some(id), + PartySelection::Exact(Some(ProposalParty::Subject)), + ) else { + return false; + }; + mutations.proposal_visible(id, &reader).await.is_ok() } #[derive(Clone, Debug, Eq, PartialEq)] @@ -303,6 +452,7 @@ pub(crate) fn authorize_checked( selected: Option<&str>, operation: ProposalAuthorityOperation, proposal_id: Option, + parties: PartySelection, ) -> Result { let CompiledActionExecution::Proposal { proposal } = &action.execution else { return Err(ProposalAdmissionError::Refused(FailedCheck::Operation)); @@ -315,6 +465,7 @@ pub(crate) fn authorize_checked( profile, operation, proposal_id, + parties, ) .map_err(ProposalAdmissionError::Refused); } @@ -367,8 +518,15 @@ pub(crate) fn authorize_checked( let mut default_refusal = None; let mut first_refusal = None; for &candidate in &candidates { - match authorize_checked_profile(registry, action, claims, candidate, operation, proposal_id) - { + match authorize_checked_profile( + registry, + action, + claims, + candidate, + operation, + proposal_id, + parties, + ) { Ok(authority) => admitted.push(authority), Err(check) => { if default_profile_id == Some(candidate) { @@ -434,6 +592,7 @@ fn authorize_checked_profile( selected: &str, operation: ProposalAuthorityOperation, proposal_id: Option, + parties: PartySelection, ) -> Result { if !claims.reaches_profile(selected) { return Err(FailedCheck::AccessProfile); @@ -461,7 +620,7 @@ fn authorize_checked_profile( { return Err(FailedCheck::TaskGrantMissing); } - let (profile, targets, task_source, profile_kind) = match operation { + let (profile, party, targets, task_source, profile_kind) = match operation { ProposalAuthorityOperation::Start => { let grant = action .permissions @@ -492,20 +651,18 @@ fn authorize_checked_profile( .ok_or(FailedCheck::RowBoundary)?; ( grant.profile_id.as_str(), + None, targets, grant.task_grant.as_ref(), grant.actor_kind, ) } ProposalAuthorityOperation::Lifecycle(operation) => { - let grant = proposal - .permissions - .iter() - .find(|grant| selected == grant.profile_id && grant.operations.contains(&operation)) + let grant = select_proposal_grant(proposal, selected, operation, parties) .ok_or(FailedCheck::AccessProfile)?; if standing_agent && operation == ProposalOperation::Edit - && grant.ownership != Some(crate::model::ProposalOwnership::Caller) + && grant.party != Some(crate::model::ProposalParty::Owner) { return Err(FailedCheck::Operation); } @@ -540,6 +697,7 @@ fn authorize_checked_profile( .ok_or(FailedCheck::RowBoundary)?; ( grant.profile_id.as_str(), + grant.party, targets, grant.task_grant.as_ref(), grant.actor_kind, @@ -552,6 +710,7 @@ fn authorize_checked_profile( operation, claims.principal().ok_or(FailedCheck::TokenClaims)?, profile, + party, claims.purpose(), targets, ) @@ -566,10 +725,8 @@ fn authorize_checked_profile( // any kind, acting for no one else and under no task grant. A delegated // actor, a standing or task-granted agent and a service never receive // them, whatever their grant says. - authority.receives_review_answers = claims.actor_kind() - == Some(registry_platform_oidc::ActorKind::Human) - && claims.actor_subject().is_none() - && claims.grant().is_none() + authority.person = acts_for_self(claims); + authority.receives_review_answers = acts_for_self(claims) && task_source.is_none() && matches!( profile_kind, @@ -706,12 +863,22 @@ pub(super) async fn admitted_http_refusal( method: HttpMethod, correlation: &RequestCorrelation, response: Response, +) -> Response { + admitted_http_refusal_with(mutations, authority, method, correlation, || response).await +} + +pub(super) async fn admitted_http_refusal_with( + mutations: &crate::postgres::PostgresRecordMutationService, + authority: &ProposalAuthority, + method: HttpMethod, + correlation: &RequestCorrelation, + response: impl FnOnce() -> Response, ) -> Response { match mutations .record_proposal_http_refusal(authority, method, correlation) .await { - Ok(()) => response, + Ok(()) => response(), Err(_) => unavailable(), } } @@ -726,6 +893,7 @@ async fn known_action_refusal( method: HttpMethod, correlation: &RequestCorrelation, check: FailedCheck, + known_party: bool, ) -> Response { let profile = selected.filter(|profile| match operation { ProposalAuthorityOperation::Start => action.permissions.iter().any(|grant| { @@ -763,8 +931,13 @@ async fn known_action_refusal( ) .await { + // A party of the Proposal already knows it exists, so its refusal + // names the profile; anyone else is answered as concealed. Ok(()) => match operation { ProposalAuthorityOperation::Start => profile_not_authorized(check), + ProposalAuthorityOperation::Lifecycle(_) if known_party => { + profile_not_authorized(check) + } ProposalAuthorityOperation::Lifecycle(_) => concealed(FailedCheck::Visibility), }, Err(_) => unavailable(), @@ -837,6 +1010,7 @@ async fn ensure_proposal_route_admitted( selected, ProposalAuthorityOperation::Lifecycle(operation), None, + PartySelection::Any, ) .and_then(|authority| { if operation == ProposalOperation::Rebase { @@ -847,6 +1021,7 @@ async fn ensure_proposal_route_admitted( selected, ProposalAuthorityOperation::Start, None, + PartySelection::Any, ) } else { Ok(authority) @@ -954,14 +1129,14 @@ pub(super) async fn authorize_target<'a>( .proposal_route_target(id) .await .map_err(proposal_target_problem)?; - let Some((action, owner)) = target.and_then(|(action_id, owner)| { + let Some((action, owner, subject)) = target.and_then(|(action_id, owner, subject)| { service .registry .actions() .actions .iter() .find(|action| action.id == action_id) - .map(|action| (action, owner)) + .map(|action| (action, owner, subject)) }) else { return Err(audited_proposal_route_refusal( service, @@ -976,6 +1151,7 @@ pub(super) async fn authorize_target<'a>( .await); }; let operation = ProposalAuthorityOperation::Lifecycle(operation); + let parties = mutations.party_selection(claims, &owner, subject.as_deref()); let authority = match authorize_checked( &service.registry, action, @@ -983,6 +1159,7 @@ pub(super) async fn authorize_target<'a>( selected, operation, Some(id), + parties, ) { Ok(authority) => authority, Err(error) => { @@ -999,6 +1176,8 @@ pub(super) async fn authorize_target<'a>( method, correlation, check, + party_entry_lacks_operation(action, claims, selected, operation, parties) + && subject_still_reads(service, mutations, action, claims, selected, id).await, ) .await); } @@ -1006,7 +1185,7 @@ pub(super) async fn authorize_target<'a>( // The task-context service is admitted by the exact accepted review // binding, independently of any caller-owned Get in the same grant. if operation != ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetTaskGrantContext) - && !mutations.proposal_owner_matches(&authority, &owner) + && !mutations.proposal_party_matches(&authority, &owner, subject.as_deref()) { return Err(admitted_http_refusal( mutations, @@ -1055,6 +1234,7 @@ pub(super) async fn start( selected.as_deref(), ProposalAuthorityOperation::Start, None, + PartySelection::Any, ) { Ok(authority) => authority, Err(ProposalAdmissionError::Ambiguous(profiles)) => { @@ -1070,6 +1250,7 @@ pub(super) async fn start( HttpMethod::Post, &correlation, check, + false, ) .await; } @@ -1174,6 +1355,9 @@ pub(super) async fn start( "", service.field_encryption.as_deref(), ), + Err(MutationError::MembershipPreconditionFailed) => { + membership_precondition_problem(&correlation) + } Err(error) => proposal_problem(error), } } @@ -1214,6 +1398,7 @@ pub(super) async fn get( .await { Ok((value, etag)) => json_response(value, Some(&etag)), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), Err(error) => proposal_target_problem(error), } @@ -1266,6 +1451,7 @@ pub(super) async fn submission( { Ok(Some(value)) => json_response(value, None), Ok(None) => fixed_problem(ProblemCode::ProposalSubmissionExpired), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), Err(error) => proposal_target_problem(error), } @@ -1323,6 +1509,7 @@ pub(super) async fn transition( selected.as_deref(), ProposalAuthorityOperation::Start, None, + PartySelection::Any, ) { Ok(authority) => Some(authority), Err(_) => { @@ -1521,6 +1708,9 @@ pub(super) async fn transition( ) .await } + Err(MutationError::MembershipPreconditionFailed) => { + membership_precondition_problem(&correlation) + } Err(error) => proposal_target_problem(error), } } @@ -1562,6 +1752,7 @@ async fn guard_failure_response( &failure.record_id.to_string(), &BTreeSet::from([guard.field.clone()]), boundaries, + authority.target_membership(&guard.entity_id), correlation, ) .await; @@ -1816,6 +2007,7 @@ pub(super) async fn task_grant_context( }; let granted = proposal.permissions.iter().find(|permission| { permission.profile_id == authority.common.access_profile() + && permission.party == authority.party && permission.operations.contains(&operation) }); if !granted.is_some_and(|permission| { @@ -1868,6 +2060,7 @@ pub(super) async fn task_grant_context( ); response } + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), Err(error) => proposal_target_problem(error), } @@ -1949,6 +2142,7 @@ async fn review_read( .await { Ok((value, etag)) => json_response(value, etag.as_deref()), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), Err(error) => proposal_target_problem(error), } @@ -2077,8 +2271,30 @@ pub(super) async fn list( selected.as_deref(), ProposalAuthorityOperation::Lifecycle(ProposalOperation::List), None, + PartySelection::Any, ) { - Ok(authority) => authorities.push(authority), + Ok(authority) => { + // A profile's other party entry lists the Proposals it + // governs, under its own projection. + if let Some(party) = authority.party { + let other = match party { + ProposalParty::Owner => ProposalParty::Subject, + ProposalParty::Subject => ProposalParty::Owner, + }; + if let Ok(sibling) = authorize_checked( + &service.registry, + action, + &claims, + Some(authority.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(ProposalOperation::List), + None, + PartySelection::Exact(Some(other)), + ) { + authorities.push(sibling); + } + } + authorities.push(authority); + } Err(ProposalAdmissionError::Ambiguous(ids)) => { ambiguous_profiles.extend(ids); } @@ -2236,3 +2452,46 @@ fn parse_proposal_list_query(raw: Option<&str>) -> Result VerifiedRequestClaims { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + "subject-canary", + BTreeSet::new(), + None, + BTreeMap::new(), + registry_platform_oidc::ActorKind::Human, + ) + .unwrap() + } + + #[test] + fn only_a_person_acting_for_themselves_passes_the_human_test() { + assert!(acts_for_self(&person())); + // A delegated token carries the subject's principal for someone + // else: an agent or application acting in their name. + let delegated = person() + .with_contextual_authority( + Some(registry_platform_oidc::ActorKind::Human), + None, + Some("delegated-actor".to_owned()), + None, + BTreeMap::new(), + ) + .unwrap(); + assert!(!acts_for_self(&delegated)); + for kind in [ + registry_platform_oidc::ActorKind::Agent, + registry_platform_oidc::ActorKind::Service, + ] { + let claims = person() + .with_contextual_authority(Some(kind), None, None, None, BTreeMap::new()) + .unwrap(); + assert!(!acts_for_self(&claims), "{kind:?}"); + } + } +} diff --git a/crates/registry-breg/src/api/proposals/answers.rs b/crates/registry-breg/src/api/proposals/answers.rs index dbe61b6ddc..d0833f4533 100644 --- a/crates/registry-breg/src/api/proposals/answers.rs +++ b/crates/registry-breg/src/api/proposals/answers.rs @@ -42,13 +42,20 @@ pub(in crate::api) async fn answer( }; if let Err(error) = mutations.proposal_visible(id, &authority).await { return match error { - MutationError::PreconditionFailed | MutationError::AuthorizationRefused(_) => { + MutationError::PreconditionFailed + | MutationError::AuthorizationRefused(_) + | MutationError::MembershipPreconditionFailed => { + let check = if matches!(error, MutationError::MembershipPreconditionFailed) { + FailedCheck::Membership + } else { + FailedCheck::Visibility + }; admitted_http_refusal( mutations, &authority, HttpMethod::Post, &correlation, - concealed(FailedCheck::Visibility), + concealed(check), ) .await } @@ -119,6 +126,7 @@ pub(in crate::api) async fn answer( "", service.field_encryption.as_deref(), ), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), Err(error) => proposal_target_problem(error), } } diff --git a/crates/registry-breg/src/api/tests/immediate_action_tests.rs b/crates/registry-breg/src/api/tests/immediate_action_tests.rs index 15d4d7ed35..16134b50bd 100644 --- a/crates/registry-breg/src/api/tests/immediate_action_tests.rs +++ b/crates/registry-breg/src/api/tests/immediate_action_tests.rs @@ -297,7 +297,7 @@ async fn proposal_task_scopes_and_standing_agent_draft_and_context_permissions_a let mut task_profile = json!({"id":"task-proposer","principalClaim":"registry_principal","actorKind":"agent","requesterClients":["agent-client"], "requiredScopes":["case.rename"],"requiredPurposes":["case-management"],"taskGrant":{"sourceIssuer":"https://casework.example"}, "permissions":{"actions":[{"action":"propose-rename","operations":["start"],"targets":[{"recordType":"case","rowBoundaries":[{"field":"region","claim":"grantRegion","operator":"equals"}]}]}], - "proposals":[{"action":"propose-rename","operations":["get","list","edit","submit","revise","cancel","apply","rebase","retry","get-review-status"],"ownership":"caller", + "proposals":[{"action":"propose-rename","operations":["get","list","edit","submit","revise","cancel","apply","rebase","retry","get-review-status"],"party":"owner", "readableInputs":["case-ref","case-label"], "targets":[{"recordType":"case","rowBoundaries":[{"field":"region","claim":"grantRegion","operator":"equals"}]}]}]}}); project @@ -361,7 +361,15 @@ async fn proposal_task_scopes_and_standing_agent_draft_and_context_permissions_a .await .unwrap(); let admit = |claims: &VerifiedRequestClaims, profile: &str, operation, id| { - super::super::proposals::authorize(®istry, action, claims, Some(profile), operation, id) + super::super::proposals::authorize( + ®istry, + action, + claims, + Some(profile), + operation, + id, + super::super::proposals::PartySelection::Any, + ) }; assert!(admit( &start, @@ -572,6 +580,7 @@ fn delegated_standing_agent_reads_only_its_bounded_review_context() { Some("casework-source-reader"), ProposalAuthorityOperation::Lifecycle(operation), Some(Uuid::parse_str("00000000-0000-4000-8000-000000000001").unwrap()), + super::super::proposals::PartySelection::Any, ) }; let authority = admit(&delegated, ProposalOperation::GetReviewContext) @@ -1390,7 +1399,7 @@ async fn proposal_metadata_roundtrips_exact_profile_inventory_and_document_requi let proposals = if operations.as_array().unwrap().is_empty() { json!([]) } else { - json!([{"action":action,"operations":operations,"ownership":"caller","targets":targets, + json!([{"action":action,"operations":operations,"party":"owner","targets":targets, "readableInputs":readable,"readableAttachments":slots}]) }; project.access_profiles.push(serde_json::from_value(json!({ @@ -1499,6 +1508,143 @@ async fn proposal_metadata_roundtrips_exact_profile_inventory_and_document_requi ); } +/// Each party entry is its own inventory entry, every entry names the inputs +/// it may write (#2720), and a reader's Action description keeps the effects +/// on Record types it can see (#2719). +#[tokio::test] +async fn proposal_metadata_serves_party_entries_writable_inputs_and_reader_effects() { + use registry_breg_client::BRegMetadata; + use tower::ServiceExt; + + let source = json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + "project":{"id":"party-metadata","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://party-metadata.example.test"}, + "datasets":{"licences": {}}, + "recordTypes":{ + "licence": {"route":"licences","primaryDataset":"licences","mutationMode":"mutable","classification":"internal", + "fields":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}]}, + "ledger": {"route":"ledger","primaryDataset":"licences","mutationMode":"mutable","classification":"internal", + "fields":[{"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}]}}, + "actions":{ + "apply-for-licence": {"execution":{"mode":"proposal","proposal":{ + "review":{"type":"none"},"application":{"mode":"manual"},"retention":{"mode":"retain"}, + "subject":{"input":"holder"}}}, + "inputs":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}], + "plan":{"type":"fixed","effects":[ + {"id":"issued","target":{"recordType":"licence"},"operation":"create", + "set":{"holder":{"fromInput":"holder"},"statement":{"fromInput":"statement"}}}, + {"id":"logged","target":{"recordType":"ledger"},"operation":"create", + "set":{"holder":{"fromInput":"holder"}}}]}}}, + "accessProfiles":{ + "citizen": {"principalClaim":"registry_principal","requiredScopes":["licence:self"],"actorKind":"human", + "permissions":{ + "actions":[{"action":"apply-for-licence","operations":["start"],"targets":[ + {"recordType":"licence","rowBoundaries":"unrestricted"},{"recordType":"ledger","rowBoundaries":"unrestricted"}]}], + "proposals":[ + {"action":"apply-for-licence","party":"owner","operations":["get","list","edit","submit","cancel"], + "readableInputs":["holder","statement"],"writableInputs":["statement"],"targets":[ + {"recordType":"licence","rowBoundaries":"unrestricted"},{"recordType":"ledger","rowBoundaries":"unrestricted"}]}, + {"action":"apply-for-licence","party":"subject","operations":["get","list","cancel"], + "readableInputs":["holder"],"targets":[ + {"recordType":"licence","rowBoundaries":"unrestricted"},{"recordType":"ledger","rowBoundaries":"unrestricted"}]}]}}, + "desk": {"principalClaim":"registry_principal","requiredScopes":["licence:desk"],"actorKind":"human", + "permissions":{"proposals":[ + {"action":"apply-for-licence","operations":["get","list","edit","submit"], + "submitsFor":"anyone","readableInputs":["holder","statement"],"targets":[ + {"recordType":"licence","rowBoundaries":"unrestricted"},{"recordType":"ledger","rowBoundaries":"unrestricted"}]}]}}, + "reader": {"principalClaim":"registry_principal","requiredScopes":["licence:read"],"actorKind":"human", + "permissions":{ + "records":[{"recordType":"licence","operations":["get"],"readableFields":["holder"],"rowBoundaries":"unrestricted"}], + "proposals":[{"action":"apply-for-licence","operations":["get"],"readableInputs":["holder"],"targets":[ + {"recordType":"licence","rowBoundaries":"unrestricted"},{"recordType":"ledger","rowBoundaries":"unrestricted"}]}]}}} + }); + let project = crate::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()) + .expect("party metadata project parses"); + let registry = Arc::new( + compile_project(&project, &[], CompileProfile::Authoring).expect("party metadata compiles"), + ); + let service = Arc::new(service_for(registry, true)); + let document = |scope: &'static str, profile: &'static str| { + let service = service.clone(); + async move { + let mut request = axum::http::Request::builder() + .uri(format!("/v1/registry?accessProfile={profile}")) + .body(Body::empty()) + .unwrap(); + request.extensions_mut().insert( + VerifiedRequestClaims::authenticated_with_actor_kind( + "registry_principal", + "person-canary", + BTreeSet::from([scope.to_owned()]), + None, + BTreeMap::new(), + registry_platform_oidc::ActorKind::Human, + ) + .unwrap(), + ); + let response = super::super::router(service) + .oneshot(request) + .await + .unwrap(); + response_json(response).await + } + }; + + let citizen = document("licence:self", "citizen").await; + let entries = citizen["proposals"]["actions"].as_array().unwrap(); + assert_eq!(entries.len(), 2, "{citizen}"); + let owner = entries + .iter() + .find(|entry| entry["party"] == "owner") + .unwrap(); + let subject = entries + .iter() + .find(|entry| entry["party"] == "subject") + .unwrap(); + assert_eq!(owner["readableInputs"], json!(["holder", "statement"])); + assert_eq!(owner["writableInputs"], json!(["statement"])); + assert_eq!(subject["readableInputs"], json!(["holder"])); + assert_eq!(subject["writableInputs"], json!([])); + let action = &citizen["actions"][0]; + assert_eq!(action["subject"], json!({"input":"holder"})); + assert_eq!(action["writableInputs"], json!(["statement"])); + let metadata = BRegMetadata::from_slice(&serde_json::to_vec(&citizen).unwrap()).unwrap(); + let inventory = metadata.proposal_actions(); + assert_eq!(inventory.len(), 2); + let parsed_subject = inventory + .iter() + .find(|entry| entry.party() == Some(registry_breg_client::BRegProposalPartyRole::Subject)) + .unwrap(); + assert_eq!(parsed_subject.writable_inputs(), Some(&[][..])); + assert_eq!(metadata.actions()[0].subject_input(), Some("holder")); + + // A grant without the list writes every declared input. + let desk = document("licence:desk", "desk").await; + let entry = &desk["proposals"]["actions"][0]; + assert!(entry.get("party").is_none()); + assert_eq!(entry["writableInputs"], json!(["holder", "statement"])); + + // A reader writes nothing and keeps the effects on Record types it reads. + let reader = document("licence:read", "reader").await; + assert_eq!( + reader["proposals"]["actions"][0]["writableInputs"], + json!([]) + ); + let action = &reader["actions"][0]; + assert_eq!(action["routes"], json!({})); + assert_eq!( + action["resultEffects"], + json!([{"effect":"issued","recordType":"licence","operation":"create"}]), + "{action}" + ); + assert_eq!(action["writableInputs"], json!([])); + BRegMetadata::from_slice(&serde_json::to_vec(&reader).unwrap()).unwrap(); +} + async fn response_json(response: Response) -> Value { assert_eq!(response.status(), StatusCode::OK); let bytes = to_bytes(response.into_body(), 1024 * 1024).await.unwrap(); @@ -1995,6 +2141,7 @@ async fn task_granted_proposal_start_binds_the_grant_to_the_request_principal_an Some("task-proposer"), ProposalAuthorityOperation::Start, None, + super::super::proposals::PartySelection::Any, ) }; assert!(admit(&matched).is_some_and(|authority| authority.task_grant.is_some())); @@ -2030,6 +2177,7 @@ async fn task_review_record_reads_bind_the_grant_to_the_request_principal_and_pu Some("task-reviewer"), ProposalAuthorityOperation::Lifecycle(operation), Some(BOUND_GRANT_PROPOSAL_ID), + super::super::proposals::PartySelection::Any, ) }; let authority = admit(&matched).expect("the matching grant opens the review context"); diff --git a/crates/registry-breg/src/artifacts.rs b/crates/registry-breg/src/artifacts.rs index 8c3c41a63b..a83403ee3d 100644 --- a/crates/registry-breg/src/artifacts.rs +++ b/crates/registry-breg/src/artifacts.rs @@ -1459,6 +1459,19 @@ pub(crate) fn public_action_metadata_entry( } }); if let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution { + if let Some(subject) = &proposal.subject { + metadata["subject"] = json!({"input": subject.input}); + } + // The inputs the selected profile's draft may set, from the entry + // that governs a draft it starts. + if let Some(profile) = selected_profile { + if let Some(grant) = proposal.permissions.iter().find(|grant| { + grant.profile_id == profile + && matches!(grant.party, None | Some(crate::model::ProposalParty::Owner)) + }) { + metadata["writableInputs"] = json!(proposal_writable_inputs(action, grant)); + } + } // Callers learn only whether a request is reviewed and whether an // accepted request is applied automatically. The review authority, // source, policy selection and attempt limit stay in the build-time @@ -1501,6 +1514,34 @@ pub(crate) fn public_action_metadata_entry( metadata } +/// The inputs a Proposal grant may set: its `writableInputs`, every declared +/// input when it names none, and none when it can neither start the Action +/// nor Edit, Revise or Rebase. +pub(crate) fn proposal_writable_inputs( + action: &CompiledAction, + grant: &crate::model::CompiledProposalPermission, +) -> Vec { + use crate::model::ProposalOperation; + let starts = grant.party != Some(crate::model::ProposalParty::Subject) + && action.permissions.iter().any(|permission| { + permission.profile_id == grant.profile_id + && permission.operations.contains(&Operation::Start) + }); + let edits = grant.operations.iter().any(|operation| { + matches!( + operation, + ProposalOperation::Edit | ProposalOperation::Revise | ProposalOperation::Rebase + ) + }); + if !(starts || edits) { + return Vec::new(); + } + match &grant.writable_inputs { + Some(writable) => writable.iter().cloned().collect(), + None => action.inputs.iter().map(|input| input.id.clone()).collect(), + } +} + /// Shared schema for the distinct Proposal resource, never a Record envelope. pub fn proposal_apply_input_schema() -> Value { json!({"type":"object","additionalProperties":false, @@ -1525,6 +1566,7 @@ pub fn proposal_schema() -> Value { "application":proposal_application_schema(), "applicationStatus":proposal_application_status_schema(), "turn":{"enum":["party","official","nobody"]}, + "partyRole":{"enum":["owner","subject"]}, "decision":proposal_decision_schema(), "asks":proposal_asks_schema(false), "handoffRefusal":proposal_handoff_refusal_schema(), @@ -4486,7 +4528,8 @@ fn operation_may_refuse_write(spec: OpenApiOperationSpec<'_>) -> bool { .entity .access_profiles .get(profile_id) - .is_some_and(|profile| !profile.row_boundaries.is_empty()); + .is_some_and(|profile| !profile.row_boundaries.is_empty()) + || !crate::membership::boundaries(spec.entity, profile_id).is_empty(); let disclosure = crate::disclosure::plan(spec.entity, profile_id); let disclosure_refuses = if spec.route.operation == Operation::Create { disclosure @@ -5180,7 +5223,7 @@ fn query_kind_name(kind: CompiledQueryKind) -> &'static str { } } -fn operation_name(operation: Operation) -> &'static str { +pub(crate) fn operation_name(operation: Operation) -> &'static str { match operation { Operation::Create => "create", Operation::Get => "get", diff --git a/crates/registry-breg/src/auth.rs b/crates/registry-breg/src/auth.rs index 2ad4ae9b66..ec3827682a 100644 --- a/crates/registry-breg/src/auth.rs +++ b/crates/registry-breg/src/auth.rs @@ -381,6 +381,7 @@ pub(crate) fn compiled_profile_facts( .row_boundaries .iter() .any(|boundary| claim_is_principal(&boundary.claim, principal)) + || !target.membership_boundaries.is_empty() }); entry.has_subject_row_rule |= subject_row; entry.reads_principal |= subject_row; @@ -393,12 +394,13 @@ pub(crate) fn compiled_profile_facts( for grant in &proposal.permissions { let entry = facts.entry(grant.profile_id.clone()).or_default(); let principal = grant.principal_claim.as_deref(); - let subject_row = grant.ownership == Some(crate::model::ProposalOwnership::Caller) + let subject_row = grant.party.is_some() || grant.targets.iter().any(|target| { target .row_boundaries .iter() .any(|boundary| claim_is_principal(&boundary.claim, principal)) + || !target.membership_boundaries.is_empty() }); entry.has_subject_row_rule |= subject_row; entry.reads_principal |= subject_row; diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index d01c7cad6b..aa463217e3 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -340,7 +340,13 @@ pub fn compile_project_with_assets( &mut diagnostics, ); crate::access::validate_access_requirements(&sources, &mut diagnostics); - crate::membership::validate(&sources, &mut diagnostics); + crate::membership::validate(project, &action_sources, &sources, &mut diagnostics); + crate::proposal_subject::validate_field_writes( + project, + &action_sources, + &sources, + &mut diagnostics, + ); crate::consent::validate(project, &sources, &mut diagnostics); crate::event_record::validate(&sources, &mut diagnostics); findings.extend(crate::access::access_findings(&sources)); @@ -378,6 +384,13 @@ pub fn compile_project_with_assets( "relationship compilation", ) })?; + crate::membership::compile(&mut entities).map_err(|errors| { + stopped_compile_failure( + CompileFailure::from_errors(errors), + &findings, + "membership compilation", + ) + })?; let statistical_datasets = statistics::compile(project, &entities).map_err(|errors| { stopped_compile_failure( CompileFailure::from_errors(errors), @@ -406,7 +419,6 @@ pub fn compile_project_with_assets( &entities, )); crate::external_views::mark_link_fields(&external_views, &mut entities, &mut physical_names); - crate::membership::compile(&mut entities); let recipients = crate::consent::compile(project, &sources, &mut entities); crate::event_record::compile(&sources, &mut entities); let timer_actions = sources @@ -4218,7 +4230,12 @@ pub(crate) fn expand_project_access( required_filters: grant.required_filters.clone(), spatial_queries: grant.spatial_queries.clone(), row_boundaries: grant.row_boundaries.clone(), - membership_boundaries: grant.membership_boundaries.clone(), + membership_boundaries: grant + .membership_row_boundaries + .iter() + .cloned() + .map(crate::contract::MembershipBoundarySource::Declared) + .collect(), require_consent: grant.require_consent.clone(), lookups: grant.lookups.clone(), read_paths: grant.read_paths.clone(), @@ -8384,6 +8401,7 @@ fn compile_entities( batch: source.batch.clone(), classification: source.classification, access_requirements: source.access_requirements.clone(), + membership: source.membership.clone(), access_log: source.access_log.clone(), disclosure_conditions: disclosure::compile_conditions(source), geojson: source diff --git a/crates/registry-breg/src/compiler/disclosure/reach.rs b/crates/registry-breg/src/compiler/disclosure/reach.rs index 34346cdebf..7aeb530aaf 100644 --- a/crates/registry-breg/src/compiler/disclosure/reach.rs +++ b/crates/registry-breg/src/compiler/disclosure/reach.rs @@ -12,8 +12,7 @@ use std::collections::{BTreeMap, BTreeSet}; use crate::contract::{ AccessProfileSource, BoundaryOperator, DerivedSource, DisclosureConditionSource, - DisclosureWithholdSource, EntitySource, Operation, RowBoundarySource, TimerPredicateSource, - UniqueSet, + DisclosureWithholdSource, EntitySource, Operation, TimerPredicateSource, UniqueSet, }; use crate::diagnostics::Diagnostic; use crate::external_views::CompiledExternalViews; @@ -139,7 +138,7 @@ pub(super) fn validate_boundaries( if profile .membership_boundaries .iter() - .any(|boundary| boundary.field == *field) + .any(|boundary| boundary.field() == field) { refuse( errors, @@ -599,12 +598,12 @@ fn reading_grant<'a>( .filter(|grant| crate::generated_ddl::grant_reads_rows(grant.operations.as_set())) } -fn backticked<'a>(values: impl IntoIterator) -> String { +fn backticked(values: impl IntoIterator + Ord>) -> String { values .into_iter() .collect::>() .into_iter() - .map(|value| format!("`{value}`")) + .map(|value| format!("`{}`", value.as_ref())) .collect::>() .join(", ") } @@ -643,7 +642,7 @@ fn withheld_source_rows( }; if !grant.membership_boundaries.is_empty() { found.push(( - source_path("membershipBoundaries"), + source_path("rowBoundaries"), format!( "{reads}, and its grant on `{source}` requires a membership through {through}, so its derived values leave out the `{source}` rows the caller holds no such membership for", source = source.id, @@ -651,7 +650,7 @@ fn withheld_source_rows( grant .membership_boundaries .iter() - .map(|boundary| &boundary.membership_entity) + .map(crate::contract::MembershipBoundarySource::record_type) ), ), )); @@ -689,7 +688,7 @@ fn unlinked_source_rows( "{reads}, and a subquery that refers to no column of the row reads every `{source}` row the profile sees, which its grant on `{source}` bounds by {boundaries}, so its derived values cover only those rows, not every `{source}` row", reads = reads_derived_from(owner, source, reader), source = source.id, - boundaries = describe_row_boundaries(&grant.row_boundaries), + boundaries = describe_row_boundaries(grant), ), )) } @@ -746,7 +745,7 @@ fn derived_source_refusal( format!( "{reads}, but the profile cannot read `{source}` rows, {missed}: {rewrite}grant it `get` on `{source}`, with only {readable} readable and the row boundaries {boundaries} of its grant on `{request_entity}`", source = source.id, - boundaries = describe_row_boundaries(&request.row_boundaries), + boundaries = describe_row_boundaries(request), readable = readable, rewrite = rewrite, ), @@ -784,10 +783,15 @@ fn derived_source_refusal( code, source_path("rowBoundaries"), format!( - "{reads}, but its grant on `{source}` is bounded by {source_rows} and its grant on `{request_entity}` by {request_rows}, {missed}: {rewrite}bound the grant on `{source}` by {request_rows} too, on fields that hold the same values", + "{reads}, but its grant on `{source}` is bounded by {source_rows} and its grant on `{request_entity}` by {request_rows}, {missed}: {rewrite}{fix}", + fix = if request.membership_boundaries.is_empty() { + format!("bound the grant on `{}` by {request_rows} too, on fields that hold the same values", source.id, request_rows = describe_row_boundaries(request)) + } else { + "align the claim boundaries on fields that hold the same values while retaining the required membership restrictions, or do not grant the derived field".to_owned() + }, source = source.id, - source_rows = describe_row_boundaries(&grant.row_boundaries), - request_rows = describe_row_boundaries(&request.row_boundaries), + source_rows = describe_row_boundaries(grant), + request_rows = describe_row_boundaries(request), rewrite = rewrite, ), )); @@ -828,11 +832,12 @@ fn derived_source_refusal( None } -fn describe_row_boundaries(boundaries: &[RowBoundarySource]) -> String { - if boundaries.is_empty() { +fn describe_row_boundaries(grant: &crate::contract::AccessProfileSource) -> String { + if grant.row_boundaries.is_empty() && grant.membership_boundaries.is_empty() { return "`unrestricted`".to_owned(); } - boundaries + grant + .row_boundaries .iter() .map(|boundary| { let operator = match boundary.operator { @@ -841,6 +846,13 @@ fn describe_row_boundaries(boundaries: &[RowBoundarySource]) -> String { }; format!("`{}` {operator} claim `{}`", boundary.field, boundary.claim) }) + .chain(grant.membership_boundaries.iter().map(|boundary| { + format!( + "`{}` requires membership through `{}`", + boundary.field(), + boundary.record_type() + ) + })) .collect::>() .join(" and ") } diff --git a/crates/registry-breg/src/compiler/statistics.rs b/crates/registry-breg/src/compiler/statistics.rs index c885ffb1e3..dcf83862a5 100644 --- a/crates/registry-breg/src/compiler/statistics.rs +++ b/crates/registry-breg/src/compiler/statistics.rs @@ -1596,17 +1596,16 @@ fn validate_publisher_independence( ), )); } - let violation = if !grant.row_boundaries.is_empty() { - Some("rowBoundaries") - } else if !grant.membership_boundaries.is_empty() { - Some("membershipBoundaries") - } else if !grant.required_purposes.is_empty() { - Some("requiredPurposes") - } else if !grant.require_consent.is_empty() { - Some("requireConsent") - } else { - None - }; + let violation = + if !grant.row_boundaries.is_empty() || !grant.membership_boundaries.is_empty() { + Some("rowBoundaries") + } else if !grant.required_purposes.is_empty() { + Some("requiredPurposes") + } else if !grant.require_consent.is_empty() { + Some("requireConsent") + } else { + None + }; if let Some(member) = violation { errors.push(error( &holder.independence_code("caller-dependent"), diff --git a/crates/registry-breg/src/contract.rs b/crates/registry-breg/src/contract.rs index 9cef24b166..7624767d9f 100644 --- a/crates/registry-breg/src/contract.rs +++ b/crates/registry-breg/src/contract.rs @@ -635,6 +635,9 @@ pub struct ProposalPolicySource { pub additions: Option, #[serde(default)] pub review_context: Option, + /// The person the Proposal is about, frozen at its first Submit. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub subject: Option, /// Post-commit observers of the fixed, value-free Proposal lifecycle event. #[serde( default, @@ -878,8 +881,29 @@ impl ProposalOperation { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -pub enum ProposalOwnership { - Caller, +pub enum ProposalParty { + /// The caller who filed the Proposal. + Owner, + /// The person the Proposal is about, frozen at its first Submit. + Subject, +} +/// Whom a Submit may name as the Proposal's subject. Absent means only the +/// submitter themselves. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum ProposalSubmitsFor { + Anyone, +} +/// Where a Proposal's subject comes from: an Action input, or a field of the +/// Record a reference input names. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ProposalSubjectSource { + pub input: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub field: Option, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -891,8 +915,12 @@ pub struct ProposalPermissionSource { #[serde(default, skip_serializing_if = "is_false")] pub readable_review_progress: bool, pub operations: UniqueSet, - #[serde(default)] - pub ownership: Option, + /// Binds the grant to one party of each Proposal. Absent grants are not + /// bound to a party, as a reviewer's or officer's are. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub party: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub submits_for: Option, #[serde(default)] pub targets: Vec, #[serde(default)] @@ -908,21 +936,24 @@ pub struct ProposalPermissionSource { pub writable_inputs: Option>, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[cfg_attr( + feature = "schema", + schemars(with = "sentinel::AuthoredTargetPermission") +)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -#[serde(deny_unknown_fields, rename_all = "camelCase")] +#[serde( + try_from = "sentinel::AuthoredTargetPermission", + into = "sentinel::AuthoredTargetPermission" +)] pub struct ProposalTargetPermissionSource { pub record_type: String, - #[serde( - deserialize_with = "sentinel::row_boundaries", - serialize_with = "sentinel::serialize_row_boundaries" - )] - #[cfg_attr(feature = "schema", schemars(with = "sentinel::RowBoundaries"))] pub row_boundaries: Vec, + pub membership_row_boundaries: Vec, } /// A reusable list of row boundaries, written under `rowBoundarySets`. #[derive(Clone, Debug, Eq, PartialEq)] -pub struct RowBoundarySetSource(pub Vec); +pub struct RowBoundarySetSource(Vec); impl<'de> Deserialize<'de> for RowBoundarySetSource { fn deserialize>(deserializer: D) -> Result { @@ -941,7 +972,7 @@ impl schemars::JsonSchema for RowBoundarySetSource { } fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { - generator.subschema_for::, sentinel::RowBoundarySetRows>>() + generator.subschema_for::, sentinel::RowBoundarySetRows>>() } } @@ -2117,6 +2148,8 @@ pub struct EntitySource { /// Write-once file slots filled by immediate Action create effects. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub attachments: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub membership: Option, /// Mandatory request-access requirements checked against every profile, including module contributions. #[serde( default, @@ -5462,7 +5495,7 @@ pub struct AccessProfileSource { pub sortable_fields: UniqueSet, #[serde(default, skip_serializing_if = "Option::is_none")] pub spatial_queries: Option, - /// Compiled row reach; an empty array permits every row, as the authored `unrestricted` does. + /// Compiled claim boundaries. An empty array imposes no claim restriction. pub row_boundaries: Vec, /// Current active membership required for each stored reference key. #[serde(default, skip_serializing_if = "Vec::is_empty")] @@ -5551,13 +5584,69 @@ pub struct RowBoundarySource { pub operator: BoundaryOperator, } -/// A one-hop current membership requirement, combined with every other row boundary. -/// The root field and membership key must reference the same entity. The active -/// field is Boolean, and principalField matches the profile's verified principal. +/// Stored fields that establish a current membership fact. #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "camelCase")] -pub struct MembershipBoundarySource { +pub struct MembershipDeclarationSource { + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + pub key: String, + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + pub principal: String, + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + pub active: String, +} + +/// A membership check on one field of the protected Record type. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct MembershipRowBoundarySource { + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + pub field: String, + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + pub membership: String, +} + +/// Membership entries in the normalized profile, before and after expansion. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[cfg_attr( + feature = "schema", + schemars(with = "ExpandedMembershipBoundarySource") +)] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum MembershipBoundarySource { + Expanded(ExpandedMembershipBoundarySource), + Declared(MembershipRowBoundarySource), +} + +impl Serialize for MembershipBoundarySource { + fn serialize(&self, serializer: S) -> Result { + match self { + Self::Expanded(boundary) => boundary.serialize(serializer), + Self::Declared(_) => Err(serde::ser::Error::custom( + "a compiled access profile requires expanded membership entries", + )), + } + } +} + +impl<'de> Deserialize<'de> for MembershipBoundarySource { + fn deserialize>(deserializer: D) -> Result { + ExpandedMembershipBoundarySource::deserialize(deserializer).map(Self::Expanded) + } +} + +/// Logical membership fields carried in the compiled profile and inventory. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ExpandedMembershipBoundarySource { pub field: String, #[serde(rename = "membershipRecordType")] pub membership_entity: String, @@ -5566,6 +5655,32 @@ pub struct MembershipBoundarySource { pub active_field: String, } +impl MembershipBoundarySource { + pub(crate) fn record_type(&self) -> &str { + match self { + Self::Expanded(boundary) => &boundary.membership_entity, + Self::Declared(boundary) => &boundary.membership, + } + } + + pub(crate) fn field(&self) -> &str { + match self { + Self::Expanded(boundary) => &boundary.field, + Self::Declared(boundary) => &boundary.field, + } + } + + pub(crate) fn entry(&self) -> MembershipRowBoundarySource { + match self { + Self::Expanded(boundary) => MembershipRowBoundarySource { + field: boundary.field.clone(), + membership: boundary.membership_entity.clone(), + }, + Self::Declared(boundary) => boundary.clone(), + } + } +} + /// Compile-time requirements, not grants. Profiles must explicitly satisfy them. /// /// This is the form the compiler holds and compiled artifacts carry, where an @@ -6031,12 +6146,9 @@ pub struct EntityPermissionSource { pub sortable_fields: UniqueSet, #[serde(skip_serializing_if = "Option::is_none")] pub spatial_queries: Option, - /// Row reach, written as `unrestricted` when it holds no boundary. - #[serde(serialize_with = "sentinel::serialize_row_boundaries")] + /// Row reach, written as unrestricted when both lists are empty. pub row_boundaries: Vec, - /// Current active membership required for each stored reference key. - #[serde(skip_serializing_if = "Vec::is_empty")] - pub membership_boundaries: Vec, + pub membership_row_boundaries: Vec, /// Current subject-issued consent required for each row, ANDed. #[serde(skip_serializing_if = "Vec::is_empty")] pub require_consent: Vec, @@ -6126,18 +6238,19 @@ pub struct ReadPathPermissionSource> { } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[cfg_attr( + feature = "schema", + schemars(with = "sentinel::AuthoredTargetPermission") +)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -#[serde(deny_unknown_fields, rename_all = "camelCase")] +#[serde( + try_from = "sentinel::AuthoredTargetPermission", + into = "sentinel::AuthoredTargetPermission" +)] pub struct ActionTargetPermissionSource { - #[serde(rename = "recordType")] pub entity: String, - /// Row reach: `unrestricted`, or a list of at least one row boundary. - #[serde( - deserialize_with = "sentinel::row_boundaries", - serialize_with = "sentinel::serialize_row_boundaries" - )] - #[cfg_attr(feature = "schema", schemars(with = "sentinel::RowBoundaries"))] pub row_boundaries: Vec, + pub membership_row_boundaries: Vec, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] @@ -6227,7 +6340,7 @@ const HANDLER_TYPE_REPLACEMENT: &str = const CHANGE_REQUEST_REPLACEMENT: &str = "Declare one Action with `execution.mode: proposal` and its `execution.proposal` review, application and retention policy. Proposal state is owned by the Action, not a Record type. See https://docs.registrystack.org/configure/breg-proposals/."; const CHANGE_CONTROL_REPLACEMENT: &str = "Replace `changeControl.requiredFor` with `mutationPolicy`, setting each governed operation (`create`, `patch`, or `tombstone`) to `proposal-required`. Declare Actions with `execution.mode: proposal` for those writes; keep their review and application policy under `execution.proposal`. See https://docs.registrystack.org/configure/breg-proposals/."; -const REQUEST_VISIBILITY_REPLACEMENT: &str = "Move Proposal authority into the profile's `permissions.proposals` entry for the Action. Use `ownership: caller` for owner-only access, and explicitly retain the required `operations` and target `rowBoundaries`. See https://docs.registrystack.org/configure/breg-proposals/."; +const REQUEST_VISIBILITY_REPLACEMENT: &str = "Move Proposal authority into the profile's `permissions.proposals` entry for the Action. Use `party: owner` for owner-only access, and explicitly retain the required `operations` and target `rowBoundaries`. See https://docs.registrystack.org/configure/breg-proposals/."; const READABLE_REQUEST_FIELDS_REPLACEMENT: &str = "Declare the profile's `permissions.proposals` entry for the Action with explicit `readableInputs`, `readableAttachments`, and `readableContextFields` for the disclosure it needs. Review status uses the separate `get-review-status` operation; do not widen Record or Proposal grants. See https://docs.registrystack.org/configure/breg-proposals/."; const EQUALS_INPUT_REPLACEMENT: &str = "Rename `equalsInput` to `equalsFromInput`, keeping the same input reference."; @@ -6248,9 +6361,17 @@ const RETIRED_ACTION_PLAN_KEYS: [RemovedKey<'static>; 2] = [ /// Members `registry.yaml` no longer accepts, each with the member that /// replaced it. +const MEMBERSHIP_BOUNDARIES_REPLACEMENT: &str = "Declare membership: {key, principal, active} on the membership Record type and write each boundary as a rowBoundaries entry {field, membership}."; + +const RETIRED_PROPOSAL_OWNERSHIP: RemovedKey<'static> = RemovedKey { + pointer: "/accessProfiles/*/permissions/proposals/*/ownership", + replacement: "Replace `ownership: caller` with `party: owner`. See https://docs.registrystack.org/configure/breg-proposals/.", +}; + const PROJECT_REMOVED_KEYS: &[RemovedKey<'static>] = &[ RETIRED_ACTION_PLAN_KEYS[0], RETIRED_ACTION_PLAN_KEYS[1], + RETIRED_PROPOSAL_OWNERSHIP, RemovedKey { pointer: "/datasets/*/id", replacement: "Write datasets as a mapping from each id to the rest of its entry, datasets: {DATASET_ID: {display: ...}}, with no id member.", @@ -6352,12 +6473,12 @@ const PROJECT_REMOVED_KEYS: &[RemovedKey<'static>] = &[ replacement: FROM_FIELD_REPLACEMENT, }, RemovedKey { - pointer: "/recordTypes/*/accessProfiles/*/membershipBoundaries/*/membershipEntity", - replacement: "Rename `membershipEntity` to `membershipRecordType`.", + pointer: "/recordTypes/*/accessProfiles/*/membershipBoundaries", + replacement: MEMBERSHIP_BOUNDARIES_REPLACEMENT, }, RemovedKey { - pointer: "/accessProfiles/*/permissions/records/*/membershipBoundaries/*/membershipEntity", - replacement: "Rename `membershipEntity` to `membershipRecordType`.", + pointer: "/accessProfiles/*/permissions/records/*/membershipBoundaries", + replacement: MEMBERSHIP_BOUNDARIES_REPLACEMENT, }, RemovedKey { pointer: "/entities", @@ -6558,12 +6679,12 @@ const MODULE_REMOVED_KEYS: &[RemovedKey<'static>] = &[ replacement: FROM_FIELD_REPLACEMENT, }, RemovedKey { - pointer: "/recordTypes/*/accessProfiles/*/membershipBoundaries/*/membershipEntity", - replacement: "Rename `membershipEntity` to `membershipRecordType`.", + pointer: "/recordTypes/*/accessProfiles/*/membershipBoundaries", + replacement: MEMBERSHIP_BOUNDARIES_REPLACEMENT, }, RemovedKey { - pointer: "/extendRecordTypes/*/accessProfiles/*/membershipBoundaries/*/membershipEntity", - replacement: "Rename `membershipEntity` to `membershipRecordType`.", + pointer: "/extendRecordTypes/*/accessProfiles/*/membershipBoundaries", + replacement: MEMBERSHIP_BOUNDARIES_REPLACEMENT, }, RemovedKey { pointer: "/recordTypes/*/hooks/*/handler/kind", @@ -6684,11 +6805,11 @@ pub const MODULE_FORMAT: FormatSpec<'static> = FormatSpec { removed_keys: MODULE_REMOVED_KEYS, }; -// Replaying a verified package can see the Action Plan keys its sealed source -// predates. Other retired keys are still checked by the shared reader. +// Verified predecessors may carry historical Action Plan and Proposal grant +// spellings. Other retired keys are still checked by the shared reader. const SEALED_PROJECT_FORMAT: FormatSpec<'static> = FormatSpec { removed_keys: PROJECT_REMOVED_KEYS - .split_at(RETIRED_ACTION_PLAN_KEYS.len()) + .split_at(RETIRED_ACTION_PLAN_KEYS.len() + 1) .1, ..PROJECT_FORMAT }; @@ -6733,7 +6854,7 @@ fn normalize_sealed_action_plans(value: &mut Value, document: &Document) -> Resu return Ok(false); }; let mut current = root.contains_key("actionPlans"); - let mut translated = rename_sealed_plan_key(root, "functions", "actionPlans", "", document)?; + let mut translated = rename_sealed_key(root, "functions", "actionPlans", "", document)?; if let Some(actions) = root.get_mut("actions").and_then(Value::as_object_mut) { for (id, action) in actions { let Some(plan) = action.get_mut("plan").and_then(Value::as_object_mut) else { @@ -6761,7 +6882,7 @@ fn normalize_sealed_action_plans(value: &mut Value, document: &Document) -> Resu } current |= current_plan; if (legacy_plan || duplicate_reference) - && rename_sealed_plan_key(plan, "function", "actionPlan", &pointer, document)? + && rename_sealed_key(plan, "function", "actionPlan", &pointer, document)? { plan.insert("type".to_owned(), Value::String("scripted".to_owned())); translated = true; @@ -6771,7 +6892,44 @@ fn normalize_sealed_action_plans(value: &mut Value, document: &Document) -> Resu Ok(translated) } -fn rename_sealed_plan_key( +fn normalize_sealed_proposal_parties( + value: &mut Value, + document: &Document, +) -> Result { + let mut translated = false; + for (profile_path, profile) in entries_mut(value, "accessProfiles", "") { + let Some(permissions) = profile.get_mut("permissions") else { + continue; + }; + let permissions_path = format!("{profile_path}/permissions"); + for (path, entry) in entries_mut(permissions, "proposals", &permissions_path) { + let Some(grant) = entry.as_object_mut() else { + continue; + }; + if rename_sealed_key(grant, "ownership", "party", &path, document)? { + match &grant["party"] { + Value::Null => {} + Value::String(party) if party == "caller" => { + grant.insert("party".to_owned(), Value::String("owner".to_owned())); + } + _ => { + return Err(document.report_with([document.diagnostic_at_value( + Severity::Error, + "config.invalid-value", + &format!("{path}/ownership"), + "A historical Proposal ownership grant must be caller or null.", + "Use a package sealed by the previous release.", + )])); + } + } + translated = true; + } + } + } + Ok(translated) +} + +fn rename_sealed_key( members: &mut serde_json::Map, old: &str, current: &str, @@ -6800,12 +6958,35 @@ fn read_with_value_types( format: &FormatSpec<'_>, sealed: bool, ) -> Result<(Decoded, bool), Report> { - let Decoded { - mut value, - document, - } = read_authored::(file, bytes, format)?; + let ( + Decoded { + mut value, + document, + }, + removed_error, + ) = match read_authored::(file, bytes, format) { + Ok(decoded) => (decoded, None), + Err(report) + if report + .diagnostics() + .iter() + .all(|diagnostic| diagnostic.code == "config.removed-key") => + { + let without_removed = FormatSpec { + removed_keys: &[], + ..*format + }; + ( + read_authored::(file, bytes, &without_removed)?, + Some(report), + ) + } + Err(report) => return Err(report), + }; let translated = if sealed { - normalize_sealed_action_plans(&mut value, &document)? + let action_plans = normalize_sealed_action_plans(&mut value, &document)?; + let proposal_parties = normalize_sealed_proposal_parties(&mut value, &document)?; + action_plans || proposal_parties } else { // The key `type` is still valid. The removed-key table can only // refuse members, so report the retired tag at its value here. @@ -6829,13 +7010,15 @@ fn read_with_value_types( }) .collect(); if !diagnostics.is_empty() { - return Err(document.report_with(diagnostics)); + let removed = removed_error.into_iter().flat_map(Report::into_diagnostics); + return Err(document.report_with(removed.chain(diagnostics))); } false }; let option_errors = field_option_diagnostics(&document, &value); if !option_errors.is_empty() { - return Err(document.report_with(option_errors)); + let removed = removed_error.into_iter().flat_map(Report::into_diagnostics); + return Err(document.report_with(removed.chain(option_errors))); } let has_value_types = value.get("valueTypes").is_some(); let has_row_boundary_sets = value.get("rowBoundarySets").is_some(); @@ -6853,10 +7036,46 @@ fn read_with_value_types( "Declare the set under rowBoundarySets in this file and reference it by its identifier, with no other member.", )]) })?; - if !translated && !has_value_types && !resolved_sets && !has_row_boundary_sets { - return document - .decode() - .map(|value| (Decoded { value, document }, false)); + let mut requirement_errors = Vec::new(); + for collection in ["recordTypes", "extendRecordTypes"] { + for (pointer, entity) in entries_mut(&mut value, collection, "") { + let Some(rows) = entity + .pointer_mut("/accessRequirements/rowBoundaries") + .and_then(Value::as_array_mut) + else { + continue; + }; + for (index, row) in rows.iter_mut().enumerate() { + if serde_json::from_value::(row.clone()).is_ok() { + let base = format!("{pointer}/accessRequirements/rowBoundaries"); + let site = format!("{base}/{index}"); + requirement_errors.push(document.diagnostic_at_value( + Severity::Error, + "breg.access.membership-access-requirement-unsupported", + if document.span_of(&site).is_some() { + &site + } else { + &base + }, + "Record type accessRequirements.rowBoundaries accepts claim entries only.", + "Use a membership entry in rowBoundaries on a grant.", + )); + // Keep the item index while decoding the rest of the document. + // The requirement diagnostic prevents this placeholder from escaping. + *row = serde_json::json!({"field":"id","claim":"sub","operator":"equals"}); + } + } + } + } + if requirement_errors.is_empty() { + if let Some(report) = removed_error { + return Err(report); + } + if !translated && !has_value_types && !resolved_sets && !has_row_boundary_sets { + return document + .decode() + .map(|value| (Decoded { value, document }, false)); + } } // Every reference is expanded, so the read file holds the boundaries // inline and no set: it serializes to source that reads back the same. @@ -6877,13 +7096,14 @@ fn read_with_value_types( } let normalized = serde_json::to_vec(&value).expect("normalized authoring value serializes"); match read_authored::(file, &normalized, format) { - Ok(decoded) => Ok(( + Ok(decoded) if requirement_errors.is_empty() => Ok(( Decoded { value: decoded.value, document, }, translated, )), + Ok(_) => Err(document.report_with(requirement_errors)), Err(report) => { let diagnostics = report .into_diagnostics() @@ -6933,6 +7153,7 @@ fn read_with_value_types( .collect(); placed }) + .chain(requirement_errors) .collect(); Err(Report::new(diagnostics)) } @@ -7478,10 +7699,10 @@ mod tests { use serde_json::json; #[test] - fn sealed_formats_skip_only_the_two_retired_action_plan_keys() { - for (authored, sealed) in [ - (&PROJECT_FORMAT, &SEALED_PROJECT_FORMAT), - (&MODULE_FORMAT, &SEALED_MODULE_FORMAT), + fn sealed_formats_skip_only_translated_retired_keys() { + for (authored, sealed, legacy_ownership) in [ + (&PROJECT_FORMAT, &SEALED_PROJECT_FORMAT, true), + (&MODULE_FORMAT, &SEALED_MODULE_FORMAT, false), ] { let expected = authored .removed_keys @@ -7491,6 +7712,7 @@ mod tests { !RETIRED_ACTION_PLAN_KEYS .iter() .any(|entry| entry.pointer == *pointer) + && !(legacy_ownership && *pointer == RETIRED_PROPOSAL_OWNERSHIP.pointer) }) .collect::>(); let observed = sealed @@ -7499,7 +7721,35 @@ mod tests { .map(|entry| entry.pointer) .collect::>(); assert_eq!(observed, expected); - assert_eq!(authored.removed_keys.len() - observed.len(), 2); + assert_eq!( + authored.removed_keys.len() - observed.len(), + 2 + usize::from(legacy_ownership) + ); + } + } + + #[test] + fn only_a_sealed_project_translates_historical_proposal_ownership() { + let current = include_str!("../../../products/breg/examples/minimal/registry.yaml"); + let old = current.replace("party: owner", "ownership: caller"); + let parsed = parse_project_yaml(current.as_bytes()).unwrap(); + assert_eq!( + parse_sealed_project_yaml(old.as_bytes()).unwrap(), + (parsed, true) + ); + assert_eq!( + parse_project_yaml(old.as_bytes()) + .unwrap_err() + .diagnostics()[0] + .code, + "config.removed-key" + ); + for invalid in [ + "party: subject\n ownership: caller", + "ownership: owner", + ] { + let ambiguous = current.replace("party: owner", invalid); + assert!(parse_sealed_project_yaml(ambiguous.as_bytes()).is_err()); } } diff --git a/crates/registry-breg/src/contract/sentinel.rs b/crates/registry-breg/src/contract/sentinel.rs index df263029e3..43f3769eaa 100644 --- a/crates/registry-breg/src/contract/sentinel.rs +++ b/crates/registry-breg/src/contract/sentinel.rs @@ -19,9 +19,10 @@ use registry_platform_yaml::{shape_union, Invalid, LocalId}; use serde::{de::IgnoredAny, Deserialize, Deserializer, Serialize, Serializer}; use super::{ - AccessProfileSource, AccessRequirementsSource, ActorKindSource, CompiledTaskGrantSource, - ConsentRequirementSource, EntityPermissionSource, LookupPermissionSource, - MembershipBoundarySource, Operation, PermissionsSource, ProvenanceFieldSource, + AccessProfileSource, AccessRequirementsSource, ActionTargetPermissionSource, ActorKindSource, + CompiledTaskGrantSource, ConsentRequirementSource, EntityPermissionSource, + LookupPermissionSource, MembershipBoundarySource, MembershipRowBoundarySource, Operation, + PermissionsSource, ProposalTargetPermissionSource, ProvenanceFieldSource, ReadPathPermissionSource, ReadableFields, RequiredFilterSource, RowBoundarySource, SpatialQueryPermissionSource, UniqueSet, }; @@ -55,6 +56,12 @@ impl Items for Vec { } } +impl Items for Vec { + fn holds_nothing(&self) -> bool { + self.is_empty() + } +} + impl Items for Vec { fn holds_nothing(&self) -> bool { self.is_empty() @@ -167,6 +174,86 @@ pub(super) enum RequiredScopes { shape_union!(RequiredScopes { scalar => Unrestricted, list => Listed }); +/// A row is bounded either by a direct claim or a membership Record type. +#[derive(Clone, Debug, Eq, PartialEq, Serialize)] +#[serde(untagged)] +pub(super) enum RowBoundaryEntry { + Claim(RowBoundarySource), + Membership(MembershipRowBoundarySource), +} + +#[cfg(feature = "schema")] +impl schemars::JsonSchema for RowBoundaryEntry { + fn schema_name() -> std::borrow::Cow<'static, str> { + "RowBoundaryEntry".into() + } + + fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { + let local_id = generator.subschema_for::(); + let operator = generator.subschema_for::(); + schemars::json_schema!({ + "type": "object", + "description": "A claim entry {field, claim, operator} or a membership entry {field, membership}.", + "additionalProperties": false, + "required": ["field"], + "properties": { + "field": {"type": "string"}, + "claim": {"type": "string"}, + "operator": operator, + "membership": local_id.clone() + }, + "if": {"required": ["membership"]}, + "then": {"properties": {"field": local_id, "claim": false, "operator": false}}, + "else": {"required": ["claim", "operator"]} + }) + } +} + +impl<'de> Deserialize<'de> for RowBoundaryEntry { + fn deserialize>(deserializer: D) -> Result { + #[derive(Deserialize)] + #[serde(deny_unknown_fields)] + struct Entry { + #[serde(default, deserialize_with = "present")] + field: Option, + #[serde(default, deserialize_with = "present")] + claim: Option, + #[serde(default, deserialize_with = "present")] + operator: Option, + #[serde(default, deserialize_with = "present")] + membership: Option, + } + fn present<'de, T: Deserialize<'de>, D: Deserializer<'de>>( + deserializer: D, + ) -> Result, D::Error> { + T::deserialize(deserializer).map(Some) + } + let entry = Entry::deserialize(deserializer)?; + match (entry.field, entry.claim, entry.operator, entry.membership) { + (Some(field), Some(claim), Some(operator), None) => { + Ok(Self::Claim(RowBoundarySource { + field, + claim, + operator, + })) + } + (Some(field), None, None, Some(membership)) => { + Ok(Self::Membership(MembershipRowBoundarySource { + field: LocalId::new(field) + .map_err(Invalid::into_error)? + .into_string(), + membership: membership.into_string(), + })) + } + _ => Err(Invalid::expected( + "a claim entry {field, claim, operator} or a membership entry {field, membership}", + "Write exactly one of the two rowBoundaries entry shapes.", + ) + .into_error()), + } + } +} + /// A reference to a named list of row boundaries the file declares under /// `rowBoundarySets`. The reader expands a reference into the set's boundaries /// before the typed model is decoded, so the compiler never holds one. @@ -186,9 +273,9 @@ pub(super) struct RowBoundarySetReference { pub(super) enum RowBoundaries { /// Reach every row. Unrestricted(Unrestricted), - /// Reach the rows every listed boundary binds to the caller's claims. - Listed(Listed, Rows>), - /// Reach the rows every boundary of a named set binds to the caller's claims. + /// Reach the rows bounded by every listed claim or membership entry. + Listed(Listed, Rows>), + /// Reach the rows bounded by every entry in a named set. // The reader expands the reference before decoding, so the typed model // only refuses it and never reads the identifier. Reference(#[allow(dead_code)] RowBoundarySetReference), @@ -222,40 +309,101 @@ pub(super) fn serialize_required_scopes( } } +type SplitRows = (Vec, Vec); + impl RowBoundaries { - /// The boundaries the compiler holds, where `unrestricted` is none. An - /// unexpanded reference is refused rather than read as none. - fn into_boundaries(self) -> Result, Invalid> { - match self { - Self::Unrestricted(_) => Ok(Vec::new()), - Self::Listed(Listed(boundaries, _)) => Ok(boundaries), - Self::Reference(_) => Err(Invalid::expected( - UNRESOLVED_REFERENCE, - UNRESOLVED_REFERENCE_ACTION, - )), + fn into_boundaries(self) -> Result { + let entries = match self { + Self::Unrestricted(_) => return Ok((Vec::new(), Vec::new())), + Self::Listed(Listed(entries, _)) => entries, + Self::Reference(_) => { + return Err(Invalid::expected( + UNRESOLVED_REFERENCE, + UNRESOLVED_REFERENCE_ACTION, + )) + } + }; + let mut claims = Vec::new(); + let mut memberships = Vec::new(); + for entry in entries { + match entry { + RowBoundaryEntry::Claim(claim) => claims.push(claim), + RowBoundaryEntry::Membership(membership) => memberships.push(membership), + } } + Ok((claims, memberships)) } -} -pub(super) fn row_boundaries<'de, D: Deserializer<'de>>( - deserializer: D, -) -> Result, D::Error> { - RowBoundaries::deserialize(deserializer)? - .into_boundaries() - .map_err(Invalid::into_error) + fn from_boundaries( + claims: Vec, + memberships: Vec, + ) -> Self { + if claims.is_empty() && memberships.is_empty() { + Self::Unrestricted(Unrestricted(PhantomData)) + } else { + Self::Listed(Listed( + claims + .into_iter() + .map(RowBoundaryEntry::Claim) + .chain(memberships.into_iter().map(RowBoundaryEntry::Membership)) + .collect(), + PhantomData, + )) + } + } } -pub(super) fn serialize_row_boundaries( - boundaries: &[RowBoundarySource], - serializer: S, -) -> Result { - if boundaries.is_empty() { - serializer.serialize_str(UNRESTRICTED) - } else { - boundaries.serialize(serializer) +impl Serialize for RowBoundaries { + fn serialize(&self, serializer: S) -> Result { + match self { + Self::Unrestricted(_) => serializer.serialize_str(UNRESTRICTED), + Self::Listed(Listed(entries, _)) => entries.serialize(serializer), + Self::Reference(_) => Err(serde::ser::Error::custom(UNRESOLVED_REFERENCE)), + } } } +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Deserialize, Serialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub(super) struct AuthoredTargetPermission { + record_type: String, + row_boundaries: RowBoundaries, +} + +macro_rules! target_permission { + ($source:ident, $record_type:ident) => { + impl TryFrom for $source { + type Error = Invalid; + + fn try_from(authored: AuthoredTargetPermission) -> Result { + let (row_boundaries, membership_row_boundaries) = + authored.row_boundaries.into_boundaries()?; + Ok(Self { + $record_type: authored.record_type, + row_boundaries, + membership_row_boundaries, + }) + } + } + + impl From<$source> for AuthoredTargetPermission { + fn from(source: $source) -> Self { + Self { + record_type: source.$record_type, + row_boundaries: RowBoundaries::from_boundaries( + source.row_boundaries, + source.membership_row_boundaries, + ), + } + } + } + }; +} + +target_permission!(ActionTargetPermissionSource, entity); +target_permission!(ProposalTargetPermissionSource, record_type); + /// Declares a member that only narrows: a list of at least one item, omitted /// when it narrows nothing. A scalar is refused with the same fix as an empty /// list, so an author who writes `unrestricted` here is told to omit the @@ -343,7 +491,7 @@ narrowing_member!( RowBoundarySetRows, RowBoundarySetRowsShapes, row_boundary_set_rows, - Vec, + Vec, "a list of at least one row boundary", "List the row boundaries the set holds. A set is a reusable list, so it is never empty and never unrestricted: write unrestricted on the grant that reaches every row." ); @@ -518,14 +666,7 @@ pub(super) struct AuthoredModuleProfile { #[serde(default, skip_serializing_if = "Option::is_none")] spatial_queries: Option, /// Row reach: `unrestricted`, or a list of at least one row boundary. - #[serde( - deserialize_with = "row_boundaries", - serialize_with = "serialize_row_boundaries" - )] - #[cfg_attr(feature = "schema", schemars(with = "RowBoundaries"))] - row_boundaries: Vec, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - membership_boundaries: Vec, + row_boundaries: RowBoundaries, #[serde(default, skip_serializing_if = "Vec::is_empty")] require_consent: Vec, #[serde(default, skip_serializing_if = "Vec::is_empty")] @@ -550,10 +691,13 @@ pub(super) struct AuthoredModuleProfile { allow_data_export: bool, } -impl From for AccessProfileSource { - fn from(authored: AuthoredModuleProfile) -> Self { +impl TryFrom for AccessProfileSource { + type Error = Invalid; + + fn try_from(authored: AuthoredModuleProfile) -> Result { + let (row_boundaries, memberships) = authored.row_boundaries.into_boundaries()?; let (readable_fields, readable_fields_ceiling) = authored.readable_fields.into_parts(); - Self { + Ok(Self { id: authored.id, display: authored.display, default: authored.default, @@ -573,8 +717,11 @@ impl From for AccessProfileSource { required_filters: authored.required_filters, sortable_fields: authored.sortable_fields, spatial_queries: authored.spatial_queries, - row_boundaries: authored.row_boundaries, - membership_boundaries: authored.membership_boundaries, + row_boundaries, + membership_boundaries: memberships + .into_iter() + .map(MembershipBoundarySource::Declared) + .collect(), require_consent: authored.require_consent, lookups: authored.lookups, read_paths: authored.read_paths.into_iter().map(Into::into).collect(), @@ -582,7 +729,7 @@ impl From for AccessProfileSource { revision_access: authored.revision_access, provenance_fields: authored.provenance_fields, allow_data_export: authored.allow_data_export, - } + }) } } @@ -610,8 +757,20 @@ impl From for AuthoredModuleProfile { required_filters: profile.required_filters, sortable_fields: profile.sortable_fields, spatial_queries: profile.spatial_queries, - row_boundaries: profile.row_boundaries, - membership_boundaries: profile.membership_boundaries, + row_boundaries: RowBoundaries::from_boundaries( + profile.row_boundaries, + profile + .membership_boundaries + .into_iter() + .map(|entry| match entry { + MembershipBoundarySource::Declared(entry) => entry, + MembershipBoundarySource::Expanded(entry) => MembershipRowBoundarySource { + field: entry.field, + membership: entry.membership_entity, + }, + }) + .collect(), + ), require_consent: profile.require_consent, lookups: profile.lookups, read_paths: profile.read_paths.into_iter().map(Into::into).collect(), @@ -626,12 +785,10 @@ impl From for AuthoredModuleProfile { pub(super) fn module_access_profiles<'de, D: Deserializer<'de>>( deserializer: D, ) -> Result, D::Error> { - Ok( - registry_platform_yaml::id_keyed_by_local_id::(deserializer)? - .into_iter() - .map(AccessProfileSource::from) - .collect(), - ) + registry_platform_yaml::id_keyed_by_local_id::(deserializer)? + .into_iter() + .map(|profile| AccessProfileSource::try_from(profile).map_err(Invalid::into_error)) + .collect() } pub(super) fn serialize_module_access_profiles( @@ -732,10 +889,6 @@ pub(super) struct AuthoredEntityPermission { #[serde(serialize_with = "serialize_entity_rows")] #[cfg_attr(feature = "schema", schemars(with = "RowBoundaries"))] row_boundaries: Option, - /// Current active membership required for each stored reference key. - #[serde(default, skip_serializing_if = "Vec::is_empty")] - #[cfg_attr(feature = "schema", schemars(extend("default" = [])))] - membership_boundaries: Vec, /// Current subject-issued consent required for each row, ANDed. #[serde(default, skip_serializing_if = "Vec::is_empty")] #[cfg_attr(feature = "schema", schemars(extend("default" = [])))] @@ -760,6 +913,7 @@ pub(super) struct AuthoredEntityPermission { feature = "schema", schemars(with = "UniqueSet", extend("default" = [])) )] + #[cfg_attr(feature = "schema", schemars(extend("default" = [])))] provenance_fields: Vec, #[serde(default)] allow_data_export: bool, @@ -788,6 +942,7 @@ impl TryFrom for EntityPermissionSource { )); }; let (readable_fields, readable_fields_ceiling) = authored.readable_fields.into_parts(); + let (row_boundaries, membership_row_boundaries) = row_boundaries.into_boundaries()?; Ok(Self { entity: authored.entity, operations: authored.operations, @@ -799,8 +954,8 @@ impl TryFrom for EntityPermissionSource { required_filters: authored.required_filters, sortable_fields: authored.sortable_fields, spatial_queries: authored.spatial_queries, - row_boundaries: row_boundaries.into_boundaries()?, - membership_boundaries: authored.membership_boundaries, + row_boundaries, + membership_row_boundaries, require_consent: authored.require_consent, lookups: authored.lookups, read_paths: authored.read_paths.into_iter().map(Into::into).collect(), @@ -814,11 +969,6 @@ impl TryFrom for EntityPermissionSource { impl From for AuthoredEntityPermission { fn from(source: EntityPermissionSource) -> Self { - let rows = if source.row_boundaries.is_empty() { - RowBoundaries::Unrestricted(Unrestricted(PhantomData)) - } else { - RowBoundaries::Listed(Listed(source.row_boundaries, PhantomData)) - }; Self { entity: source.entity, operations: source.operations, @@ -832,8 +982,10 @@ impl From for AuthoredEntityPermission { required_filters: source.required_filters, sortable_fields: source.sortable_fields, spatial_queries: source.spatial_queries, - row_boundaries: Some(rows), - membership_boundaries: source.membership_boundaries, + row_boundaries: Some(RowBoundaries::from_boundaries( + source.row_boundaries, + source.membership_row_boundaries, + )), require_consent: source.require_consent, lookups: source.lookups, read_paths: source.read_paths.into_iter().map(Into::into).collect(), diff --git a/crates/registry-breg/src/disclosure.rs b/crates/registry-breg/src/disclosure.rs index 7d066edcf9..f6587bd523 100644 --- a/crates/registry-breg/src/disclosure.rs +++ b/crates/registry-breg/src/disclosure.rs @@ -82,6 +82,33 @@ impl DisclosurePlan<'_> { }) } + #[cfg(feature = "runtime")] + pub(crate) fn withholds_record_before_allocation( + &self, + state: &Map, + ) -> Result { + for condition in &self.conditions { + if matches!(condition.withhold, DisclosureWithhold::Record) + && condition.when.iter().all(|predicate| { + let field = match predicate { + DisclosureWhenPredicate::FieldEquals { field, .. } + | DisclosureWhenPredicate::FieldIn { field, .. } + | DisclosureWhenPredicate::FieldIsNull { field } + | DisclosureWhenPredicate::FieldIsNotNull { field } => field, + }; + self.entity + .fields + .get(field) + .is_none_or(|field| field.generate.is_none()) + }) + && when_matches(self.entity, &condition.when, state)? + { + return Ok(true); + } + } + Ok(false) + } + /// Whether a `record` or `history` condition matches `state`, so the /// record's revisions and snapshots behave as absent. pub fn withholds_history(&self, state: &Map) -> Result { diff --git a/crates/registry-breg/src/evidence_source/tests.rs b/crates/registry-breg/src/evidence_source/tests.rs index 7c9f0bf6ed..6214a239ed 100644 --- a/crates/registry-breg/src/evidence_source/tests.rs +++ b/crates/registry-breg/src/evidence_source/tests.rs @@ -427,11 +427,13 @@ fn membership_project() -> Value { {"id":"active","type":"boolean","classification":"internal"}, {"id":"other-active","type":"boolean","classification":"internal"}]})) ]); - source["accessProfiles"]["evidence-source"]["permissions"]["records"][0] - ["membershipBoundaries"] = json!([{ - "field":"organization","membershipRecordType":"membership","membershipKeyField":"organization", - "principalField":"principal","activeField":"active" - }]); + source["recordTypes"]["membership"]["membership"] = + json!({"key":"organization","principal":"principal","active":"active"}); + let grant = &mut source["accessProfiles"]["evidence-source"]["permissions"]["records"][0]; + grant["rowBoundaries"] + .as_array_mut() + .unwrap() + .push(json!({"field":"organization","membership":"membership"})); source } @@ -441,13 +443,12 @@ fn membership_behavior_reaches_helper_semantics_source_fields_and_select_authori let registry = compiled(&original, SQL); let before = export_evidence_source(®istry, &options()).unwrap(); for (name, value) in [ - ("principalField", "other-principal"), - ("activeField", "other-active"), - ("membershipKeyField", "other-organization"), + ("principal", "other-principal"), + ("active", "other-active"), + ("key", "other-organization"), ] { let mut changed = original.clone(); - changed["accessProfiles"]["evidence-source"]["permissions"]["records"][0] - ["membershipBoundaries"][0][name] = json!(value); + changed["recordTypes"]["membership"]["membership"][name] = json!(value); let after_registry = compiled(&changed, SQL); assert_eq!( select_policies(®istry, ®istry.entities()["record"], "evidence-source"), @@ -510,10 +511,7 @@ fn membership_behavior_reaches_helper_semantics_source_fields_and_select_authori fn reached_derived_source_consumes_its_membership_helper() { let mut original = membership_project(); let reader = &original["accessProfiles"]["evidence-source"]["permissions"]["records"][0]; - let (boundary, row_boundaries) = ( - reader["membershipBoundaries"].clone(), - reader["rowBoundaries"].clone(), - ); + let row_boundaries = reader["rowBoundaries"].clone(); original["recordTypes"].as_object_mut().unwrap().insert("flag".to_owned(), json!({"route":"flags","primaryDataset":"test-dataset","mutationMode":"mutable","fields":[ {"id":"code","type":"string","maximumLength":32,"classification":"internal"}, {"id":"organization","type":"reference","target":"organization","classification":"internal"}, @@ -522,15 +520,17 @@ fn reached_derived_source_consumes_its_membership_helper() { {"id":"enabled","type":"boolean","classification":"internal"}] })); original["accessProfiles"]["evidence-source"]["permissions"]["records"].as_array_mut().unwrap().push(json!({ - "recordType":"flag","operations":["get"],"readableFields":["code","enabled"],"rowBoundaries":row_boundaries, - "membershipBoundaries":boundary + "recordType":"flag","operations":["get"],"readableFields":["code","enabled"],"rowBoundaries":row_boundaries })); let sql = "SELECT r.id AS id, f.enabled AS active FROM registry_source.record r JOIN registry_source.flag f ON f.code = r.code"; let mut selection = options(); selection.fields = vec!["active".into()]; let before = export_evidence_source(&compiled(&original, sql), &selection).unwrap(); - original["accessProfiles"]["evidence-source"]["permissions"]["records"][1] - ["membershipBoundaries"][0]["field"] = json!("other-organization"); + original["accessProfiles"]["evidence-source"]["permissions"]["records"][1]["rowBoundaries"] + .as_array_mut() + .unwrap() + .last_mut() + .unwrap()["field"] = json!("other-organization"); assert_ne!( before.behavior_revision, export_evidence_source(&compiled(&original, sql), &selection) diff --git a/crates/registry-breg/src/fixtures.rs b/crates/registry-breg/src/fixtures.rs index 1b1ad4578b..420073d2a8 100644 --- a/crates/registry-breg/src/fixtures.rs +++ b/crates/registry-breg/src/fixtures.rs @@ -749,7 +749,7 @@ struct ClaimsSource { } impl ClaimsSource { - /// The authored scopes as a set, for comparison with a profile's. + /// The full authored scope set, for exact credential binding. fn scope_set(&self) -> BTreeSet { self.scopes.iter().cloned().collect() } @@ -1816,12 +1816,22 @@ fn validate_claims( profile: &AccessProfileSource, outcome: ExpectedOutcome, ) -> Result<(), FixtureError> { + // Exact bearer binding includes every authored scope. For the profile + // comparison, set aside only OIDC scopes the profile does not require. + let profile_scopes = claims + .scopes + .iter() + .filter(|scope| { + profile.required_scopes.contains(*scope) + || !registry_platform_oidc::OPENID_CONNECT_SCOPES.contains(&scope.as_str()) + }) + .cloned() + .collect::>(); if claims .principal .as_deref() .is_none_or(|value| value.is_empty() || value.len() > MAX_BINDING_BYTES) - || !claims - .scopes + || !profile_scopes .iter() .all(|scope| profile.required_scopes.contains(scope)) { @@ -1871,7 +1881,7 @@ fn validate_claims( } if outcome == ExpectedOutcome::Success && (claims.principal.is_none() - || claims.scope_set() != *profile.required_scopes + || profile_scopes != *profile.required_scopes || (!profile.required_purposes.is_empty() && claims.purpose.is_none()) || missing_direct_claim) { @@ -2089,15 +2099,11 @@ fn fixture_action_input_value_is_valid( } } +/// The condition inputs the Action's own HTTP contract requires, so a journey +/// sends exactly the preconditions a caller would. A current-revision Action +/// requires none. fn condition_input_api_names(action: &CompiledAction) -> BTreeSet { - let logical_ids = action - .effects - .iter() - .filter_map(|effect| match &effect.target.binding { - crate::model::CompiledPlanTargetBinding::Existing { input } => Some(input.as_str()), - crate::model::CompiledPlanTargetBinding::Create => None, - }) - .collect::>(); + let logical_ids = crate::plan::condition_inputs(action); action .inputs .iter() @@ -6934,12 +6940,14 @@ mod tests { assert_exact_claims(&undeclared, &profile, &exact, &claims.scope_set()), Err(FixtureError::AuthorityWideningRefused) ); - let widened_scopes = - BTreeSet::from(["registry:read".to_owned(), "registry:write".to_owned()]); - assert_eq!( - assert_exact_claims(&claims, &profile, &exact, &widened_scopes), - Err(FixtureError::AuthorityWideningRefused) - ); + for scope in ["registry:write", "openid"] { + let mut widened_scopes = claims.scope_set(); + widened_scopes.insert(scope.to_owned()); + assert_eq!( + assert_exact_claims(&claims, &profile, &exact, &widened_scopes), + Err(FixtureError::AuthorityWideningRefused) + ); + } } #[test] @@ -6989,6 +6997,58 @@ mod tests { } } + #[test] + fn fixture_profile_scope_comparison_sets_aside_openid_scopes() { + for (required, scopes, expected) in [ + (json!([]), json!(["openid", "profile"]), Ok(())), + ( + json!(["fixture:write", "openid"]), + json!(["openid", "profile", "fixture:write"]), + Ok(()), + ), + ( + json!(["fixture:write", "openid"]), + json!(["profile", "fixture:write"]), + Err(FixtureError::AuthorityWideningRefused), + ), + ( + json!(["fixture:write"]), + json!(["openid", "fixture:write"]), + Ok(()), + ), + ( + json!(["fixture:write"]), + json!(["openid", "fixture:write", "fixture:extra"]), + Err(FixtureError::AuthorityWideningRefused), + ), + ( + json!(["fixture:write"]), + json!(["openid"]), + Err(FixtureError::AuthorityWideningRefused), + ), + ] { + let profile = serde_json::from_value(json!({ + "id": "fixture", + "principalClaim": "sub", + "actorKind": "human", + "operations": ["get"], + "rowBoundaries": [], + "requiredScopes": required + })) + .unwrap(); + let claims = serde_json::from_value(json!({ + "principal": "fixture-person", + "actorKind": "human", + "scopes": scopes + })) + .unwrap(); + assert_eq!( + validate_claims(&claims, &profile, ExpectedOutcome::Success), + expected + ); + } + } + #[test] fn fixture_claims_leave_reserved_consent_claims_to_the_verified_client() { let profile: AccessProfileSource = serde_json::from_value(json!({ @@ -7073,7 +7133,7 @@ journeys: - id: list-people recordType: person accessProfile: person-operator - claims: {principal: fixture-operator, purpose: person-maintenance} + claims: {principal: fixture-operator, purpose: person-maintenance, scopes: [people:write]} request: {type: list} expect: {outcome: success, status: 200, count: 0} "#; @@ -7400,7 +7460,7 @@ journeys: {"id":"name","type":"string","maximumLength":80,"required":true,"classification":"internal"}], "plan":{"type":"scripted","actionPlan":"person-plan","inputs":["person","name"], "writes":[{"id":"person","target":{"fromInput":"person"},"operation":"patch","fields":["name"]}]}}}, - "accessProfiles":{"person-operator": {"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["person-maintenance"], + "accessProfiles":{"person-operator": {"principalClaim":"principal","requiredScopes":["people:write"],"requiredPurposes":["person-maintenance"], "permissions":{"records":[{"recordType":"person","operations":["get","list"],"readableFields":["name"],"rowBoundaries":"unrestricted"}], "actions":[{"action":"rename-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person"]}]}}} })).unwrap() @@ -8797,7 +8857,7 @@ journeys: .expect("constraint project compiles"); let step = |id: &str, request: &str| { format!( - " - id: {id}\n recordType: widget\n accessProfile: operator\n claims:\n principal: fixture-operator\n purpose: case-management\n directClaims: {{jurisdiction: zone-a}}\n request: {request}\n expect: {{outcome: refusal, status: 409, problemCode: mutation.conflict}}\n" + " - id: {id}\n recordType: widget\n accessProfile: operator\n claims:\n principal: fixture-operator\n scopes: [fixture:write]\n purpose: case-management\n directClaims: {{jurisdiction: zone-a}}\n request: {request}\n expect: {{outcome: refusal, status: 409, problemCode: mutation.conflict}}\n" ) }; let journeys = format!( diff --git a/crates/registry-breg/src/fixtures/proposals.rs b/crates/registry-breg/src/fixtures/proposals.rs index 7ff32dd06a..fb0894b127 100644 --- a/crates/registry-breg/src/fixtures/proposals.rs +++ b/crates/registry-breg/src/fixtures/proposals.rs @@ -83,6 +83,7 @@ fn profile(grant: &CompiledProposalPermission) -> Result DdlInventory { + let membership_probes = crate::membership::probes(entities, actions); let mut statements = vec![DdlStatement { id: "schema.registry_data".to_owned(), kind: DdlStatementKind::Schema, @@ -502,7 +503,10 @@ pub(crate) fn generate_ddl_with_actions( for field_id in spatial_projection_fields(entity) { statements.push(spatial_projection_statements(entity, &field_id).create_index); } - for (id, _, sql) in crate::consent::index_statements(entity) { + for (id, _, sql) in crate::consent::index_statements(entity) + .into_iter() + .chain(crate::membership::index_statement(entity)) + { statements.push(DdlStatement { id, kind: DdlStatementKind::Index, @@ -544,35 +548,48 @@ pub(crate) fn generate_ddl_with_actions( // Invoker helpers give membership facts a processing-only RLS context. // The exception block rolls back the local marker on errors; normal return // restores its prior value. No cluster-wide custom-parameter ACL is needed. - for entity in entities.values() { - for (profile_id, boundaries) in &entity.membership_boundaries { - for (index, boundary) in boundaries.iter().enumerate() { - let name = crate::membership::function_name(&entity.id, profile_id, index); - let body = format!( - "DECLARE prior_marker text := current_setting('registry.membership_probe', true); authorized boolean; BEGIN PERFORM set_config('registry.membership_probe', {}, true); SELECT EXISTS (SELECT 1 FROM registry_data.{} AS membership WHERE {} AND membership.{} = $1) INTO authorized; PERFORM set_config('registry.membership_probe', COALESCE(prior_marker, ''), true); RETURN authorized; EXCEPTION WHEN OTHERS THEN RAISE; END", - quote_literal(&name), - quote_identifier(&boundary.membership_table), - crate::membership::source_predicate(boundary, "membership"), - quote_identifier(&boundary.membership_key_column), - ); - statements.push(DdlStatement { - id: format!("registry_context.{name}"), - kind: DdlStatementKind::Function, - sql: format!( - "CREATE FUNCTION registry_context.{}(uuid) RETURNS boolean LANGUAGE plpgsql STABLE STRICT SECURITY INVOKER SET search_path = pg_catalog AS {}", - quote_identifier(&name), quote_literal(&body), - ), - }); - functions.push(DdlFunction { - id: format!("registry_context.{name}"), - schema: "registry_context".to_owned(), - name, - arguments: "uuid".to_owned(), - runtime_execute: true, - spatial_bbox_execute: false, - }); - } - } + for probe in &membership_probes { + let boundary = probe.boundary; + let name = probe.name.clone(); + let scan = format!( + "1 FROM registry_data.{} AS membership WHERE {} AND membership.{} = $1", + quote_identifier(&boundary.membership_table), + crate::membership::source_predicate(boundary, "membership"), + quote_identifier(&boundary.membership_key_column), + ); + let (query, volatility) = if probe.locks { + ( + format!( + "PERFORM {scan} ORDER BY membership.record_id FOR SHARE; authorized := FOUND" + ), + "VOLATILE", + ) + } else { + ( + format!("SELECT EXISTS (SELECT {scan}) INTO authorized"), + "STABLE", + ) + }; + let body = format!( + "DECLARE prior_marker text := current_setting('registry.membership_probe', true); authorized boolean; BEGIN PERFORM set_config('registry.membership_probe', {}, true); {query}; PERFORM set_config('registry.membership_probe', COALESCE(prior_marker, ''), true); RETURN authorized; EXCEPTION WHEN OTHERS THEN RAISE; END", + quote_literal(&name), + ); + statements.push(DdlStatement { + id: format!("registry_context.{name}"), + kind: DdlStatementKind::Function, + sql: format!( + "CREATE FUNCTION registry_context.{}(uuid) RETURNS boolean LANGUAGE plpgsql {volatility} STRICT SECURITY INVOKER SET search_path = pg_catalog AS {}", + quote_identifier(&name), quote_literal(&body), + ), + }); + functions.push(DdlFunction { + id: format!("registry_context.{name}"), + schema: "registry_context".to_owned(), + name, + arguments: "uuid".to_owned(), + runtime_execute: true, + spatial_bbox_execute: false, + }); } // Consent probes share the membership security shape: an invoker helper // whose own marker opens the consent table's guarded policy for this @@ -608,17 +625,20 @@ pub(crate) fn generate_ddl_with_actions( } } for entity in entities.values() { - let runtime_privileges = runtime_privileges(entity, entities, actions); + let runtime_privileges = runtime_privileges(entity, entities, actions, &membership_probes); let runtime_lock_column = !runtime_privileges.contains(&TablePrivilege::Update) - && actions - .actions + && (membership_probes .iter() - .flat_map(|action| &action.target_uses) - .any(|target| { - target.entity_id == entity.id - && matches!(target.operation, Operation::Get | Operation::Invoke) - }); - let policies = policies(entity, entities, actions); + .any(|probe| probe.locks && probe.boundary.membership_entity == entity.id) + || actions + .actions + .iter() + .flat_map(|action| &action.target_uses) + .any(|target| { + target.entity_id == entity.id + && matches!(target.operation, Operation::Get | Operation::Invoke) + })); + let policies = policies(entity, entities, actions, &membership_probes); let table = quote_identifier(&entity.physical_table); statements.push(DdlStatement { id: format!("entity.{}.rls.enable", entity.id), @@ -1508,6 +1528,7 @@ fn runtime_privileges( entity: &CompiledEntity, entities: &BTreeMap, actions: &CompiledActionInventory, + membership_probes: &[crate::membership::MembershipProbe<'_>], ) -> BTreeSet { let operations = entity .access_profiles @@ -1526,16 +1547,14 @@ fn runtime_privileges( | Operation::Snapshot ) }) || path_select_entities(entities).contains(&entity.id) + || membership_probes + .iter() + .any(|probe| probe.boundary.membership_entity == entity.id) || entities.values().any(|root| { - root.membership_boundaries + root.consent_requirements .values() .flatten() - .any(|boundary| boundary.membership_entity == entity.id) - || root - .consent_requirements - .values() - .flatten() - .any(|requirement| requirement.record == entity.id) + .any(|requirement| requirement.record == entity.id) }) { privileges.insert(TablePrivilege::Select); @@ -1577,6 +1596,7 @@ fn policies( entity: &CompiledEntity, entities: &BTreeMap, actions: &CompiledActionInventory, + membership_probes: &[crate::membership::MembershipProbe<'_>], ) -> Vec { let mut policies = Vec::new(); for profile in entity.access_profiles.values() { @@ -1639,7 +1659,7 @@ fn policies( }); } } - policies.extend(membership_source_policies(entity, entities)); + policies.extend(membership_source_policies(entity, membership_probes)); policies.extend(consent_source_policies(entity, entities)); policies.extend(read_path_policies_for_table(entity, entities)); policies.extend(immediate_action_target_policies_for_table(entity, actions)); @@ -1680,36 +1700,38 @@ pub(crate) fn disclosure_policy_name(entity_id: &str, condition_id: &str) -> Str fn membership_source_policies( entity: &CompiledEntity, - entities: &BTreeMap, + probes: &[crate::membership::MembershipProbe<'_>], ) -> Vec { let mut policies = Vec::new(); - for root in entities.values() { - for (profile, boundaries) in &root.membership_boundaries { - for (index, boundary) in boundaries.iter().enumerate() { - if boundary.membership_entity != entity.id { - continue; - } - policies.push(DdlPolicy { - permissive: true, - name: format!( - "registry_{}", - crate::membership::function_name(&root.id, profile, index) - ), - command: PolicyCommand::Select, - access_profile: profile.clone(), - applies_to: DdlPolicyRole::Runtime, - using_expression: Some(format!( - "({}) AND ({})", - crate::membership::source_guard(&root.id, profile, index), - crate::membership::source_predicate( - boundary, - "e_identifier(&entity.physical_table) - ) - )), - check_expression: None, - }); - } + for probe in probes + .iter() + .filter(|probe| probe.boundary.membership_entity == entity.id) + { + let select = DdlPolicy { + permissive: true, + name: format!("registry_{}", probe.name), + command: PolicyCommand::Select, + access_profile: probe.profile.to_owned(), + applies_to: DdlPolicyRole::Runtime, + using_expression: Some(format!( + "({}) AND ({})", + crate::membership::source_guard(&probe.name, probe.profile), + crate::membership::source_predicate( + probe.boundary, + "e_identifier(&entity.physical_table) + ) + )), + check_expression: None, + }; + if probe.locks { + policies.push(DdlPolicy { + name: format!("{}_update", select.name), + command: PolicyCommand::Update, + check_expression: Some("false".to_owned()), + ..select.clone() + }); } + policies.push(select); } policies } @@ -2113,6 +2135,7 @@ fn immediate_action_target_policies_for_table( if !emitted_profiles.insert(grant.profile_id.as_str()) || target_effects.is_empty() { continue; } + let first_policy = policies.len(); let expressions = immediate_action_application_expressions( target_entity, action, @@ -2211,6 +2234,7 @@ fn immediate_action_target_policies_for_table( check_expression: Some(writable), }); } + append_action_target_probes(target_entity, grant, &mut policies[first_policy..]); } for target_use in action.target_uses.iter().filter(|target_use| { @@ -2232,6 +2256,7 @@ fn immediate_action_target_policies_for_table( .iter() .any(|target| target.entity_id == target_entity.id) }) { + let first_policy = policies.len(); let expression = immediate_action_link_expression( target_entity, action, @@ -2267,12 +2292,31 @@ fn immediate_action_target_policies_for_table( using_expression: Some(format!("{expression} AND record_lifecycle = 'active'")), check_expression: Some("false".to_owned()), }); + append_action_target_probes(target_entity, grant, &mut policies[first_policy..]); } } } policies } +fn append_action_target_probes( + entity: &CompiledEntity, + grant: &crate::model::CompiledActionPermission, + policies: &mut [DdlPolicy], +) { + if let Some(target) = grant + .entity_target_locks() + .find(|target| target.entity_id == entity.id) + { + crate::membership::append_target_probes( + entity, + &grant.profile_id, + &target.membership_boundaries, + policies, + ); + } +} + fn immediate_action_application_expressions( target_entity: &CompiledEntity, action: &CompiledAction, @@ -3430,6 +3474,13 @@ pub(crate) fn quote_literal(value: &str) -> String { format!("'{}'", value.replace('\'', "''")) } +#[cfg(test)] +use crate as breg_fixture_crate; + +#[cfg(test)] +#[path = "../tests/support/membership_targets.rs"] +mod membership_targets; + #[cfg(test)] mod tests { use serde_json::json; @@ -3443,6 +3494,147 @@ mod tests { SPATIAL_BBOX_FUNCTION_NAME, SPATIAL_POLYGON_CONTRACT_FUNCTION_NAME, }; + #[test] + fn action_target_policies_append_the_membership_probe() { + let (registry, mut actions) = super::membership_targets::immediate(false); + let mut patch = actions.actions[0].effects[0].clone(); + patch.id = "patch-child".into(); + patch.operation = super::Operation::Patch; + patch.target.binding = crate::model::CompiledPlanTargetBinding::Existing { + input: "child".into(), + }; + actions.actions[0].effects.push(patch); + let ddl = super::generate_ddl_with_actions( + registry.entities(), + registry.physical_names(), + &actions, + ); + let probe = ddl + .functions + .iter() + .find(|f| f.name.starts_with("membership_target_")) + .unwrap(); + assert_eq!( + ddl.functions + .iter() + .filter(|f| f.name.starts_with("membership_target_")) + .count(), + 1 + ); + for (entity, commands) in [ + ( + "child", + vec![ + super::PolicyCommand::Select, + super::PolicyCommand::Insert, + super::PolicyCommand::Update, + ], + ), + ( + "parent", + vec![super::PolicyCommand::Select, super::PolicyCommand::Update], + ), + ] { + let table = ddl + .tables + .iter() + .find(|table| table.entity_id == entity) + .unwrap(); + let field = if entity == "child" { + "parent" + } else { + "directory" + }; + let suffix = format!( + " AND registry_context.{}({})", + quote_identifier(&probe.name), + quote_identifier(®istry.entities()[entity].fields[field].physical_name) + ); + assert_eq!( + table + .policies + .iter() + .map(|policy| policy.command) + .collect::>(), + commands + ); + for expression in table.policies.iter().flat_map(|policy| { + policy + .using_expression + .iter() + .chain(&policy.check_expression) + }) { + assert!( + expression == "false" || expression.ends_with(&suffix), + "{expression}" + ); + } + } + } + + #[test] + fn proposal_target_policies_append_the_membership_probe() { + for automatic in [false, true] { + let source = crate::proposal_hooks::test_model::source(json!([])); + let (registry, actions) = super::membership_targets::proposal(source, automatic); + let lockable = + crate::membership::lockable_membership_tables(registry.entities(), &actions); + assert_eq!(lockable.contains_key(&("clerk", "membership")), !automatic); + let before = super::proposal::target_policies( + ®istry.entities()["target"], + registry.actions(), + ); + let after = super::proposal::target_policies(®istry.entities()["target"], &actions); + assert_eq!(before.len(), after.len()); + let mut caller_checks = 0; + let mut system_checks = 0; + for (base, guarded) in before.iter().zip(&after) { + for (base, guarded) in base + .using_expression + .iter() + .chain(&base.check_expression) + .zip( + guarded + .using_expression + .iter() + .chain(&guarded.check_expression), + ) + { + if base.contains("'actorKind' = 'caller'") { + assert!(guarded.starts_with(&format!( + "({base}) AND registry_context.\"membership_target_" + ))); + caller_checks += 1; + } else { + assert_eq!(base, guarded); + system_checks += usize::from(base.contains("'system-proposal-apply'")); + } + } + } + assert!(caller_checks > 0); + assert_eq!(system_checks > 0, automatic); + } + } + + #[test] + fn the_membership_lock_helper_is_volatile_and_takes_for_share() { + let (registry, actions) = super::membership_targets::immediate(false); + let ddl = super::generate_ddl_with_actions( + registry.entities(), + registry.physical_names(), + &actions, + ); + let name = crate::membership::lock_function_name("registrar", "membership"); + let mut helper = ddl + .statements + .iter() + .filter(|statement| statement.id == format!("registry_context.{name}")); + let sql = &helper.next().unwrap().sql; + assert!(helper.next().is_none()); + assert!(sql.contains("(uuid) RETURNS boolean LANGUAGE plpgsql VOLATILE STRICT SECURITY INVOKER SET search_path = pg_catalog")); + assert!(sql.contains("ORDER BY membership.record_id FOR SHARE; authorized := FOUND")); + } + #[cfg(feature = "runtime")] #[test] fn an_added_required_column_carries_its_requiredness_in_a_separate_statement() { diff --git a/crates/registry-breg/src/history_maintenance.rs b/crates/registry-breg/src/history_maintenance.rs index fce1dc16a2..24342131b5 100644 --- a/crates/registry-breg/src/history_maintenance.rs +++ b/crates/registry-breg/src/history_maintenance.rs @@ -65,6 +65,7 @@ impl From for HistoryMaintenanceError { | PostgresKernelError::DatabaseTransport(_) | PostgresKernelError::FieldPatternSyntax { .. } | PostgresKernelError::FieldPatternExistingRows { .. } + | PostgresKernelError::MembershipDuplicateLiveRows { .. } | PostgresKernelError::FieldEncryptionBlindCollision { .. } | PostgresKernelError::FieldEncryptionRetainedProposalSnapshots { .. } | PostgresKernelError::BlindIndexReindexRowLimit { .. } => Self::InvalidInput, diff --git a/crates/registry-breg/src/history_schema.rs b/crates/registry-breg/src/history_schema.rs index e9454ca13b..26fd486a78 100644 --- a/crates/registry-breg/src/history_schema.rs +++ b/crates/registry-breg/src/history_schema.rs @@ -847,6 +847,7 @@ mod tests { change_control: None, classification: Classification::Restricted, access_requirements: None, + membership: None, access_log: None, disclosure_conditions: Vec::new(), geojson: None, diff --git a/crates/registry-breg/src/immediate_actions.rs b/crates/registry-breg/src/immediate_actions.rs index bb474dc6a7..de1749e63d 100644 --- a/crates/registry-breg/src/immediate_actions.rs +++ b/crates/registry-breg/src/immediate_actions.rs @@ -305,6 +305,21 @@ fn compile_action( errors, ); if let crate::contract::ActionExecutionSource::Proposal { proposal } = &action.execution { + // Submit reads the subject field of the referenced Record, like a + // commit guard reads its field. + if let Some(crate::contract::ProposalSubjectSource { + input, + field: Some(field), + }) = &proposal.subject + { + if let Some(binding) = input_map.get(input.as_str()) { + if let FieldTypeSource::Reference { .. } = &binding.field_type { + if let Some(existing) = target_uses.iter_mut().find(|use_| use_.operation == Operation::Get && matches!(&use_.source, CompiledActionTargetUseSource::Input { input: selected } if selected == input)) { + existing.fields.insert(field.clone()); + } + } + } + } if let Some(context) = &proposal.review_context { for projection in context.fields.values() { if let crate::contract::ProposalContextValueSource::Record { input, field } = @@ -2433,7 +2448,8 @@ fn compile_permissions( "Action permissions support only the invoke operation", )); } - let target_locks = compile_permission_targets(entities, profile, grant, errors); + let target_locks = + compile_permission_targets(entities, profile, grant, target_uses, errors); validate_permission_covers_uses(&target_locks, target_uses, errors); let targets = discriminate_permission_targets(&target_locks, target_uses, errors); for result in grant.results.iter() { @@ -2487,12 +2503,14 @@ fn validate_action_permission_sources( struct PermissionTargetLock { entity_id: String, row_boundaries: Vec, + membership_boundaries: Vec, } fn compile_permission_targets( entities: &BTreeMap, profile: &ProjectAccessProfileSource, grant: &crate::contract::ActionPermissionSource, + target_uses: &[CompiledActionTargetUse], errors: &mut Vec, ) -> Vec { let mut seen = BTreeSet::new(); @@ -2526,15 +2544,63 @@ fn compile_permission_targets( "project.accessProfiles[].permissions.actions[].targets", errors, ); + let writes = target_uses.iter().any(|use_| { + use_.entity_id == target.entity && crate::membership::is_record_write(use_.operation) + }); + let membership_boundaries = compile_target_memberships( + entities, profile, entity, &target.row_boundaries, &target.membership_row_boundaries, + true, + writes, + &format!("accessProfiles[id={}].permissions.actions[action={}].targets[recordType={}].rowBoundaries", profile.id, grant.action, target.entity), + errors, + ); targets.push(PermissionTargetLock { entity_id: target.entity.clone(), row_boundaries: target.row_boundaries.clone(), + membership_boundaries, }); } targets.sort_by(|left, right| left.entity_id.cmp(&right.entity_id)); targets } +#[allow(clippy::too_many_arguments)] +fn compile_target_memberships( + entities: &BTreeMap, + profile: &ProjectAccessProfileSource, + entity: &CompiledEntity, + row_boundaries: &[RowBoundarySource], + entries: &[crate::contract::MembershipRowBoundarySource], + write_grant: bool, + writes_record: bool, + location: &str, + errors: &mut Vec, +) -> Vec { + crate::membership::validate_write_admission( + profile.required_scopes.is_empty(), + profile.requester_clients.is_empty(), + &profile.principal_claim, + write_grant, + writes_record && entity.membership.is_some(), + row_boundaries, + !entries.is_empty(), + location, + errors, + ); + entries + .iter() + .filter_map( + |entry| match crate::membership::resolve_entry(entry, entities, location) { + Ok((physical, _)) => Some(physical), + Err(error) => { + errors.push(error); + None + } + }, + ) + .collect() +} + fn discriminate_permission_targets( target_locks: &[PermissionTargetLock], target_uses: &[CompiledActionTargetUse], @@ -2553,6 +2619,7 @@ fn discriminate_permission_targets( operation: target_use.operation, source: target_use.source.clone(), row_boundaries: target_lock.row_boundaries.clone(), + membership_boundaries: target_lock.membership_boundaries.clone(), }); } if !matched { @@ -3027,6 +3094,177 @@ pub(crate) fn hex_lower(bytes: &[u8]) -> String { out } +fn party_label(party: Option) -> &'static str { + match party { + Some(crate::contract::ProposalParty::Owner) => "`party: owner`", + Some(crate::contract::ProposalParty::Subject) => "`party: subject`", + None => "an entry without `party`", + } +} + +/// The operations a subject entry may hold. The subject follows work someone +/// else filed: it reads, answers, adds files and withdraws, and never changes +/// what was filed. +const SUBJECT_OPERATIONS: [crate::contract::ProposalOperation; 6] = [ + crate::contract::ProposalOperation::Get, + crate::contract::ProposalOperation::List, + crate::contract::ProposalOperation::GetReviewStatus, + crate::contract::ProposalOperation::Answer, + crate::contract::ProposalOperation::Add, + crate::contract::ProposalOperation::Cancel, +]; + +fn validate_proposal_subject( + action: &ActionSource, + entities: &BTreeMap, + subject: &crate::contract::ProposalSubjectSource, + errors: &mut Vec, +) { + let path = format!("actions[id={}].execution.proposal.subject", action.id); + let Some(input) = action.inputs.iter().find(|input| input.id == subject.input) else { + errors.push(Diagnostic::error( + "breg.proposal.subject-input-unknown", + format!("{path}.input"), + &format!( + "the subject input `{}` is not an input of Action `{}`", + subject.input, action.id + ), + )); + return; + }; + if !input.required { + errors.push(Diagnostic::error( + "breg.proposal.subject-input-optional", + format!("{path}.input"), + &format!( + "the subject input `{}` must be required, so every submitted Proposal names its subject", + input.id + ), + )); + } + match (&subject.field, &input.field_type) { + ( + None, + FieldTypeSource::String { .. } | FieldTypeSource::Text { .. } | FieldTypeSource::Uuid, + ) => {} + (Some(field), FieldTypeSource::Reference { target, .. }) => { + let plaintext = entities + .get(target) + .and_then(|entity| entity.fields.get(field)) + .is_some_and(|declared| { + declared.encryption.is_none() + && matches!( + declared.field_type, + FieldTypeSource::String { .. } | FieldTypeSource::Text { .. } + ) + }); + if !plaintext { + errors.push(Diagnostic::error( + "breg.proposal.subject-field-type", + format!("{path}.field"), + &format!( + "the subject field `{field}` must be a plaintext string or text field of Record type `{target}`" + ), + )); + } + } + (None, _) => errors.push(Diagnostic::error( + "breg.proposal.subject-input-type", + format!("{path}.input"), + &format!( + "the subject input `{}` must be a string, text or uuid input; to read the subject from a referenced Record, add `field`", + input.id + ), + )), + (Some(_), _) => errors.push(Diagnostic::error( + "breg.proposal.subject-input-type", + format!("{path}.input"), + &format!( + "a subject `field` is read through a reference input, and `{}` is not one", + input.id + ), + )), + } +} + +fn validate_party_grant( + action: &ActionSource, + profile: &ProjectAccessProfileSource, + grant: &crate::contract::ProposalPermissionSource, + subject_declared: bool, + errors: &mut Vec, +) { + use crate::contract::{ProposalOperation, ProposalParty}; + let path = format!( + "accessProfiles[id={}].permissions.proposals[action={}]", + profile.id, action.id + ); + if grant.submits_for.is_some() + && (!grant.operations.contains(&ProposalOperation::Submit) || !subject_declared) + { + errors.push(Diagnostic::error( + "breg.proposal.submits-for-invalid", + format!("{path}.submitsFor"), + &format!( + "`submitsFor` lets a Submit name someone else as the subject: it needs `submit` in the same entry and `execution.proposal.subject` on Action `{}`", + action.id + ), + )); + } + if grant.party != Some(ProposalParty::Subject) { + return; + } + if !subject_declared { + errors.push(Diagnostic::error( + "breg.proposal.subject-undeclared", + format!("{path}.party"), + &format!( + "access profile `{}` holds a `party: subject` entry, but Action `{}` declares no `execution.proposal.subject`", + profile.id, action.id + ), + )); + } + let forbidden = grant + .operations + .iter() + .filter(|operation| !SUBJECT_OPERATIONS.contains(operation)) + .map(|operation| operation.as_str()) + .collect::>(); + if !forbidden.is_empty() { + errors.push(Diagnostic::error( + "breg.proposal.subject-operation-forbidden", + format!("{path}.operations"), + &format!( + "a `party: subject` entry cannot hold {}. The subject may hold only get, list, get-review-status, answer, add and cancel", + forbidden.join(", ") + ), + )); + } + if !matches!( + profile.actor_kind, + None | Some(crate::contract::ActorKindSource::Human) + ) { + errors.push(Diagnostic::error( + "breg.proposal.permission-invalid", + format!("{path}.party"), + &format!( + "a `party: subject` entry is for people: access profile `{}` must set `actorKind: human` or leave it unset", + profile.id + ), + )); + } + if profile.required_scopes.is_empty() + && profile.requester_clients.is_empty() + && profile.principal_claim != "sub" + { + errors.push(Diagnostic::error( + "breg.access.open-subject-principal-not-sub", + format!("accessProfiles[id={}].principalClaim", profile.id), + "An open profile with a `party: subject` entry must set principalClaim to sub.", + )); + } +} + fn compile_execution( action: &ActionSource, entities: &BTreeMap, @@ -3126,6 +3364,10 @@ fn compile_execution( } } }; + let subject = proposal.subject.as_ref().map(|subject| { + validate_proposal_subject(action, entities, subject, errors); + subject.clone() + }); let mut permissions = Vec::new(); for profile in profiles { for grant in profile @@ -3135,6 +3377,7 @@ fn compile_execution( .filter(|grant| grant.action == action.id) { crate::consent::validate_proposal_permission(profile, grant, entities, errors); + validate_party_grant(action, profile, grant, subject.is_some(), errors); if application.is_automatic() && grant.operations.iter().any(|operation| { matches!( @@ -3163,7 +3406,8 @@ fn compile_execution( || !grant .operations .contains(&ProposalOperation::GetReviewStatus) - || grant.ownership.is_some() + || grant.party.is_some() + || grant.submits_for.is_some() || !grant.targets.is_empty() || !grant.readable_context_fields.is_empty() || !grant.readable_inputs.is_empty() @@ -3185,12 +3429,12 @@ fn compile_execution( || !grant .operations .contains(&ProposalOperation::GetReviewStatus) - || grant.ownership != Some(ProposalOwnership::Caller)) + || grant.party.is_none()) { errors.push(Diagnostic::error( "breg.proposal.review-progress-grant-invalid", "accessProfiles[].permissions.proposals[].readableReviewProgress", - "review progress requires caller-owned GetReviewStatus authority for an Action with required review, and cannot be enabled on the named review-authority service grant", + "review progress requires party-bound GetReviewStatus authority for an Action with required review, and cannot be enabled on the named review-authority service grant", )); } @@ -3202,21 +3446,42 @@ fn compile_execution( ProposalOperation::Edit | ProposalOperation::GetReviewContext ) }) || (grant.operations.contains(&ProposalOperation::Edit) - && grant.ownership != Some(ProposalOwnership::Caller))) + && grant.party != Some(ProposalParty::Owner))) { errors.push(Diagnostic::error("breg.proposal.standing-agent-operation-forbidden", "accessProfiles[].permissions.proposals", "an agent without a task grant can only start or edit caller-owned draft Proposals and read an explicitly bounded review context; other operations require task-grant or human authority")); } - if grant.operations.is_empty() - || permissions - .iter() - .any(|entry: &CompiledProposalPermission| entry.profile_id == profile.id) - { + if grant.operations.is_empty() { errors.push(Diagnostic::error( "breg.proposal.permission-invalid", "accessProfiles[].permissions.proposals", "Proposal grants require operations and one entry per Action", )); } + // One entry per party; an entry bound to no party governs the + // whole Action for its profile, so it stands alone. + if permissions + .iter() + .any(|entry: &CompiledProposalPermission| { + entry.profile_id == profile.id + && (entry.party == grant.party + || entry.party.is_none() + || grant.party.is_none()) + }) + { + errors.push(Diagnostic::error( + "breg.proposal.permission-invalid", + format!( + "accessProfiles[id={}].permissions.proposals[action={}]", + profile.id, action.id + ), + &format!( + "access profile `{}` holds more than one Proposal entry for Action `{}` where the second is {}. Hold at most one entry for each party (`party: owner`, `party: subject`), and no entry without `party` beside them", + profile.id, + action.id, + party_label(grant.party), + ), + )); + } if grant .operations .contains(&ProposalOperation::GetApplicationActor) @@ -3259,9 +3524,27 @@ fn compile_execution( "accessProfiles[].permissions.proposals[].targets", errors, ); + let write_grant = grant + .operations + .iter() + .copied() + .any(crate::membership::is_proposal_write); + let writes = write_grant + && target_uses.iter().any(|use_| { + use_.entity_id == target.record_type + && crate::membership::is_record_write(use_.operation) + }); + let membership_boundaries = compile_target_memberships( + entities, profile, entity, &target.row_boundaries, &target.membership_row_boundaries, + write_grant, + writes, + &format!("accessProfiles[id={}].permissions.proposals[action={}].targets[recordType={}].rowBoundaries", profile.id, grant.action, target.record_type), + errors, + ); targets.push(CompiledProposalTargetPermission { entity_id: target.record_type.clone(), row_boundaries: target.row_boundaries.clone(), + membership_boundaries, }); } if !authority_status @@ -3421,7 +3704,8 @@ fn compile_execution( required_scopes: profile.required_scopes.as_set().clone(), required_purposes: profile.required_purposes.as_set().clone(), operations: grant.operations.as_set().clone(), - ownership: grant.ownership, + party: grant.party, + submits_for_anyone: grant.submits_for == Some(ProposalSubmitsFor::Anyone), targets, readable_context_fields: grant.readable_context_fields.as_set().clone(), readable_inputs: grant.readable_inputs.as_set().clone(), @@ -3520,6 +3804,7 @@ fn compile_execution( additions: proposal.additions.clone(), promotions: Vec::new(), permissions, + subject, }, } } @@ -3834,6 +4119,11 @@ pub(crate) fn definition_revision( if let Some(slot) = &proposal.additions { policy["additions"] = json!(slot); } + // The subject decides who may follow frozen work, so declaring + // or moving it changes the Action. Omitted when undeclared. + if let Some(subject) = &proposal.subject { + policy["subject"] = json!(subject); + } // Promotions change what an approved Proposal writes, so they are // part of the Action's identity. Omitting an empty list keeps the // revision of every Action without promotions unchanged. @@ -3875,3 +4165,86 @@ pub(crate) fn definition_revision( )) ) } + +#[cfg(test)] +mod membership_target_tests { + use super::*; + use crate::compiler::{compile_project, CompileProfile}; + use crate::contract::{parse_project_json, MembershipRowBoundarySource}; + use serde_json::json; + + fn project() -> (crate::contract::RegistryProject, crate::CompiledRegistry) { + let mut source = crate::proposal_hooks::test_model::source(json!([])); + let fixture: serde_json::Value = serde_json::from_str(include_str!( + "../../../products/breg/fixtures/organization-membership-access/registry.yaml" + )) + .unwrap(); + for id in ["membership", "organization"] { + source["recordTypes"][id] = fixture["recordTypes"][id].clone(); + source["recordTypes"][id]["primaryDataset"] = json!("directory"); + } + source["recordTypes"]["membership"]["accessRequirements"]["requiredScopes"] = + json!(["proposal:manage"]); + source["recordTypes"]["target"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"organization","type":"reference","target":"organization","classification":"internal"})); + let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); + let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); + (project, registry) + } + + fn entry() -> MembershipRowBoundarySource { + MembershipRowBoundarySource { + field: "organization".into(), + membership: "membership".into(), + } + } + + #[test] + fn an_action_target_membership_entry_reaches_every_discriminated_use() { + let (mut project, registry) = project(); + let profile = &mut project.access_profiles[0]; + profile.permissions.actions[0].targets[0].membership_row_boundaries = vec![entry()]; + let uses = ®istry.actions().actions[0].target_uses; + let mut errors = Vec::new(); + let locks = compile_permission_targets( + registry.entities(), + profile, + &profile.permissions.actions[0], + uses, + &mut errors, + ); + let targets = discriminate_permission_targets(&locks, uses, &mut errors); + assert!(targets.len() > 1); + assert!(targets.iter().all(|target| { + target.membership_boundaries.len() == 1 + && target.membership_boundaries[0].membership_entity == "membership" + })); + assert!(errors.is_empty(), "{errors:?}"); + } + + #[test] + fn a_proposal_target_membership_entry_reaches_the_compiled_target() { + let (mut project, registry) = project(); + let action = ®istry.actions().actions[0]; + project.access_profiles[0].permissions.proposals[0].targets[0].membership_row_boundaries = + vec![entry()]; + let mut errors = Vec::new(); + let execution = compile_execution( + &project.actions[0], + registry.entities(), + &project.access_profiles, + &project.review_authorities, + &action.target_uses, + &mut errors, + ); + let crate::model::CompiledActionExecution::Proposal { proposal } = execution else { + panic!("expected a Proposal"); + }; + let compiled = &proposal.permissions[0].targets[0].membership_boundaries; + assert_eq!(compiled.len(), 1); + assert_eq!(compiled[0].membership_entity, "membership"); + assert!(errors.is_empty(), "{errors:?}"); + } +} diff --git a/crates/registry-breg/src/ingestion_store.rs b/crates/registry-breg/src/ingestion_store.rs index 117c42d3e4..7edaf31c01 100644 --- a/crates/registry-breg/src/ingestion_store.rs +++ b/crates/registry-breg/src/ingestion_store.rs @@ -1619,7 +1619,7 @@ mod tests { {"id":"serial-code","apiName":"serialNumber","type":"string","maximumLength":64,"classification":"internal"} ] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["review"], "permissions":{"records":[{ "recordType":"entry","operations":["create"], @@ -1746,7 +1746,7 @@ mod tests { "datasets":{{"test-dataset": {{}}}},"recordTypes":{{"entry":{{"primaryDataset":"test-dataset","route":"entries","mutationMode":"mutable","classification":"internal", "fields":[{fields}] }}}}, - "accessProfiles":{{"operator":{{"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{{"operator":{{"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["review"], "permissions":{{"records":[{{ "recordType":"entry","operations":["create"], diff --git a/crates/registry-breg/src/lib.rs b/crates/registry-breg/src/lib.rs index fd492a52dd..b8fe655feb 100644 --- a/crates/registry-breg/src/lib.rs +++ b/crates/registry-breg/src/lib.rs @@ -155,6 +155,7 @@ mod proposal_prepare; pub mod proposal_retention; #[cfg(feature = "runtime")] mod proposal_store; +pub(crate) mod proposal_subject; pub mod proposal_workflow; pub mod query; #[cfg(feature = "runtime")] diff --git a/crates/registry-breg/src/membership.rs b/crates/registry-breg/src/membership.rs index 522bf756f4..0d6968a7a0 100644 --- a/crates/registry-breg/src/membership.rs +++ b/crates/registry-breg/src/membership.rs @@ -1,27 +1,65 @@ // SPDX-License-Identifier: Apache-2.0 //! One-hop current membership checks over governed stored records. -use std::collections::BTreeMap; -#[cfg(feature = "runtime")] -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; -use crate::contract::{EntitySource, FieldTypeSource, Operation}; +use crate::contract::{ + ActionPlanSource, ActionSource, EntitySource, ExpandedMembershipBoundarySource, + FieldTypeSource, MembershipBoundarySource, MembershipDeclarationSource, + MembershipRowBoundarySource, Operation, ProposalOperation, RegistryProject, RowBoundarySource, +}; use crate::diagnostics::Diagnostic; use crate::generated_ddl::{quote_identifier, quote_literal}; -use crate::model::{CompiledEntity, CompiledMembershipBoundary}; +use crate::model::{ + CompiledActionExecution, CompiledActionInventory, CompiledEntity, CompiledMembershipBoundary, +}; use crate::physical_names::hex_prefix; use sha2::{Digest, Sha256}; -pub(crate) fn validate(entities: &BTreeMap, errors: &mut Vec) { +/// The canonical identifier every Record type carries. As a membership +/// boundary field it names the protected row's own `record_id`. +pub(crate) const CANONICAL_ID: &str = "id"; + +pub(crate) fn validate( + project: &RegistryProject, + actions: &BTreeMap, + entities: &BTreeMap, + errors: &mut Vec, +) { for entity in entities.values() { + validate_declaration(project, entity, entities, errors); for profile in &entity.access_profiles { - if profile.membership_boundaries.is_empty() { - continue; - } let location = format!( - "recordTypes[id={}].accessProfiles[id={}].membershipBoundaries", + "recordTypes[id={}].accessProfiles[id={}].rowBoundaries", entity.id, profile.id ); + let has_membership = !profile.membership_boundaries.is_empty(); + let writes = profile.operations.iter().copied().any(is_record_write); + let writes_membership = entity.membership.is_some() + && (writes + || profile.operations.contains(&Operation::Import) + || profile.operations.contains(&Operation::Batch)); + validate_write_admission( + profile.required_scopes.is_empty(), + profile.requester_clients.is_empty(), + &profile.principal_claim, + writes, + writes_membership, + &profile.row_boundaries, + has_membership, + &location, + errors, + ); + if !has_membership { + continue; + } + if profile.operations.contains(&Operation::Import) { + errors.push(Diagnostic::error( + "breg.access.membership-import-unsupported", + &location, + "Import grants cannot use a membership entry in rowBoundaries.", + )); + } if profile.operations.iter().any(|operation| { !matches!( operation, @@ -30,112 +68,41 @@ pub(crate) fn validate(entities: &BTreeMap, errors: &mut V | Operation::List | Operation::Revisions | Operation::Snapshot + | Operation::Create + | Operation::Patch + | Operation::Tombstone + | Operation::Batch + | Operation::Import ) - }) || !profile.writable_fields.is_empty() + }) || (!profile.writable_fields.is_empty() + && !writes + && !profile.operations.contains(&Operation::Import)) { - errors.push(Diagnostic::error("breg.access.membership-read-only", &location, - "membership boundaries support get, lookup, list, revisions and snapshot only; use a separate directly authorized profile for writes and proposal application")); + refuse_membership_write(&location, errors); } if profile.spatial_queries.is_some() { errors.push(Diagnostic::error("breg.access.membership-spatial-unsupported", &location, "spatial bbox uses a separate database authority role; use a directly authorized bbox profile or ordinary membership-filtered reads")); } - if profile.membership_boundaries.len() > 8 { - errors.push(Diagnostic::error( - "breg.access.membership-limit", - &location, - "declare at most eight one-hop membership boundaries", - )); - } - for (index, boundary) in profile.membership_boundaries.iter().enumerate() { - let path = format!("{location}[{index}]"); - if profile.membership_boundaries[..index].contains(boundary) { - errors.push(Diagnostic::error( - "breg.access.membership-duplicate", - &path, - "each membership boundary must be unique", - )); - } - let Some(membership) = entities.get(&boundary.membership_entity) else { - errors.push(Diagnostic::error( - "breg.access.membership-entity-unknown", - &path, - "membershipRecordType must name a governed Record type", - )); - continue; - }; - let root_field = entity - .fields - .iter() - .find(|field| field.id == boundary.field); - let key_field = membership - .fields - .iter() - .find(|field| field.id == boundary.membership_key_field); - let matching = match (root_field, key_field) { - (Some(root), Some(key)) => matches!((&root.field_type, &key.field_type), - (FieldTypeSource::Reference { target: a, .. }, FieldTypeSource::Reference { target: b, .. }) if a == b), - _ => false, - }; - if !matching { - errors.push(Diagnostic::error( - "breg.access.membership-key-type", - &path, - "field and membershipKeyField must be stored references to the same entity", - )); - } - if !membership.fields.iter().any(|field| { - field.id == boundary.principal_field - && matches!( - field.field_type, - FieldTypeSource::String { .. } | FieldTypeSource::Text { .. } - ) - }) { - errors.push(Diagnostic::error("breg.access.membership-principal-type", &path, - "principalField must be a stored string or text field matching the verified principal")); - } - // The membership predicate compares the principal column to the - // verified plaintext principal, so ciphertext can never match. - if membership - .fields - .iter() - .any(|field| field.id == boundary.principal_field && field.encrypted) - { - errors.push(Diagnostic::error("breg.access.membership-principal-encrypted", &path, - "principalField must be a plaintext stored field; an encrypted field cannot match the verified principal")); - } - if !membership.fields.iter().any(|field| { - field.id == boundary.active_field - && matches!(field.field_type, FieldTypeSource::Boolean) - }) { - errors.push(Diagnostic::error("breg.access.membership-active-type", &path, - "activeField must be a stored Boolean field; only true memberships authorize access")); - } - // A membership source is a leaf authorization fact. Its own RLS must - // never traverse back into the protected root, even through an OR arm. - if membership.id == entity.id - || membership - .access_profiles - .iter() - .any(|candidate| !candidate.membership_boundaries.is_empty()) - || entities.values().any(|candidate| { - candidate - .read_paths - .iter() - .any(|path| path.through == membership.id || path.to == membership.id) - }) - { - errors.push(Diagnostic::error("breg.access.membership-source-recursive", &path, - "membership sources must be ordinary leaf entities without membership boundaries or incoming read paths; use a separate membership fact entity")); - } - if let Some(requirements) = &membership.access_requirements { - let mut processing = requirements.clone(); - processing.row_boundaries.clear(); - crate::access::check_profile(&processing, profile, &path, errors); - if !requirements.row_boundaries.is_empty() { - errors.push(Diagnostic::error("breg.access.membership-source-row-requirement", &path, - "membership source row requirements cannot be inferred from a root profile; use its mandatory scopes and purposes with the fixed principal membership predicate")); - } + let entries = profile + .membership_boundaries + .iter() + .map(MembershipBoundarySource::entry) + .collect::>(); + let writes_rows = writes + || profile.operations.contains(&Operation::Batch) + || profile.operations.contains(&Operation::Import); + for source in + validate_entries(entity, &entries, writes_rows, entities, &location, errors) + { + if let Some(requirements) = &source.access_requirements { + crate::access::check_profile_authority( + requirements, + &profile.required_scopes, + &profile.required_purposes, + &location, + errors, + ); } } } @@ -158,53 +125,1007 @@ pub(crate) fn validate(entities: &BTreeMap, errors: &mut V } } } + validate_target_entries(project, actions, entities, errors); + validate_source_writes(project, actions, entities, errors); + validate_source_key_writes(project, actions, entities, errors); +} + +fn refuse_source_key_write(location: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.access.membership-source-key-write", + location, + "Change a membership source's key, principal or active flag through an Action whose reference target grant you scope, or through an unrestricted grant. A bounded grant can only deactivate an existing row.", + )); +} + +/// Whether a plan can decide who a row of `source` names, or for which key, +/// other than by a create whose key comes from a reference input: a function +/// ceiling over the key, principal or active field, a key set any other way, +/// a principal set on an existing row, or an existing row's active flag set +/// to anything but a fixed `false`. +fn plan_sets_key_unchecked( + action: &ActionSource, + source: &str, + declaration: &MembershipDeclarationSource, +) -> bool { + let reference_input = |input: &str| { + action.inputs.iter().any(|candidate| { + candidate.id == input + && matches!(candidate.field_type, FieldTypeSource::Reference { .. }) + }) + }; + match &action.plan { + ActionPlanSource::Fixed { effects } => effects + .iter() + .filter(|effect| writes_target(action, &effect.target, source)) + .any(|effect| { + effect.set.iter().any(|(field, value)| { + if *field == declaration.key { + // Defence in depth: compiling the plan already requires + // a reference field to come from a reference input or + // an earlier create, so no test reaches this arm alone. + !(value.from_field.as_deref().is_some_and(reference_input) + || value.from_effect.is_some()) + } else if effect.operation == Operation::Create { + false + } else if *field == declaration.principal { + true + } else { + *field == declaration.active + && !(value.from_field.is_none() + && value.from_effect.is_none() + && value.value == Some(serde_json::Value::Bool(false))) + } + }) + }), + ActionPlanSource::Function { writes, .. } => writes + .iter() + .filter(|ceiling| writes_target(action, &ceiling.target, source)) + .any(|ceiling| { + ceiling.fields.iter().any(|field| { + *field == declaration.key + || *field == declaration.principal + || *field == declaration.active + }) + }), + } +} + +/// Whether a grant is bounded, yet not on the source's key: by claims, or by +/// a membership entry on another field. Neither checks which key it writes. +/// A grant with no boundary at all is unrestricted by the author's choice. +fn bounded_off_key( + rows: &[RowBoundarySource], + membership_fields: &[String], + declaration: &MembershipDeclarationSource, +) -> bool { + (!rows.is_empty() || !membership_fields.is_empty()) + && !bounds_key(membership_fields.iter().cloned(), declaration) +} + +/// A grant bounded only by claims on a membership source's own row cannot +/// choose which key, or for whom, that row grants authority. +fn validate_source_key_writes( + project: &RegistryProject, + actions: &BTreeMap, + entities: &BTreeMap, + errors: &mut Vec, +) { + for source in entities.values() { + let Some(declaration) = &source.membership else { + continue; + }; + let fields = probe_fields(declaration); + for grant in &source.access_profiles { + let entries = grant + .membership_boundaries + .iter() + .map(|boundary| boundary.entry().field) + .collect::>(); + if !bounded_off_key(&grant.row_boundaries, &entries, declaration) { + continue; + } + let location = format!( + "recordTypes[id={}].accessProfiles[id={}]", + source.id, grant.id + ); + if grant.operations.iter().any(|operation| { + matches!( + operation, + Operation::Create | Operation::Batch | Operation::Import + ) + }) { + refuse_source_key_write(&format!("{location}.operations"), errors); + } else if grant.operations.contains(&Operation::Patch) + && grant + .writable_fields + .iter() + .any(|field| fields.contains(&field.as_str())) + { + // A Patch of the active flag can set it back to true. + refuse_source_key_write(&format!("{location}.writableFields"), errors); + } + } + let target_bounded_off_key = + |rows: &[RowBoundarySource], entries: &[MembershipRowBoundarySource]| { + let fields = entries + .iter() + .map(|entry| entry.field.clone()) + .collect::>(); + bounded_off_key(rows, &fields, declaration) + }; + for profile in &project.access_profiles { + let action_grants = profile.permissions.actions.iter().map(|grant| { + ( + "actions", + grant.action.as_str(), + grant + .targets + .iter() + .find(|target| target.entity == source.id) + .map(|target| { + target_bounded_off_key( + &target.row_boundaries, + &target.membership_row_boundaries, + ) + }), + ) + }); + let proposal_grants = profile + .permissions + .proposals + .iter() + .filter(|grant| grant.operations.iter().copied().any(is_proposal_write)) + .map(|grant| { + ( + "proposals", + grant.action.as_str(), + grant + .targets + .iter() + .find(|target| target.record_type == source.id) + .map(|target| { + target_bounded_off_key( + &target.row_boundaries, + &target.membership_row_boundaries, + ) + }), + ) + }); + for (surface, action, bounded) in action_grants.chain(proposal_grants) { + if bounded == Some(true) + && actions.get(action).is_some_and(|collected| { + plan_sets_key_unchecked(&collected.source, &source.id, declaration) + }) + { + refuse_source_key_write( + &format!( + "accessProfiles[id={}].permissions.{surface}[action={action}].targets[recordType={}]", + profile.id, source.id + ), + errors, + ); + } + } + } + } } -pub(crate) fn compile(entities: &mut BTreeMap) { - let resolved = entities +/// The fields a membership probe reads on its source row besides its +/// lifecycle, which only a tombstone changes and so only removes authority. +fn probe_fields(declaration: &MembershipDeclarationSource) -> [&str; 3] { + [ + declaration.key.as_str(), + declaration.principal.as_str(), + declaration.active.as_str(), + ] +} + +/// The membership sources any entry of `profile` bounds it through. +fn bounding_sources<'a>( + project: &'a RegistryProject, + entities: &'a BTreeMap, + profile: &str, +) -> BTreeSet { + let records = entities + .values() + .flat_map(|entity| &entity.access_profiles) + .filter(|grant| grant.id == profile) + .flat_map(|grant| &grant.membership_boundaries) + .map(|boundary| boundary.entry().membership); + let targets = project + .access_profiles .iter() - .map(|(id, entity)| { - let profiles = entity - .access_profiles + .filter(|candidate| candidate.id == profile) + .flat_map(|candidate| { + candidate + .permissions + .actions .iter() - .filter_map(|(profile_id, profile)| { - if profile.membership_boundaries.is_empty() { - return None; - } - let boundaries = profile - .membership_boundaries + .flat_map(|grant| &grant.targets) + .flat_map(|target| &target.membership_row_boundaries) + .chain( + candidate + .permissions + .proposals + .iter() + .flat_map(|grant| &grant.targets) + .flat_map(|target| &target.membership_row_boundaries), + ) + .map(|entry| entry.membership.clone()) + }); + records.chain(targets).collect() +} + +/// Whether a plan can give authority on `source`: create a row, or set a +/// field its probe reads to anything but a fixed `false` on the active flag. +fn plan_grants_authority( + action: &ActionSource, + source: &str, + declaration: &MembershipDeclarationSource, +) -> bool { + let fields = probe_fields(declaration); + let targets = + |target: &crate::contract::ActionTargetSource| writes_target(action, target, source); + match &action.plan { + ActionPlanSource::Fixed { effects } => effects + .iter() + .filter(|effect| targets(&effect.target)) + .any(|effect| { + // Defence in depth: a create must set the key, which the + // field check below already refuses. + effect.operation == Operation::Create + || effect.set.iter().any(|(field, value)| { + fields.contains(&field.as_str()) + && !(*field == declaration.active + && value.from_field.is_none() + && value.from_effect.is_none() + && value.value == Some(serde_json::Value::Bool(false))) + }) + }), + ActionPlanSource::Function { writes, .. } => writes + .iter() + .filter(|ceiling| targets(&ceiling.target)) + .any(|ceiling| { + ceiling.operation == Operation::Create + || ceiling + .fields + .iter() + .any(|field| fields.contains(&field.as_str())) + }), + } +} + +fn refuse_source_write(location: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.access.membership-source-write", + location, + "A profile bounded through a membership source cannot create its rows or write the key, principal or active field its probe reads, unless that write is itself bounded over a different membership source. A fixed active: false, a tombstone, or a field the probe does not read only removes authority and is admitted.", + )); +} + +/// A profile that a membership source bounds must not be able to give +/// itself, or anyone, authority through that source. +fn validate_source_writes( + project: &RegistryProject, + actions: &BTreeMap, + entities: &BTreeMap, + errors: &mut Vec, +) { + // A module can declare a profile on its Record types alone, so walk every + // profile id a grant can carry, not only the project's. + let profile_ids = project + .access_profiles + .iter() + .map(|profile| profile.id.as_str()) + .chain( + entities + .values() + .flat_map(|entity| &entity.access_profiles) + .map(|grant| grant.id.as_str()), + ) + .collect::>(); + for profile_id in profile_ids { + let profile = project + .access_profiles + .iter() + .find(|profile| profile.id == profile_id); + for source_id in bounding_sources(project, entities, profile_id) { + let Some((source, declaration)) = entities.get(&source_id).and_then(|source| { + source + .membership + .as_ref() + .map(|declaration| (source, declaration)) + }) else { + continue; + }; + let fields = probe_fields(declaration); + if let Some(grant) = source.access_profiles.iter().find(|grant| { + grant.id == profile_id + && !bounds_key( + grant + .membership_boundaries + .iter() + .map(|boundary| boundary.entry().field), + declaration, + ) + }) { + let location = format!( + "recordTypes[id={}].accessProfiles[id={}]", + source.id, grant.id + ); + if grant.operations.iter().any(|operation| { + matches!( + operation, + Operation::Create | Operation::Batch | Operation::Import + ) + }) { + refuse_source_write(&format!("{location}.operations"), errors); + } else if grant.operations.contains(&Operation::Patch) + && grant + .writable_fields + .iter() + .any(|field| fields.contains(&field.as_str())) + { + refuse_source_write(&format!("{location}.writableFields"), errors); + } + } + // Action and Proposal grants exist on project profiles only. + let Some(profile) = profile else { + continue; + }; + let key_bounded = |entries: &[MembershipRowBoundarySource]| { + bounds_key(entries.iter().map(|entry| entry.field.clone()), declaration) + }; + let action_grants = profile.permissions.actions.iter().map(|grant| { + ( + "actions", + grant.action.as_str(), + grant + .targets .iter() - .map(|boundary| { - let source = &entities[&boundary.membership_entity]; - CompiledMembershipBoundary { - field: boundary.field.clone(), - membership_entity: source.id.clone(), - membership_table: source.physical_table.clone(), - membership_key_column: source.fields - [&boundary.membership_key_field] - .physical_name - .clone(), - principal_column: source.fields[&boundary.principal_field] - .physical_name - .clone(), - active_column: source.fields[&boundary.active_field] - .physical_name - .clone(), - } - }) - .collect(); - Some((profile_id.clone(), boundaries)) + .find(|target| target.entity == source.id) + .map(|target| !key_bounded(&target.membership_row_boundaries)), + ) + }); + let proposal_grants = profile + .permissions + .proposals + .iter() + .filter(|grant| grant.operations.iter().copied().any(is_proposal_write)) + .map(|grant| { + ( + "proposals", + grant.action.as_str(), + grant + .targets + .iter() + .find(|target| target.record_type == source.id) + .map(|target| !key_bounded(&target.membership_row_boundaries)), + ) + }); + for (surface, action, unbounded) in action_grants.chain(proposal_grants) { + // A target whose key is bounded over another source is + // governed by the one-level rule; a missing target is + // refused elsewhere. + if unbounded == Some(true) + && actions.get(action).is_some_and(|collected| { + plan_grants_authority(&collected.source, &source.id, declaration) + }) + { + refuse_source_write( + &format!( + "accessProfiles[id={}].permissions.{surface}[action={action}].targets[recordType={}]", + profile.id, source.id + ), + errors, + ); + } + } + } + } +} + +/// Whether a membership entry among `fields` sits on the source's key. Only +/// such an entry checks which key a write sets; an entry on another field +/// bounds that field alone. +fn bounds_key( + mut fields: impl Iterator, + declaration: &MembershipDeclarationSource, +) -> bool { + fields.any(|field| field == declaration.key) +} + +fn validate_declaration( + project: &RegistryProject, + entity: &EntitySource, + entities: &BTreeMap, + errors: &mut Vec, +) { + let Some(declaration) = &entity.membership else { + return; + }; + let location = format!("recordTypes[id={}].membership", entity.id); + let field = |id: &str| entity.fields.iter().find(|field| field.id == id); + if !field(&declaration.key) + .is_some_and(|field| matches!(field.field_type, FieldTypeSource::Reference { .. })) + { + errors.push(Diagnostic::error( + "breg.access.membership-key-type", + &location, + &format!( + "membership.key must name a stored reference field, found {}", + declaration.key + ), + )); + } + let principal = field(&declaration.principal); + if !principal.is_some_and(|field| { + matches!( + field.field_type, + FieldTypeSource::String { .. } | FieldTypeSource::Text { .. } + ) + }) { + errors.push(Diagnostic::error( + "breg.access.membership-principal-type", + &location, + &format!( + "membership.principal must name a stored string or text field, found {}", + declaration.principal + ), + )); + } + // The membership predicate compares the principal column to the + // verified plaintext principal, so ciphertext can never match. + if principal.is_some_and(|field| field.encrypted) { + errors.push(Diagnostic::error( + "breg.access.membership-principal-encrypted", + &location, + &format!( + "membership.principal must name a plaintext stored field, found encrypted field {}", + declaration.principal + ), + )); + } + if !field(&declaration.active) + .is_some_and(|field| matches!(field.field_type, FieldTypeSource::Boolean)) + { + errors.push(Diagnostic::error( + "breg.access.membership-active-type", + &location, + &format!( + "membership.active must name a stored Boolean field, found {}", + declaration.active + ), + )); + } + // A membership source's own RLS must never traverse back into the + // protected root, even through an OR arm. It may be bounded one level + // over a different source that is itself a leaf, and no further. + // Consent is a probe too: a source whose grant requires consent from a + // consent record that membership bounds could need its own probe to + // evaluate the consent probe. + let requires_bounded_consent = entity.access_profiles.iter().any(|profile| { + profile + .require_consent + .iter() + .any(|requirement| has_membership_entries(project, entities, &requirement.record)) + }); + if has_incoming_read_path(entities, &entity.id) + || requires_bounded_consent + || entity.access_profiles.iter().any(|profile| { + profile.membership_boundaries.iter().any(|boundary| { + !is_leaf_over(project, entities, &entity.id, &boundary.entry().membership) + }) + }) + { + refuse_recursive(&location, errors); + } + if entity + .access_requirements + .as_ref() + .is_some_and(|requirements| !requirements.row_boundaries.is_empty()) + { + errors.push(Diagnostic::error("breg.access.membership-source-row-requirement", &location, + "Use mandatory scopes and purposes on the membership Record type. The membership predicate provides its row restriction.")); + } +} + +/// Whether `source` is a membership leaf that `root`, itself a membership +/// source, may be bounded over: a different Record type that declares +/// membership, has no incoming read paths, and is bounded by no membership +/// entry anywhere, as a Record grant or as an Action or Proposal target. +/// The `source != root` and read-path checks are defence in depth: a +/// self-reference already puts an entry on the source, and the leaf's own +/// declaration refuses an incoming read path. Tests reach them only through +/// those other checks. +fn is_leaf_over( + project: &RegistryProject, + entities: &BTreeMap, + root: &str, + source: &str, +) -> bool { + source != root + && entities + .get(source) + .is_some_and(|candidate| candidate.membership.is_some()) + && !has_incoming_read_path(entities, source) + && !has_membership_entries(project, entities, source) +} + +fn has_incoming_read_path(entities: &BTreeMap, id: &str) -> bool { + entities.values().any(|candidate| { + candidate + .read_paths + .iter() + .any(|path| path.through == id || path.to == id) + }) +} + +fn has_membership_entries( + project: &RegistryProject, + entities: &BTreeMap, + id: &str, +) -> bool { + entities.get(id).is_some_and(|entity| { + entity + .access_profiles + .iter() + .any(|profile| !profile.membership_boundaries.is_empty()) + }) || project.access_profiles.iter().any(|profile| { + profile + .permissions + .actions + .iter() + .flat_map(|grant| &grant.targets) + .any(|target| target.entity == id && !target.membership_row_boundaries.is_empty()) + || profile + .permissions + .proposals + .iter() + .flat_map(|grant| &grant.targets) + .any(|target| { + target.record_type == id && !target.membership_row_boundaries.is_empty() + }) + }) +} + +fn refuse_recursive(location: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.access.membership-source-recursive", + location, + "A Record type declaring membership must have no incoming read paths, cannot require consent from a consent record that membership bounds, and its membership row boundaries may only name a different membership source that has no membership row boundaries or incoming read paths.", + )); +} + +fn validate_entries<'a>( + entity: &EntitySource, + entries: &[MembershipRowBoundarySource], + writes_rows: bool, + entities: &'a BTreeMap, + location: &str, + errors: &mut Vec, +) -> Vec<&'a EntitySource> { + if entries.len() > 8 { + errors.push(Diagnostic::error( + "breg.access.membership-limit", + location, + "declare at most eight one-hop membership boundaries", + )); + } + let mut sources = Vec::new(); + for (index, entry) in entries.iter().enumerate() { + let site = format!( + "{location}[membership={}:field={}]", + entry.membership, entry.field + ); + if entries[..index].contains(entry) { + errors.push(Diagnostic::error( + "breg.access.membership-duplicate", + &site, + "each membership boundary must be unique", + )); + } + let Some((source, declaration)) = entities.get(&entry.membership).and_then(|source| { + source + .membership + .as_ref() + .map(|declaration| (source, declaration)) + }) else { + errors.push(Diagnostic::error( + "breg.access.membership-entity-unknown", + &site, + &format!( + "membership must name a Record type with a membership declaration, found {}", + entry.membership + ), + )); + continue; + }; + let root = entity.fields.iter().find(|field| field.id == entry.field); + let key = source + .fields + .iter() + .find(|field| field.id == declaration.key); + if entry.field == CANONICAL_ID && writes_rows { + // A create has no identifier to probe, and a write's key checks + // read stored fields. The identifier bounds reads and targets an + // Action or Proposal only references. + errors.push(Diagnostic::error( + "breg.access.membership-key-type", + &site, + "field id can bound only reads and Action or Proposal targets the plan does not write; bound writes by a stored reference field", + )); + } + if let Some(FieldTypeSource::Reference { target, .. }) = key.map(|key| &key.field_type) { + // The canonical identifier names the protected row itself, so it + // matches a key that references the protected Record type. + let matches = if entry.field == CANONICAL_ID { + *target == entity.id + } else { + root.is_some_and(|root| matches!( + &root.field_type, + FieldTypeSource::Reference { target: field_target, .. } if field_target == target + )) + }; + if !matches { + errors.push(Diagnostic::error( + "breg.access.membership-key-type", + &site, + &format!("field {} and membership.key {} must be stored references to the same Record type, or field must be id when membership.key references this Record type", entry.field, declaration.key), + )); + } + } + sources.push(source); + } + sources +} + +fn validate_target_entries( + project: &RegistryProject, + actions: &BTreeMap, + entities: &BTreeMap, + errors: &mut Vec, +) { + let hook_principals = entities + .values() + .flat_map(|entity| { + entity + .hooks + .iter() + .filter_map(|hook| hook.principal.as_deref()) + }) + .collect::>(); + let timer_actions = entities + .values() + .flat_map(|entity| entity.timers.iter().map(|timer| timer.invoke.as_str())) + .collect::>(); + for profile in &project.access_profiles { + let targets = profile + .permissions + .actions + .iter() + .flat_map(|grant| { + grant.targets.iter().map(move |target| { + ( + "actions", + grant.action.as_str(), + target.entity.as_str(), + &target.membership_row_boundaries, + &target.row_boundaries, + true, + ) + }) + }) + .chain(profile.permissions.proposals.iter().flat_map(|grant| { + grant.targets.iter().map(move |target| { + ( + "proposals", + grant.action.as_str(), + target.record_type.as_str(), + &target.membership_row_boundaries, + &target.row_boundaries, + grant.operations.iter().copied().any(is_proposal_write), + ) }) - .collect(); - (id.clone(), profiles) + })); + for (surface, action, id, entries, rows, write_grant) in targets { + // Invalid references receive the ordinary target diagnostics without + // embedding authored scalar values in admission paths. + if registry_platform_yaml::LocalId::new(action).is_err() + || registry_platform_yaml::LocalId::new(id).is_err() + { + continue; + } + let location = format!("accessProfiles[id={}].permissions.{surface}[action={action}].targets[recordType={id}].rowBoundaries", profile.id); + let declares_membership = entities + .get(id) + .is_some_and(|entity| entity.membership.is_some()); + let plan_writes_target = actions + .get(action) + .is_some_and(|action| plan_writes(&action.source, id)); + let writes_membership = write_grant && declares_membership && plan_writes_target; + validate_write_admission( + profile.required_scopes.is_empty(), + profile.requester_clients.is_empty(), + &profile.principal_claim, + write_grant, + writes_membership, + rows, + !entries.is_empty(), + &location, + errors, + ); + if entries.is_empty() { + continue; + } + if declares_membership + && entries + .iter() + .any(|entry| !is_leaf_over(project, entities, id, &entry.membership)) + { + refuse_recursive(&format!("recordTypes[id={id}].membership"), errors); + } + if surface == "actions" && hook_principals.contains(profile.id.as_str()) { + errors.push(Diagnostic::error( + "breg.access.membership-hook-unsupported", + &location, + "A grant used by a hook cannot use a membership entry in rowBoundaries.", + )); + } + if timer_actions.contains(action) { + errors.push(Diagnostic::error( + "breg.access.membership-timer-unsupported", + &location, + "A grant used by a timer cannot use a membership entry in rowBoundaries.", + )); + } + if let Some(entity) = entities.get(id) { + for source in validate_entries( + entity, + entries, + plan_writes_target, + entities, + &location, + errors, + ) { + if let Some(requirements) = &source.access_requirements { + crate::access::check_profile_authority( + requirements, + &profile.required_scopes, + &profile.required_purposes, + &location, + errors, + ); + } + } + } + } + } +} + +pub(crate) fn is_proposal_write(operation: ProposalOperation) -> bool { + match operation { + ProposalOperation::Answer + | ProposalOperation::Edit + | ProposalOperation::Add + | ProposalOperation::Submit + | ProposalOperation::Revise + | ProposalOperation::Cancel + | ProposalOperation::Apply + | ProposalOperation::Rebase + | ProposalOperation::Retry => true, + ProposalOperation::Get + | ProposalOperation::List + | ProposalOperation::GetReviewStatus + | ProposalOperation::GetReviewContext + | ProposalOperation::GetTaskGrantContext + | ProposalOperation::GetApplicationActor => false, + } +} + +/// Whether an effect or write ceiling target names `entity`, directly or +/// through a reference input. +pub(crate) fn writes_target( + action: &ActionSource, + target: &crate::contract::ActionTargetSource, + entity: &str, +) -> bool { + match (&target.entity, &target.from_field) { + (Some(record_type), None) => record_type == entity, + (None, Some(input)) => action.inputs.iter().any(|candidate| { + candidate.id == *input + && matches!( + &candidate.field_type, FieldTypeSource::Reference { target, .. } if target == entity + ) + }), + _ => false, + } +} + +fn plan_writes(action: &ActionSource, entity: &str) -> bool { + let writes = |target: &crate::contract::ActionTargetSource, operation| { + is_record_write(operation) && writes_target(action, target, entity) + }; + match &action.plan { + ActionPlanSource::Fixed { effects } => effects + .iter() + .any(|effect| writes(&effect.target, effect.operation)), + ActionPlanSource::Function { + writes: ceilings, .. + } => ceilings + .iter() + .any(|ceiling| writes(&ceiling.target, ceiling.operation)), + } +} + +pub(crate) fn is_record_write(operation: Operation) -> bool { + matches!( + operation, + Operation::Create | Operation::Patch | Operation::Tombstone + ) +} + +fn refuse_open_membership_principal(location: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.access.open-membership-principal-not-sub", + location, + "An open profile with a membership entry must set principalClaim to sub.", + )); +} + +#[allow(clippy::too_many_arguments)] +pub(crate) fn validate_write_admission( + scopeless: bool, + unrestricted_clients: bool, + principal_claim: &str, + writes: bool, + writes_membership: bool, + row_boundaries: &[RowBoundarySource], + has_membership: bool, + location: &str, + errors: &mut Vec, +) { + let open = scopeless && unrestricted_clients; + if open && has_membership && principal_claim != "sub" { + refuse_open_membership_principal(location, errors); + } + if open + && writes + && !has_membership + && !row_boundaries + .iter() + .any(|row| row.claim == principal_claim) + { + errors.push(Diagnostic::error( + "breg.access.open-write-without-principal-boundary", + location, + "An open profile must bound each write target with a membership entry or a row boundary on its principalClaim.", + )); + } + if scopeless && writes_membership { + errors.push(Diagnostic::error( + "breg.access.scopeless-membership-source-write", + location, + "A profile that admits tokens without scopes cannot write a Record type that declares membership.", + )); + } +} + +pub(crate) fn refuse_membership_write(location: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.access.membership-read-only", + location, + "Membership entries cannot authorize this operation. Use a separately authorized profile.", + )); +} + +pub(crate) fn resolve_entry( + entry: &MembershipRowBoundarySource, + entities: &BTreeMap, + location: &str, +) -> Result<(CompiledMembershipBoundary, ExpandedMembershipBoundarySource), Diagnostic> { + let source = entities + .get(&entry.membership) + .and_then(|source| { + source + .membership + .as_ref() + .map(|declaration| (source, declaration)) }) - .collect::>(); - for (id, boundaries) in resolved { - entities - .get_mut(&id) - .expect("compiled entity") - .membership_boundaries = boundaries; + .ok_or_else(|| { + Diagnostic::error( + "breg.access.membership-entity-unknown", + location, + &format!( + "membership must name a Record type with a membership declaration, found {}", + entry.membership + ), + ) + })?; + let (source, declaration) = source; + let column = |name: &str, field: &str, code| { + source + .fields + .get(field) + .map(|field| field.physical_name.clone()) + .ok_or_else(|| { + Diagnostic::error( + code, + location, + &format!("membership.{name} names missing field {field}"), + ) + }) + }; + Ok(( + CompiledMembershipBoundary { + field: entry.field.clone(), + membership_entity: source.id.clone(), + membership_table: source.physical_table.clone(), + membership_key_column: column( + "key", + &declaration.key, + "breg.access.membership-key-type", + )?, + principal_column: column( + "principal", + &declaration.principal, + "breg.access.membership-principal-type", + )?, + active_column: column( + "active", + &declaration.active, + "breg.access.membership-active-type", + )?, + }, + ExpandedMembershipBoundarySource { + field: entry.field.clone(), + membership_entity: source.id.clone(), + membership_key_field: declaration.key.clone(), + principal_field: declaration.principal.clone(), + active_field: declaration.active.clone(), + }, + )) +} + +pub(crate) fn compile( + entities: &mut BTreeMap, +) -> Result<(), Vec> { + let mut resolved = Vec::new(); + let mut errors = Vec::new(); + for (id, entity) in entities.iter() { + for (profile_id, profile) in &entity.access_profiles { + if profile.membership_boundaries.is_empty() { + continue; + } + let location = + format!("recordTypes[id={id}].accessProfiles[id={profile_id}].rowBoundaries"); + let mut physical = Vec::new(); + let mut logical = Vec::new(); + for boundary in &profile.membership_boundaries { + match resolve_entry(&boundary.entry(), entities, &location) { + Ok((boundary, expanded)) => { + physical.push(boundary); + logical.push(MembershipBoundarySource::Expanded(expanded)); + } + Err(error) => errors.push(error), + } + } + resolved.push((id.clone(), profile_id.clone(), physical, logical)); + } } + if !errors.is_empty() { + return Err(errors); + } + for (id, profile_id, physical, logical) in resolved { + if let Some(entity) = entities.get_mut(&id) { + if let Some(profile) = entity.access_profiles.get_mut(&profile_id) { + profile.membership_boundaries = logical; + entity.membership_boundaries.insert(profile_id, physical); + } + } + } + Ok(()) } pub(crate) fn boundaries<'a>( @@ -313,10 +1234,214 @@ pub(crate) fn source_predicate(boundary: &CompiledMembershipBoundary, alias: &st ) } -pub(crate) fn source_guard(entity: &str, profile: &str, index: usize) -> String { +pub(crate) fn source_guard(name: &str, profile: &str) -> String { format!( "NULLIF(current_setting('registry.membership_probe', true), '') = {} AND NULLIF(current_setting('registry.access_profile', true), '') = {}", - quote_literal(&function_name(entity, profile, index)), + quote_literal(name), quote_literal(profile) ) } + +pub(crate) fn target_function_name(profile: &str, source: &str) -> String { + scoped_function_name("membership_target", profile, source) +} + +fn scoped_function_name(namespace: &str, profile: &str, source: &str) -> String { + let mut hash = Sha256::new(); + hash.update(format!("breg/{namespace}/v1")); + for part in [profile, source] { + hash.update((part.len() as u64).to_be_bytes()); + hash.update(part.as_bytes()); + } + format!("{namespace}_{}", hex_prefix(&hash.finalize(), 12)) +} + +pub(super) struct MembershipProbe<'a> { + pub name: String, + pub profile: &'a str, + pub boundary: &'a CompiledMembershipBoundary, + pub locks: bool, +} + +pub(super) fn probes<'a>( + entities: &'a BTreeMap, + actions: &'a CompiledActionInventory, +) -> Vec> { + let mut probes = Vec::new(); + for entity in entities.values() { + for (profile, boundaries) in &entity.membership_boundaries { + for (index, boundary) in boundaries.iter().enumerate() { + probes.push(MembershipProbe { + name: function_name(&entity.id, profile, index), + profile, + boundary, + locks: false, + }); + } + } + } + + let mut targets = BTreeSet::new(); + for (profile, boundary, _) in target_boundaries(actions) { + if targets.insert((profile, boundary.membership_entity.as_str())) { + probes.push(MembershipProbe { + name: target_function_name(profile, &boundary.membership_entity), + profile, + boundary, + locks: false, + }); + } + } + probes.extend( + lockable_membership_tables(entities, actions) + .into_iter() + .map(|((profile, source), boundary)| MembershipProbe { + name: lock_function_name(profile, source), + profile, + boundary, + locks: true, + }), + ); + probes +} + +fn target_boundaries( + actions: &CompiledActionInventory, +) -> impl Iterator { + actions.actions.iter().flat_map(|action| { + let action_operation = if action.execution.is_proposal() { + Operation::Start + } else { + Operation::Invoke + }; + let action_targets = action + .permissions + .iter() + .filter(move |grant| grant.operations.contains(&action_operation)) + .flat_map(move |grant| { + grant.entity_target_locks().flat_map(move |target| { + target.membership_boundaries.iter().map(move |boundary| { + ( + grant.profile_id.as_str(), + boundary, + action_operation == Operation::Invoke, + ) + }) + }) + }); + let proposal_targets = match &action.execution { + CompiledActionExecution::Proposal { proposal } => proposal.permissions.as_slice(), + CompiledActionExecution::Immediate => &[], + }; + action_targets.chain(proposal_targets.iter().flat_map(move |grant| { + // Caller Apply also includes an authorized external recovery actor. + let locks = grant.operations.contains(&ProposalOperation::Apply); + grant.targets.iter().flat_map(move |target| { + target + .membership_boundaries + .iter() + .map(move |boundary| (grant.profile_id.as_str(), boundary, locks)) + }) + })) + }) +} + +pub(crate) fn lock_function_name(profile: &str, source: &str) -> String { + scoped_function_name("membership_lock", profile, source) +} + +/// The membership sources write authority can lock, by access profile and Record type. +pub(crate) fn lockable_membership_tables<'a>( + entities: &'a BTreeMap, + actions: &'a CompiledActionInventory, +) -> BTreeMap<(&'a str, &'a str), &'a CompiledMembershipBoundary> { + let mut tables = BTreeMap::new(); + for entity in entities.values() { + for (profile, boundaries) in &entity.membership_boundaries { + if entity.access_profiles[profile] + .operations + .iter() + .any(|operation| { + matches!( + operation, + Operation::Create + | Operation::Patch + | Operation::Tombstone + | Operation::Batch + ) + }) + { + for boundary in boundaries { + tables.insert( + (profile.as_str(), boundary.membership_entity.as_str()), + boundary, + ); + } + } + } + } + for (profile, boundary, locks) in target_boundaries(actions) { + if locks { + tables.insert((profile, boundary.membership_entity.as_str()), boundary); + } + } + tables +} + +pub(super) fn append_target_probes( + entity: &CompiledEntity, + profile: &str, + boundaries: &[CompiledMembershipBoundary], + policies: &mut [crate::generated_ddl::DdlPolicy], +) { + if boundaries.is_empty() { + return; + } + let predicate = boundaries + .iter() + .map(|boundary| { + format!( + "registry_context.{}({})", + quote_identifier(&target_function_name(profile, &boundary.membership_entity)), + if boundary.field == CANONICAL_ID { + "record_id".to_owned() + } else { + quote_identifier(&entity.fields[&boundary.field].physical_name) + } + ) + }) + .collect::>() + .join(" AND "); + for policy in policies { + for expression in policy.using_expression.iter_mut().chain( + policy + .check_expression + .iter_mut() + .filter(|check| *check != "false"), + ) { + *expression = format!("({expression}) AND {predicate}"); + } + } +} + +pub(crate) fn index_statement(entity: &CompiledEntity) -> Option<(String, String, String)> { + let declaration = entity.membership.as_ref()?; + let column = |field: &str| quote_identifier(&entity.fields[field].physical_name); + let digest = Sha256::digest(format!("breg/membership-index/v1/{}/key", entity.id).as_bytes()); + let name = format!("breg_membership_key_{}", hex_prefix(&digest, 5)); + // Unique: one live row per key and principal, so a removal that + // deactivates one row always ends that person's access through the key. + let sql = format!( + "CREATE UNIQUE INDEX {} ON registry_data.{} ({}, {}) WHERE {} IS TRUE AND record_lifecycle = 'active'", + quote_identifier(&name), + quote_identifier(&entity.physical_table), + column(&declaration.key), + column(&declaration.principal), + column(&declaration.active) + ); + Some(( + format!("entity.{}.membership.key-index", entity.id), + name, + sql, + )) +} diff --git a/crates/registry-breg/src/migration.rs b/crates/registry-breg/src/migration.rs index 100563c211..69d40735f0 100644 --- a/crates/registry-breg/src/migration.rs +++ b/crates/registry-breg/src/migration.rs @@ -178,6 +178,11 @@ pub enum MigrationError { FieldPatternSyntax { entity_id: String, field_id: String }, #[error("existing rows do not conform to a persisted field pattern")] FieldPatternExistingRows { entity_id: String, field_id: String }, + /// Existing active rows of a membership source repeat a key and + /// principal, so its unique live-row index cannot build. + /// Authored identifiers only. + #[error("existing active rows of membership source `{entity_id}` repeat a key and principal")] + MembershipDuplicateLiveRows { entity_id: String }, /// Authored record identifiers only; field values never cross this boundary. #[error("field-encryption backfill would collide blind indexes of existing records")] FieldEncryptionLookupCollision { @@ -1283,6 +1288,10 @@ async fn activate(request: ApplyVerifiedPackageRequest<'_>, mode: ApplyMode) -> request.package.registry(), &statement.id, ), + membership_source: crate::postgres::compiled_membership_source( + request.package.registry(), + &statement.id, + ), ordinal: i32::try_from(ordinal).map_err(|_| MigrationError::PackageBinding)?, }) }) @@ -2247,6 +2256,9 @@ async fn fail_with_error_and_release( entity_id, field_id, }, + crate::postgres::PostgresKernelError::MembershipDuplicateLiveRows { entity_id } => { + MigrationError::MembershipDuplicateLiveRows { entity_id } + } crate::postgres::PostgresKernelError::FieldEncryptionBlindCollision { entity_id, record_ids, diff --git a/crates/registry-breg/src/migration_reconcile.rs b/crates/registry-breg/src/migration_reconcile.rs index 10bf36ee2b..c4af6e506a 100644 --- a/crates/registry-breg/src/migration_reconcile.rs +++ b/crates/registry-breg/src/migration_reconcile.rs @@ -213,6 +213,7 @@ impl From for ReconcileError { | PostgresKernelError::DatabaseTransport(_) | PostgresKernelError::FieldPatternSyntax { .. } | PostgresKernelError::FieldPatternExistingRows { .. } + | PostgresKernelError::MembershipDuplicateLiveRows { .. } | PostgresKernelError::FieldEncryptionBlindCollision { .. } | PostgresKernelError::FieldEncryptionRetainedProposalSnapshots { .. } | PostgresKernelError::BlindIndexReindexRowLimit { .. } => Self::InvalidInput, @@ -254,6 +255,7 @@ impl From for ReconcileError { | MigrationError::DatabaseUnavailable | MigrationError::FieldPatternSyntax { .. } | MigrationError::FieldPatternExistingRows { .. } + | MigrationError::MembershipDuplicateLiveRows { .. } | MigrationError::FieldEncryptionLookupCollision { .. } | MigrationError::FieldEncryptionRetainedProposalSnapshots { .. } | MigrationError::BlindIndexReindexRowLimit { .. } diff --git a/crates/registry-breg/src/model.rs b/crates/registry-breg/src/model.rs index a4e8c6ec47..a200501c41 100644 --- a/crates/registry-breg/src/model.rs +++ b/crates/registry-breg/src/model.rs @@ -542,6 +542,9 @@ pub struct CompiledProposalPolicy { #[serde(default, skip_serializing_if = "Vec::is_empty")] pub promotions: Vec, pub permissions: Vec, + /// Where the Proposal's subject comes from. Bound once, at the first Submit. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub subject: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub system_apply_grant: Option, } @@ -608,7 +611,7 @@ impl CompiledProposalApplication { } } } -pub use crate::contract::{ProposalOperation, ProposalOwnership}; +pub use crate::contract::{ProposalOperation, ProposalParty, ProposalSubjectSource}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum CompiledProposalRetentionMode { @@ -632,7 +635,20 @@ pub struct CompiledProposalPermission { pub required_scopes: BTreeSet, pub required_purposes: BTreeSet, pub operations: BTreeSet, - pub ownership: Option, + /// Packages built before `party` replaced `ownership` stored a caller + /// owned grant as `"ownership": "caller"` and any other as `null`. They + /// still load as predecessors, with the same meaning. + #[serde( + default, + alias = "ownership", + deserialize_with = "compiled_party", + skip_serializing_if = "Option::is_none" + )] + pub party: Option, + /// The grant's Submit may name someone other than the submitter as the + /// Proposal's subject. + #[serde(default, skip_serializing_if = "is_false")] + pub submits_for_anyone: bool, pub targets: Vec, pub readable_context_fields: BTreeSet, #[serde(default)] @@ -642,12 +658,27 @@ pub struct CompiledProposalPermission { #[serde(default, skip_serializing_if = "Option::is_none")] pub writable_inputs: Option>, } +fn compiled_party<'de, D: serde::Deserializer<'de>>( + deserializer: D, +) -> Result, D::Error> { + match Option::::deserialize(deserializer)?.as_deref() { + None => Ok(None), + Some("owner" | "caller") => Ok(Some(ProposalParty::Owner)), + Some("subject") => Ok(Some(ProposalParty::Subject)), + Some(other) => Err(serde::de::Error::unknown_variant( + other, + &["owner", "subject"], + )), + } +} #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CompiledProposalTargetPermission { #[serde(rename = "recordType")] pub entity_id: String, pub row_boundaries: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub membership_boundaries: Vec, } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -889,6 +920,8 @@ pub struct CompiledActionTargetPermission { /// The effect or input that identifies this action target use. pub source: CompiledActionTargetUseSource, pub row_boundaries: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub membership_boundaries: Vec, } impl CompiledActionPermission { @@ -1100,6 +1133,8 @@ pub struct CompiledEntity { #[serde(default, skip_serializing_if = "Option::is_none")] pub access_requirements: Option, #[serde(default, skip_serializing_if = "Option::is_none")] + pub membership: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] pub access_log: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub geojson: Option, diff --git a/crates/registry-breg/src/mutation.rs b/crates/registry-breg/src/mutation.rs index d75af96ea7..312251733c 100644 --- a/crates/registry-breg/src/mutation.rs +++ b/crates/registry-breg/src/mutation.rs @@ -7,6 +7,9 @@ mod action; pub(crate) use action::erase_expired_action_evidence; pub(crate) use action::validate_action_attachments; pub(crate) use action::{HookChangeApplication, HookChangeOutcome}; +mod membership; +pub(crate) use membership::probe_action_memberships; +use membership::RecordMembership; mod proposal; pub(crate) use proposal::{ link_readable, proposal_http_method, proposal_operation_name, CheckedProposalTaskAuthority, @@ -90,7 +93,7 @@ use crate::outbox::{ }; use crate::postgres::external_refresh_queue::{capture_local_records, LocalRecordCapture}; use crate::postgres::{ - begin_action_transaction, begin_record_transaction, begin_timer_action_transaction, + begin_action_transaction, begin_record_transaction_for_write, begin_timer_action_transaction, ActionClaimContext, ClaimContext, ExpectedRegistryIdentity, ImmediateActionLinkBinding, ImmediateActionLinkContext, ImmediateActionTargetBinding, ImmediateActionTargetContext, RegistryLockKey, RowBoundaryContext, SqlIdentifier, @@ -1022,7 +1025,18 @@ impl MutationTransaction { return Err(error); } let _attempt = self.begin_boundary_audit(&request).await?; - let result = self.execute_after_attempt(client, &request, fault).await; + let mut retries = 0; + let result = loop { + let result = self.execute_after_attempt(client, &request, fault).await; + if matches!(result, Err(MutationError::MembershipKeyDrift)) + && retries < 2 + && !fault.is_enabled() + { + retries += 1; + continue; + } + break result; + }; if failure_is_refusal(&result) && !fault.is_enabled() { self.record_boundary_audit(&request, PreIoAuditKind::Refusal) .await?; @@ -1030,9 +1044,9 @@ impl MutationTransaction { // The retry distinction belongs to request actions. Ordinary mutations // retain their existing public failure for aborted SQL transactions. result.map_err(|error| match error { - MutationError::RetryableConflict | MutationError::CommitUnresolved => { - MutationError::Unavailable - } + MutationError::MembershipKeyDrift + | MutationError::RetryableConflict + | MutationError::CommitUnresolved => MutationError::Unavailable, other => other, }) } @@ -1081,17 +1095,28 @@ impl MutationTransaction { return Err(error); } let _attempt = self.begin_batch_boundary_audit(&request).await?; - let result = self - .execute_batch_after_attempt(client, &request, fault) - .await; + let mut retries = 0; + let result = loop { + let result = self + .execute_batch_after_attempt(client, &request, fault) + .await; + if matches!(result, Err(MutationError::MembershipKeyDrift)) + && retries < 2 + && !fault.is_enabled() + { + retries += 1; + continue; + } + break result; + }; if failure_is_refusal(&result) && !fault.is_enabled() { self.record_batch_boundary_audit(&request, PreIoAuditKind::Refusal) .await?; } result.map_err(|error| match error { - MutationError::RetryableConflict | MutationError::CommitUnresolved => { - MutationError::Unavailable - } + MutationError::MembershipKeyDrift + | MutationError::RetryableConflict + | MutationError::CommitUnresolved => MutationError::Unavailable, other => other, }) } @@ -1206,12 +1231,14 @@ impl MutationTransaction { key_domain: IdempotencyKeyDomain::Caller, }, )?; - let transaction = begin_record_transaction( + let transaction = begin_record_transaction_for_write( client, self.lock_key, self.lock_timeout, &self.expected, request.claims, + !crate::membership::boundaries(&request.plan.entity, request.claims.access_profile()) + .is_empty(), ) .await .map_err(|_| MutationError::Unavailable)?; @@ -1228,6 +1255,23 @@ impl MutationTransaction { if !matches!(&stored.metadata, StoredResultMetadata::Record { .. }) { return Err(MutationError::Unavailable); } + if !crate::membership::boundaries(&request.plan.entity, request.claims.access_profile()) + .is_empty() + { + let record_ids = match request.record_id { + Some(id) => { + vec![Uuid::parse_str(id).map_err(|_| MutationError::InvalidRequest)?] + } + None => membership::replayed_record_ids(stored.response.body())?, + }; + membership::recheck_replayed_membership( + transaction.transaction(), + &request.plan.entity, + request.claims.access_profile(), + &record_ids, + ) + .await?; + } let entry = terminal_entry( self.audit.profile(), TerminalAudit { @@ -1283,6 +1327,13 @@ impl MutationTransaction { if request.claims.task_grant().is_some() { return Err(MutationError::PreconditionFailed); } + let membership = RecordMembership::prepare( + transaction.transaction(), + &request.plan.entity, + request.claims.access_profile(), + std::iter::once((request.record_id, request.body.clone())), + ) + .await?; fault.fail_at(MutationFaultPoint::BeforeCurrentRow)?; let current = apply_current_row( transaction.transaction(), @@ -1290,6 +1341,7 @@ impl MutationTransaction { self.audit.profile(), &self.expected.activation_id, self.field_encryption.as_deref(), + membership.as_ref(), ) .await?; stage_record_timer_rows( @@ -1547,12 +1599,14 @@ impl MutationTransaction { }, }, )?; - let transaction = begin_record_transaction( + let transaction = begin_record_transaction_for_write( client, self.lock_key, self.lock_timeout, &self.expected, request.claims, + !crate::membership::boundaries(&request.plan.entity, request.claims.access_profile()) + .is_empty(), ) .await .map_err(|_| MutationError::Unavailable)?; @@ -1826,6 +1880,17 @@ impl MutationTransaction { let StoredResultMetadata::Batch { result_count } = stored.metadata else { return Err(MutationError::Unavailable); }; + if !crate::membership::boundaries(&request.plan.entity, request.claims.access_profile()) + .is_empty() + { + membership::recheck_replayed_membership( + transaction.transaction(), + &request.plan.entity, + request.claims.access_profile(), + &membership::replayed_record_ids(stored.response.body())?, + ) + .await?; + } let entry = terminal_entry( self.audit.profile(), TerminalAudit { @@ -1885,7 +1950,17 @@ impl MutationTransaction { }); } - prelock_batch_current_rows(transaction.transaction(), request).await?; + let mut membership = RecordMembership::prepare( + transaction.transaction(), + &request.plan.entity, + request.claims.access_profile(), + request.items.iter().map(|item| { + let (id, _, body) = item.request_parts(); + (id, body) + }), + ) + .await?; + prelock_batch_current_rows(transaction.transaction(), request, membership.as_ref()).await?; set_temporal_exclusion_constraints( transaction.transaction(), @@ -1920,8 +1995,12 @@ impl MutationTransaction { self.audit.profile(), &self.expected.activation_id, self.field_encryption.as_deref(), + membership.as_ref(), ) .await?; + if let Some(membership) = &mut membership { + membership.record_batch_write(¤t); + } let record_reference = record_reference( self.audit.profile(), &self.expected.activation_id, @@ -2448,8 +2527,14 @@ pub enum MutationError { /// stale-condition failures, which remain generic precondition refusals. #[error("the resulting record is outside the selected access profile's row boundary")] WriteOutsideBoundary, + #[error("the resulting record is outside the selected access profile's row boundary")] + MembershipWriteOutsideBoundary, #[error("mutation precondition failed")] PreconditionFailed, + #[error("mutation precondition failed")] + MembershipPreconditionFailed, + #[error("a target key changed before the mutation locked the target")] + MembershipKeyDrift, /// An admitted frozen application found a changed target. It keeps the /// ordinary precondition problem, but records Rebase as its recovery. #[error("mutation precondition failed")] @@ -2475,6 +2560,14 @@ pub enum MutationError { /// The review authority rejected the Proposal, and a rejection is terminal. #[error("the review rejected this Proposal")] ProposalRejected, + /// Submit names a subject other than the submitter, and the submitting + /// grant does not say `submitsFor: anyone`. + #[error("the Proposal names someone other than the submitter as its subject")] + ProposalSubjectNotCaller, + /// A later Submit read a different subject than the one bound at the + /// first Submit. + #[error("the Proposal's subject changed since it was first submitted")] + ProposalSubjectChanged, /// A record attachment slot already holds a file. Record slots are /// write-once, so a second write is refused whatever its bytes are. #[error("the record attachment slot already holds a file")] @@ -2560,6 +2653,8 @@ impl MutationError { match self { Self::AuthorizationRefused(check) => Some(*check), Self::WriteOutsideBoundary => Some(FailedCheck::RowBoundary), + Self::ProposalSubjectNotCaller => Some(FailedCheck::Ownership), + Self::MembershipWriteOutsideBoundary => Some(FailedCheck::Membership), Self::FieldGuardFailed { .. } | Self::ProposalGuardFailed(_) => { Some(FailedCheck::ActionGuard) } @@ -2567,11 +2662,14 @@ impl MutationError { | Self::InvalidRequestAt(_) | Self::InvalidTimerWindow { .. } | Self::PreconditionFailed + | Self::MembershipPreconditionFailed + | Self::MembershipKeyDrift | Self::ProposalTargetChanged | Self::ProposalReviewResultMismatch | Self::Conflict | Self::ProposalUniqueConflict | Self::ProposalRejected + | Self::ProposalSubjectChanged | Self::AttachmentSlotWriteOnce | Self::AttachmentTooLarge | Self::AttachmentLimitReached @@ -2917,13 +3015,14 @@ pub(super) async fn capture_external_refresh_rows( Ok(()) } -/// Acquire every existing batch target in canonical UUID order before the +/// Acquire every admitted existing batch target in canonical UUID order before the /// first row is changed. Timer staging takes its shared control lock first, /// so ordinary writers and workers cannot invert control, Record, and /// generation locks when callers submit the same targets in different order. async fn prelock_batch_current_rows( transaction: &Transaction<'_>, request: &BatchMutationRequest<'_>, + membership: Option<&RecordMembership<'_>>, ) -> Result<(), MutationError> { let mut record_ids = BTreeSet::new(); for item in &request.items { @@ -2935,6 +3034,11 @@ async fn prelock_batch_current_rows( if !valid_uuid(record_id) { return Err(MutationError::InvalidRequest); } + if membership + .is_some_and(|membership| membership.authorize_existing(Some(record_id)).is_err()) + { + continue; + } record_ids.insert(Uuid::parse_str(record_id).map_err(|_| MutationError::InvalidRequest)?); } if record_ids.is_empty() { @@ -2964,6 +3068,7 @@ async fn apply_current_row( audit_profile: &AuditProfile, package_revision: &str, field_encryption: Option<&FieldEncryptionService>, + membership: Option<&RecordMembership<'_>>, ) -> Result { if request .plan @@ -2986,6 +3091,18 @@ async fn apply_current_row( return Err(MutationError::InvalidRequest); }; let mut data = data.clone(); + if let Some(membership) = membership { + membership.authorize_proposed(&data)?; + match request.claims.authorizes_record_snapshot_before_allocation( + &request.plan.entity, + &data, + record_uuid, + ) { + Ok(true) => {} + Ok(false) => return Err(MutationError::WriteOutsideBoundary), + Err(_) => return Err(MutationError::Unavailable), + } + } crate::generated_identifiers::reserve_for_create( transaction, &request.plan.entity, @@ -3014,6 +3131,9 @@ async fn apply_current_row( Ok(row) } Operation::Patch => { + if let Some(membership) = membership { + membership.authorize_existing(request.record_id)?; + } let current = load_current_row_for_update(transaction, request).await?; let expected = request .expected_etag @@ -3031,8 +3151,12 @@ async fn apply_current_row( if expected.ct_eq(current_etag.as_bytes()).unwrap_u8() != 1 { return Err(MutationError::PreconditionFailed); } + if let Some(membership) = membership { + membership.verify_locked(¤t)?; + } let before_data = current.data.clone(); - let data = apply_patch_document(transaction, request, ¤t.data).await?; + let data = + apply_patch_document(transaction, request, ¤t.data, membership).await?; let mut admitted_intake = current.data.clone(); admitted_intake.extend(data.clone()); authorize_record_snapshot(request, &admitted_intake, current.record_uuid)?; @@ -3050,6 +3174,9 @@ async fn apply_current_row( Ok(row) } Operation::Tombstone => { + if let Some(membership) = membership { + membership.authorize_existing(request.record_id)?; + } let current = load_tombstone_row_for_update(transaction, request).await?; let expected = request .expected_etag @@ -3067,6 +3194,9 @@ async fn apply_current_row( if expected.ct_eq(current_etag.as_bytes()).unwrap_u8() != 1 { return Err(MutationError::PreconditionFailed); } + if let Some(membership) = membership { + membership.verify_locked(¤t)?; + } match crate::disclosure::plan(&request.plan.entity, request.claims.access_profile()) .refuses_tombstone(¤t.data) { @@ -3136,13 +3266,13 @@ async fn apply_patch_row( ) -> Result { let record_id = request.record_id.ok_or(MutationError::InvalidRequest)?; let profile = selected_profile(request)?; + let disclosure = crate::disclosure::plan(&request.plan.entity, request.claims.access_profile()); + check_update_disclosure(&disclosure, before, &data)?; update_current_row( transaction, &request.plan.entity, - request.claims.access_profile(), record_id, expected_revision, - before, data, field_encryption, Some(ConstraintDisclosure::DeclaredFields { @@ -3188,21 +3318,12 @@ pub(super) async fn write_plan_row( ) .await?; } - // A state a `record` condition withholds from the writer is outside its - // boundary, as for a Patch or a Create, before the restrictive row policy - // can refuse it. A state that cannot be evaluated counts as withheld. - let mut after = before.cloned().unwrap_or_default(); - after.extend( - fields - .iter() - .map(|(field, value)| (field.clone(), value.clone())), - ); - if crate::disclosure::plan(entity, writer) - .withholds_record(&after) - .unwrap_or(true) - { + let disclosure = crate::disclosure::plan(entity, writer); + let PlanWriteDisclosure::RecordVisible { update } = + plan_write_disclosure(&disclosure, before, &fields) + else { return Err(MutationError::WriteOutsideBoundary); - } + }; let record_id = record_uuid.to_string(); let mut current = match expected_revision { None => { @@ -3225,19 +3346,15 @@ pub(super) async fn write_plan_row( .await? } Some(revision) => { - let Some(before) = before else { - return Err(MutationError::InvalidRequest); - }; - if revision < 1 { + if before.is_none() || revision < 1 { return Err(MutationError::InvalidRequest); } + update?; update_current_row( transaction, entity, - writer, &record_id, revision, - before, fields, field_encryption, origin.constraint_disclosure(), @@ -3250,6 +3367,51 @@ pub(super) async fn write_plan_row( Ok(current) } +enum PlanWriteDisclosure { + RecordWithheld, + RecordVisible { update: Result<(), MutationError> }, +} + +fn plan_write_disclosure( + disclosure: &crate::disclosure::DisclosurePlan<'_>, + before: Option<&Map>, + fields: &Map, +) -> PlanWriteDisclosure { + if disclosure.is_empty() { + return PlanWriteDisclosure::RecordVisible { update: Ok(()) }; + } + // A `record` condition withholds the resulting state before the + // restrictive row policy can refuse it. An unevaluable state is withheld. + let mut after = before.cloned().unwrap_or_default(); + after.extend( + fields + .iter() + .map(|(field, value)| (field.clone(), value.clone())), + ); + if disclosure.withholds_record(&after).unwrap_or(true) { + return PlanWriteDisclosure::RecordWithheld; + } + PlanWriteDisclosure::RecordVisible { + update: before.map_or(Ok(()), |before| { + check_update_disclosure(disclosure, before, fields) + }), + } +} + +/// Refuse lifting a disclosure mark or writing a withheld field before +/// persistence can answer with a constraint conflict. +fn check_update_disclosure( + disclosure: &crate::disclosure::DisclosurePlan<'_>, + before: &Map, + data: &Map, +) -> Result<(), MutationError> { + match disclosure.refuses_write(before, data) { + Ok(false) => Ok(()), + Ok(true) => Err(MutationError::WriteOutsideBoundary), + Err(_) => Err(MutationError::Unavailable), + } +} + #[derive(Clone, Copy)] pub(super) enum PlanWriteOrigin { ImmediateAction, @@ -3340,27 +3502,17 @@ async fn insert_current_row( row_to_current(entity, &row) } -/// Write `data` over the current row `before` as the `writer` profile. Every -/// update of an existing record passes here, so a bound writer's attempt to -/// lift a disclosure mark or overwrite a withheld field is refused on each -/// path alike, before the database can answer with a constraint conflict. +/// Persist an update after the caller has checked write disclosure. #[allow(clippy::too_many_arguments)] async fn update_current_row( transaction: &Transaction<'_>, entity: &CompiledEntity, - writer: &str, record_id: &str, expected_revision: i64, - before: &Map, data: Map, field_encryption: Option<&FieldEncryptionService>, constraint_disclosure: Option>, ) -> Result { - match crate::disclosure::plan(entity, writer).refuses_write(before, &data) { - Ok(false) => {} - Ok(true) => return Err(MutationError::WriteOutsideBoundary), - Err(_) => return Err(MutationError::Unavailable), - } let submitted_fields = entity .fields .values() @@ -3764,6 +3916,7 @@ async fn apply_patch_document( transaction: &Transaction<'_>, request: &MutationRequest<'_>, current: &Map, + membership: Option<&RecordMembership<'_>>, ) -> Result, MutationError> { let MutationBody::Patch(operations) = &request.body else { return Err(MutationError::InvalidRequest); @@ -3775,6 +3928,7 @@ async fn apply_patch_document( let mut materialized = current.clone(); let mut changed = Map::new(); let mut mutated = false; + let mut deferred_topology = Vec::new(); for (index, operation) in operations.iter().enumerate() { let at = |member| patch_location(index, member); match operation { @@ -3794,10 +3948,16 @@ async fn apply_patch_document( } written_sql_value(&request.plan.entity, field, value) .map_err(|_| at(PatchMember::Value))?; - validate_polygon_topology(transaction, &field.field_type, value, || { - at(PatchMember::Value) - }) - .await?; + if membership.is_some() + && matches!(field.field_type, FieldTypeSource::Crs84Polygon { .. }) + { + deferred_topology.push((index, &field.field_type, value)); + } else { + validate_polygon_topology(transaction, &field.field_type, value, || { + at(PatchMember::Value) + }) + .await?; + } materialized.insert(field_id.clone(), value.clone()); changed.insert(field_id, value.clone()); mutated = true; @@ -3846,6 +4006,17 @@ async fn apply_patch_document( if !mutated { return Err(MutationError::InvalidRequest); } + if let Some(membership) = membership { + // The patch interpreter has validated the values and run the tests. + // Check its final key before asking PostgreSQL to check topology. + membership.authorize_proposed(&materialized)?; + for (index, field_type, value) in deferred_topology { + validate_polygon_topology(transaction, field_type, value, || { + patch_location(index, PatchMember::Value) + }) + .await?; + } + } Ok(changed) } diff --git a/crates/registry-breg/src/mutation/action.rs b/crates/registry-breg/src/mutation/action.rs index 084c6b8d4e..d3e2c19331 100644 --- a/crates/registry-breg/src/mutation/action.rs +++ b/crates/registry-breg/src/mutation/action.rs @@ -88,10 +88,21 @@ impl ImmediateActionExecutionOutcome { } } +mod membership; +use membership::ActionMembership; + +#[derive(Clone, Copy, Eq, PartialEq)] +enum TargetRead { + Lock, + MembershipPreRead, + EvidencePreflight, +} + struct LockedActionTargets { guard_failure: Option, rows: BTreeMap<(String, Uuid), CurrentRow>, missing_timer_link: bool, + missing_target: bool, } enum TimerActionPreflight { @@ -270,6 +281,7 @@ impl MutationTransaction { None, Some(authority), &[], + None, ) .await; let definite_refusal = failure_is_refusal(&result) && !fault.is_enabled(); @@ -554,6 +566,7 @@ impl MutationTransaction { pub(crate) async fn execute_immediate_action( &self, client: &mut Client, + pool: &crate::postgres::RuntimePool, registry: &CompiledRegistry, input: ImmediateActionInput<'_>, claims: &ActionClaimContext, @@ -602,8 +615,13 @@ impl MutationTransaction { }, )?; let reserved_creates = reserve_action_create_ids(action)?; - self.stage_action_attachments(client, claims, &attachments, deadline) - .await?; + let staging_pool = if claims.locks_membership() { + Some(pool) + } else { + self.stage_action_attachments(client, claims, &attachments, deadline) + .await?; + None + }; let mut candidate = None; let trusted_now = time::OffsetDateTime::now_utc(); let application_id = Uuid::new_v4(); @@ -632,6 +650,7 @@ impl MutationTransaction { None, None, &attachments, + staging_pool, ) .await; if matches!(attempt, Err(MutationError::RetryableConflict)) @@ -694,20 +713,100 @@ impl MutationTransaction { .set_statement_budget(deadline.saturating_duration_since(tokio::time::Instant::now())) .await .map_err(|_| MutationError::Unavailable)?; + self.stage_attachment_rows(guarded.transaction(), attachments) + .await?; + guarded + .commit() + .await + .map_err(|_| MutationError::Unavailable) + } + + async fn stage_membership_action_attachments( + &self, + pool: &crate::postgres::RuntimePool, + claims: &ActionClaimContext, + attachments: &[ActionRequestAttachment], + deadline: tokio::time::Instant, + ) -> Result<(), MutationError> { + if attachments.is_empty() + || !matches!( + self.attachment_storage, + crate::attachment_storage::AttachmentStorage::S3(_) + ) + { + return Ok(()); + } + // The parent has admitted the package and holds the target and + // membership locks. Holding that package lock across staging also + // avoids joining a queue behind a waiting exclusive activation. + tokio::time::timeout_at(deadline, async { + let mut staging = pool + .attachment_staging_connection() + .await + .map_err(|_| MutationError::Unavailable)?; + let result = async { + let transaction = staging + .client() + .transaction() + .await + .map_err(map_database_error)?; + let remaining = deadline.saturating_duration_since(tokio::time::Instant::now()); + if remaining < Duration::from_millis(1) { + return Err(MutationError::Unavailable); + } + crate::postgres::set_transaction_statement_budget(&transaction, remaining) + .await + .map_err(|_| MutationError::Unavailable)?; + transaction + .execute( + "SELECT set_config('lock_timeout', $1, true), + set_config('registry.principal', $2, true), + set_config('registry.active_package_revision', $3, true)", + &[ + &format!("{}ms", self.lock_timeout.as_millis()), + &claims.principal(), + &self.expected.activation_id, + ], + ) + .await + .map_err(map_database_error)?; + crate::postgres::verify_registry_transaction_identity( + &transaction, + self.lock_key, + &self.expected, + ) + .await + .map_err(|_| MutationError::Unavailable)?; + self.stage_attachment_rows(&transaction, attachments) + .await?; + transaction.commit().await.map_err(map_database_error) + } + .await; + staging.disarm(); + result + }) + .await + .map_err(|_| MutationError::Unavailable)? + } + + async fn stage_attachment_rows( + &self, + transaction: &Transaction<'_>, + attachments: &[ActionRequestAttachment], + ) -> Result<(), MutationError> { + let backend = self.attachment_storage.binding_digest(); + let verification = self.attachment_verification.binding_digest(); for attachment in attachments_in_lock_order(attachments) { crate::attachment_store::stage_external( - guarded.transaction(), + transaction, &attachment.sha256, attachment.content.len() as u64, - &self.attachment_storage.binding_digest(), - &self.attachment_verification.binding_digest(), + &backend, + &verification, ) .await?; } - guarded - .commit() - .await - .map_err(|_| MutationError::Unavailable) + Ok(()) } /// Fill each record slot the Action declares from its file, in the @@ -1176,17 +1275,12 @@ impl MutationTransaction { }; // A hook holds no claims, so a grant that row-boundaries its targets // can never be satisfied by this path and is refused outright. - let mut target_authority = BTreeMap::>::new(); - for target in grant.entity_target_locks() { - if target.row_boundaries.is_empty() { - target_authority.insert(target.entity_id.clone(), Vec::new()); - } else { - return refused_proposal( - "hook.proposal.boundaries-unsatisfiable", - "The declared principal's grant carries row boundaries a hook holds no claims to satisfy.", - ); - } - } + let Some(target_authority) = hook_target_authority(grant) else { + return refused_proposal( + "hook.proposal.boundaries-unsatisfiable", + "The declared principal's grant carries row boundaries a hook holds no claims to satisfy.", + ); + }; if validate_action_claims(action, &claims, Operation::Invoke).is_err() { return refused_proposal( "hook.proposal.unauthorized", @@ -1342,6 +1436,7 @@ impl MutationTransaction { Some(&causation), None, &[], + None, ) .await; if matches!(attempt, Err(MutationError::RetryableConflict)) @@ -1383,7 +1478,11 @@ impl MutationTransaction { // applies again either. return conflicting_hook_answer(); } - Err(MutationError::PreconditionFailed | MutationError::FieldGuardFailed { .. }) => { + Err( + MutationError::PreconditionFailed + | MutationError::MembershipPreconditionFailed + | MutationError::FieldGuardFailed { .. }, + ) => { return refused_proposal( "hook.proposal.precondition-failed", "The proposed mutation found its target in an unexpected state.", @@ -1541,6 +1640,7 @@ impl MutationTransaction { causation: Option<&Causation>, timer_authority: Option<&TimerActionAuthority>, attachments: &[ActionRequestAttachment], + staging_pool: Option<&crate::postgres::RuntimePool>, ) -> Result { if tokio::time::Instant::now() >= deadline { return Err(MutationError::Unavailable); @@ -1555,12 +1655,13 @@ impl MutationTransaction { ) .await } else { - begin_action_transaction( + crate::postgres::begin_action_transaction_for_write( client, self.lock_key, self.lock_timeout, &self.expected, claims, + claims.locks_membership(), ) .await } @@ -1635,6 +1736,7 @@ impl MutationTransaction { preconditions, timer_authority, trusted_now, + TargetRead::Lock, ) .await?; let entity = registry @@ -1737,8 +1839,38 @@ impl MutationTransaction { application_id, )?; - let guard_failure = match locked_timer_targets.take() { - Some(locked) => locked.guard_failure, + let mut membership = if claims.locks_membership() { + let observed = self + .lock_existing_action_targets( + transaction.transaction(), + registry, + action, + claims, + target_authority, + input_values, + application_id, + preconditions, + None, + trusted_now, + TargetRead::MembershipPreRead, + ) + .await?; + Some( + ActionMembership::acquire( + transaction.transaction(), + claims, + &observed, + effects, + input_values, + reserved_creates, + ) + .await?, + ) + } else { + None + }; + let locked_targets = match locked_timer_targets.take() { + Some(locked) => locked, None => { self.lock_existing_action_targets( transaction.transaction(), @@ -1751,9 +1883,9 @@ impl MutationTransaction { preconditions, timer_authority, trusted_now, + TargetRead::Lock, ) .await? - .guard_failure } }; @@ -1784,6 +1916,7 @@ impl MutationTransaction { claims, target_authority, input_values, + true, ) .await?; } @@ -1799,8 +1932,12 @@ impl MutationTransaction { preconditions, application_id, timer_authority, + true, ) .await?; + if let Some(membership) = &membership { + membership.verify_current(claims, &locked_targets)?; + } if let Some(timer) = timer_authority { let anchor = locked_timer_anchor .as_ref() @@ -1835,16 +1972,61 @@ impl MutationTransaction { // Before surfacing a failed guard, finish every current-target and // admission precheck above and recheck the grant. Effect application and // proposed-value authorization below run only after guards pass. - if let Some(input) = guard_failure { + if let Some(input) = locked_targets.guard_failure { check_current_action_grant(claims)?; return Err(MutationError::FieldGuardFailed { input }); } let ordered = ordered_action_effects(effects)?; let groups = ordered_action_effect_groups(&ordered, &patch_bases, reserved_creates)?; - let mut rows = BTreeMap::::new(); + if let Some(membership) = &mut membership { + for group in &groups { + let effect = group[0]; + let entity = registry + .entities() + .get(&effect.target.entity_id) + .ok_or(MutationError::InvalidRequest)?; + let (_, id) = action_effect_target_key(effect, &patch_bases, reserved_creates)?; + let base = patch_bases.get(&effect.id); + let target = action_target_group_context( + registry, + action, + group, + claims, + target_authority, + id, + base.map(|row| row.record_revision), + false, + Some(application_id), + &self.expected.activation_id, + None, + )?; + let mut preview = base.map(|row| row.data.clone()).unwrap_or_default(); + preview.extend(action_effect_group_document( + action, + entity, + group, + input_values, + reserved_creates, + )?); + membership.authorize_effect( + claims.access_profile(), + target.membership_boundaries(), + &preview, + )?; + match effect.operation { + Operation::Create => { + target.authorize_create_before_allocation(entity, &preview, id) + } + _ => target.authorize_rows(entity, base.map(|row| &row.data), &preview, id), + } + .map_err(|_| MutationError::PreconditionFailed)?; + } + } + let mut rows = BTreeMap::::new(); let mut timer_rows = BTreeMap::<(String, Uuid), CurrentRow>::new(); let mut results = Vec::::new(); for effects in groups { + let effect = effects[0]; fault.fail_at(MutationFaultPoint::BeforeCurrentRow)?; let current = self .apply_action_effect_group( @@ -1862,7 +2044,15 @@ impl MutationTransaction { timer_authority, ) .await?; - let effect = effects[0]; + if let Some(membership) = &membership { + if claims.is_membership_source(&effect.target.entity_id) { + // The locks fence other transactions. This transaction + // can change its own proof before a later effect uses it. + membership + .recheck_used_authority(transaction.transaction()) + .await?; + } + } let record_reference = record_reference( self.audit.profile(), &self.expected.activation_id, @@ -1947,7 +2137,7 @@ impl MutationTransaction { record_reference: record_reference.clone(), operation: effect.operation, }); - rows.insert(effect.id.clone(), current.clone()); + rows.insert(effect.id.clone(), current.record_uuid); } let timer_key = (entity.id.clone(), current.record_uuid); if let Some(previous) = timer_rows.insert(timer_key, current.clone()) { @@ -1987,6 +2177,24 @@ impl MutationTransaction { ) .await?; + // Like Proposal Apply, finish attachment work before taking the history + // head. Membership staging must also finish before the parent takes + // any attachment hash lock. + if let Some(pool) = staging_pool { + check_current_action_grant(claims)?; + self.stage_membership_action_attachments(pool, claims, attachments, deadline) + .await?; + } + self.write_action_attachments( + transaction.transaction(), + action, + claims, + binding, + &results, + attachments, + ) + .await?; + // Several effects may share one final record revision. Index each // distinct revision once, under the action transaction's one commit, // just as the single-record and batch mutation paths do. @@ -2022,15 +2230,6 @@ impl MutationTransaction { }, ) .await?; - self.write_action_attachments( - transaction.transaction(), - action, - claims, - binding, - &results, - attachments, - ) - .await?; let held = action_held_response(action, claims, application_id, &results)?; let public_result_count = u16::try_from( @@ -2219,7 +2418,7 @@ impl MutationTransaction { input_values: &ActionInputs, patch_bases: &BTreeMap, reserved_creates: &BTreeMap, - prior_results: &BTreeMap, + prior_results: &BTreeMap, application_id: Uuid, timer_authority: Option<&TimerActionAuthority>, ) -> Result { @@ -2276,22 +2475,8 @@ impl MutationTransaction { ) .await .map_err(map_database_error)?; - let mut fields = Map::new(); - for effect in effects { - let effect_fields = action_effect_document( - action, - entity, - effect, - input_values, - prior_results, - before, - )?; - for (field, value) in effect_fields { - if fields.insert(field, value).is_some() { - return Err(MutationError::InvalidRequest); - } - } - } + let mut fields = + action_effect_group_document(action, entity, effects, input_values, prior_results)?; if effect.operation == Operation::Create { crate::generated_identifiers::reserve_for_create(transaction, entity, &mut fields) .await?; @@ -2348,6 +2533,7 @@ impl MutationTransaction { preconditions: &BTreeMap, timer_authority: Option<&TimerActionAuthority>, trusted_now: time::OffsetDateTime, + read: TargetRead, ) -> Result { #[derive(Clone, Copy)] enum Role<'a> { @@ -2363,6 +2549,7 @@ impl MutationTransaction { let mut guard_failure = None; let mut rows = BTreeMap::new(); let mut missing_timer_link = false; + let mut missing_target = false; for effect in &action.effects { if let CompiledPlanTargetBinding::Existing { input } = &effect.target.binding { let record_id = Uuid::parse_str(&input_record_id(input_values, input)?) @@ -2507,17 +2694,27 @@ impl MutationTransaction { ) .await .map_err(map_database_error)?; - let mut current = - match load_action_row(transaction, entity, &record_id.to_string(), true).await { - Ok(current) => current, - Err(MutationError::PreconditionFailed) - if timer_authority.is_some() && matches!(role, Role::Link(_)) => - { - missing_timer_link = true; - continue; - } - Err(error) => return Err(error), - }; + let mut current = match load_action_row( + transaction, + entity, + &record_id.to_string(), + read == TargetRead::Lock, + ) + .await + { + Ok(current) => current, + Err(MutationError::PreconditionFailed) + if timer_authority.is_some() && matches!(role, Role::Link(_)) => + { + missing_timer_link = true; + continue; + } + Err(MutationError::PreconditionFailed) if read == TargetRead::MembershipPreRead => { + missing_target = true; + continue; + } + Err(error) => return Err(error), + }; if let (Role::Link(input), Some(timer)) = (role, timer_authority) { let fields = timer.read_fields_for_input(action, input, entity_id)?; timer.materialize_read_fields( @@ -2527,18 +2724,30 @@ impl MutationTransaction { self.field_encryption.as_deref(), )?; } - verify_action_requirements( - entity, - action, - input_values, - record_id, - ¤t, - self.audit.profile(), - registry, - trusted_now, - preconditions, - &mut guard_failure, - )?; + if read == TargetRead::EvidencePreflight { + probe_action_memberships( + transaction, + claims.access_profile(), + claims.target_membership(entity_id), + Some(current.record_uuid), + ¤t.data, + ) + .await?; + } + if read != TargetRead::MembershipPreRead { + verify_action_requirements( + entity, + action, + input_values, + record_id, + ¤t, + self.audit.profile(), + registry, + trusted_now, + preconditions, + &mut guard_failure, + )?; + } rows.insert((entity_id.to_owned(), record_id), current); } transaction @@ -2553,6 +2762,7 @@ impl MutationTransaction { guard_failure, rows, missing_timer_link, + missing_target, }) } @@ -2568,6 +2778,7 @@ impl MutationTransaction { preconditions: &BTreeMap, application_id: Uuid, timer_authority: Option<&TimerActionAuthority>, + lock: bool, ) -> Result, MutationError> { let mut patch_targets = BTreeMap::<(String, Uuid), Vec<(&str, &CompiledPlanEffect, String)>>::new(); @@ -2614,7 +2825,7 @@ impl MutationTransaction { ) .await .map_err(map_database_error)?; - let current = load_action_row(transaction, entity, &target_effects[0].2, true).await?; + let current = load_action_row(transaction, entity, &target_effects[0].2, lock).await?; // A `current-revision` Action sends no condition: its commit guards // were evaluated against this same locked row. if timer_authority.is_none() && action.concurrency.is_condition_required() { @@ -2657,6 +2868,16 @@ impl MutationTransaction { current.record_uuid, ) .map_err(|_| MutationError::PreconditionFailed)?; + if !lock { + probe_action_memberships( + transaction, + claims.access_profile(), + target_context.membership_boundaries(), + Some(current.record_uuid), + ¤t.data, + ) + .await?; + } for (_, effect, _) in target_effects { bases.insert(effect.id.clone(), current.clone()); } @@ -2739,6 +2960,14 @@ impl MutationTransaction { current.record_uuid, ) .map_err(|_| MutationError::PreconditionFailed)?; + probe_action_memberships( + transaction.transaction(), + claims.access_profile(), + target_context.membership_boundaries(), + Some(current.record_uuid), + ¤t.data, + ) + .await?; current } else { let link_context = action_link_context( @@ -2760,6 +2989,14 @@ impl MutationTransaction { link_context .authorize_row(entity, ¤t.data, current.record_uuid) .map_err(|_| MutationError::PreconditionFailed)?; + probe_action_memberships( + transaction.transaction(), + claims.access_profile(), + link_context.membership_boundaries(), + Some(current.record_uuid), + ¤t.data, + ) + .await?; current }; conditions.insert( @@ -2812,6 +3049,7 @@ impl MutationTransaction { Ok(held) } + #[allow(clippy::too_many_arguments)] // The read mode and authority belong to one Action invocation. async fn verify_action_link_references( &self, transaction: &Transaction<'_>, @@ -2820,6 +3058,7 @@ impl MutationTransaction { claims: &ActionClaimContext, target_authority: &BTreeMap>, input_values: &ActionInputs, + lock: bool, ) -> Result<(), MutationError> { let mut refs = Vec::new(); for target_use in &action.target_uses { @@ -2863,10 +3102,20 @@ impl MutationTransaction { ) .await .map_err(map_database_error)?; - let current = load_action_row(transaction, entity, &record_id, true).await?; + let current = load_action_row(transaction, entity, &record_id, lock).await?; link_context .authorize_row(entity, ¤t.data, current.record_uuid) .map_err(|_| MutationError::PreconditionFailed)?; + if !lock { + probe_action_memberships( + transaction, + claims.access_profile(), + link_context.membership_boundaries(), + Some(current.record_uuid), + ¤t.data, + ) + .await?; + } } Ok(()) } @@ -2962,6 +3211,14 @@ impl MutationTransaction { current.record_uuid, ) .map_err(|_| MutationError::PreconditionFailed)?; + probe_action_memberships( + transaction, + claims.access_profile(), + target_context.membership_boundaries(), + Some(current.record_uuid), + ¤t.data, + ) + .await?; } } Ok(()) @@ -3031,6 +3288,18 @@ fn conflicting_hook_answer() -> Result { ) } +fn hook_target_authority( + grant: &crate::model::CompiledActionPermission, +) -> Option>> { + grant + .entity_target_locks() + .map(|target| { + (target.row_boundaries.is_empty() && target.membership_boundaries.is_empty()) + .then(|| (target.entity_id.clone(), Vec::new())) + }) + .collect() +} + fn hook_change_idempotency_key(event_id: Uuid, compiled_delivery_id: &str) -> String { // The application identity is the hook delivery identity, // domain-separated. No attempt, generation, or answer component enters @@ -3569,12 +3838,32 @@ fn action_effect_target_key( Ok((effect.target.entity_id.clone(), record_uuid)) } +fn action_effect_group_document( + action: &CompiledAction, + entity: &CompiledEntity, + effects: &[&CompiledPlanEffect], + inputs: &ActionInputs, + references: &BTreeMap, +) -> Result, MutationError> { + let mut fields = Map::new(); + for effect in effects { + for (field, value) in + action_effect_document(action, entity, effect, inputs, references, None)? + { + if fields.insert(field, value).is_some() { + return Err(MutationError::InvalidRequest); + } + } + } + Ok(fields) +} + fn action_effect_document( action: &CompiledAction, entity: &CompiledEntity, effect: &CompiledPlanEffect, input_values: &ActionInputs, - prior_results: &BTreeMap, + prior_results: &BTreeMap, _before: Option<&CurrentRow>, ) -> Result, MutationError> { let mut data = Map::new(); @@ -3616,10 +3905,10 @@ fn action_effect_document( if target_entity_id != &source.target.entity_id { return Err(MutationError::InvalidRequest); } - let row = prior_results + let id = prior_results .get(effect) .ok_or(MutationError::InvalidRequest)?; - Value::String(row.record_id.clone()) + Value::String(id.to_string()) } }; if !validate_field_value(FieldValue::Json(&value), &field_source.field_type) @@ -4056,6 +4345,16 @@ impl MutationTransaction { context .authorize_row(entity, ¤t.data, uuid) .map_err(|_| MutationError::PreconditionFailed)?; + // At READ COMMITTED this read can see a different revision from + // the earlier Link check. Authorize the exact selector snapshot. + probe_action_memberships( + transaction, + claims.access_profile(), + context.membership_boundaries(), + Some(uuid), + ¤t.data, + ) + .await?; let values = fields .into_iter() .map(|field| { @@ -4258,6 +4557,7 @@ impl MutationTransaction { &input.preconditions, None, trusted_now, + TargetRead::EvidencePreflight, ) .await? .guard_failure; @@ -4268,20 +4568,23 @@ impl MutationTransaction { claims, target_authority, &normalized, + false, ) .await?; - self.lock_action_patch_targets( - transaction.transaction(), - registry, - action, - claims, - target_authority, - &normalized, - &input.preconditions, - application_id, - None, - ) - .await?; + let patch_bases = self + .lock_action_patch_targets( + transaction.transaction(), + registry, + action, + claims, + target_authority, + &normalized, + &input.preconditions, + application_id, + None, + false, + ) + .await?; let commit_requests = self .action_commit_evidence_requests( transaction.transaction(), @@ -4299,6 +4602,19 @@ impl MutationTransaction { if let Some(input) = guard_failure { return Err(MutationError::FieldGuardFailed { input }); } + if claims.locks_membership() { + membership::preflight_evidence( + transaction.transaction(), + registry, + action, + claims, + target_authority, + &normalized, + &patch_bases, + &reserved_creates, + ) + .await?; + } transaction .commit() .await @@ -4359,6 +4675,7 @@ impl MutationTransaction { None, None, &[], + None, ) .await; if matches!(result, Err(MutationError::RetryableConflict)) @@ -4499,6 +4816,56 @@ pub(crate) async fn erase_expired_action_evidence( mod tests { use super::*; + #[test] + fn hooks_refuse_claim_and_membership_boundaries_on_the_same_path() { + use crate::model::{ + CompiledActionPermission, CompiledActionTargetPermission, + CompiledActionTargetUseSource, CompiledMembershipBoundary, + }; + let mut grant = CompiledActionPermission { + profile_id: "operator".into(), + default: false, + actor_kind: None, + task_grant: None, + requester_clients: BTreeSet::new(), + principal_claim: Some("sub".into()), + required_scopes: BTreeSet::from(["records:write".into()]), + required_purposes: BTreeSet::new(), + operations: BTreeSet::from([Operation::Invoke]), + targets: vec![CompiledActionTargetPermission { + entity_id: "target".into(), + operation: Operation::Create, + source: CompiledActionTargetUseSource::Effect { + effect: "create".into(), + }, + row_boundaries: Vec::new(), + membership_boundaries: Vec::new(), + }], + results: BTreeSet::from(["create".into()]), + }; + assert!(hook_target_authority(&grant).is_some()); + grant.targets[0] + .row_boundaries + .push(crate::contract::RowBoundarySource { + field: "owner".into(), + claim: "sub".into(), + operator: crate::contract::BoundaryOperator::Equals, + }); + assert!(hook_target_authority(&grant).is_none()); + grant.targets[0].row_boundaries.clear(); + grant.targets[0] + .membership_boundaries + .push(CompiledMembershipBoundary { + field: "owner".into(), + membership_entity: "members".into(), + membership_table: "members".into(), + membership_key_column: "key".into(), + principal_column: "principal".into(), + active_column: "active".into(), + }); + assert!(hook_target_authority(&grant).is_none()); + } + #[test] fn ordinary_action_binding_keeps_the_released_canonical_shape() { let profile = AuditProfile::unkeyed_dev_only(); diff --git a/crates/registry-breg/src/mutation/action/membership.rs b/crates/registry-breg/src/mutation/action/membership.rs new file mode 100644 index 0000000000..35cd670677 --- /dev/null +++ b/crates/registry-breg/src/mutation/action/membership.rs @@ -0,0 +1,713 @@ +// SPDX-License-Identifier: Apache-2.0 + +use super::*; +use crate::action_outcome::{decode_slot_mutations, ProposedValue}; +use crate::membership::target_function_name; +use crate::model::{CompiledMembershipBoundary, CompiledPlanWrite}; +use crate::mutation::membership::{ + json_key, keys_for_row, probe, probe_action_membership, probe_action_memberships, LockKey, + MembershipLocks, +}; +use crate::postgres::snapshot_matches_boundaries; + +pub(super) struct ActionMembership { + keys: BTreeMap<(String, Uuid), Vec>>, + locks: MembershipLocks, + used: BTreeSet, +} + +impl ActionMembership { + pub(super) async fn acquire( + transaction: &Transaction<'_>, + claims: &ActionClaimContext, + observed: &LockedActionTargets, + effects: &[CompiledPlanEffect], + inputs: &ActionInputs, + reserved: &BTreeMap, + ) -> Result { + let profile = claims.access_profile(); + let mut needed = BTreeSet::new(); + let mut keys = BTreeMap::new(); + for ((entity, id), row) in &observed.rows { + let boundaries = claims.target_membership(entity); + if boundaries.is_empty() { + continue; + } + let existing = keys_for_row(boundaries, Some(*id), &row.data); + for (boundary, key) in boundaries.iter().zip(&existing) { + MembershipLocks::collect(&mut needed, profile, boundary, *key); + } + keys.insert((entity.clone(), *id), existing); + } + for effect in effects { + for boundary in claims.target_membership(&effect.target.entity_id) { + for mutation in &effect.mutations { + if let CompiledPlanMutation::Set { field, value } = mutation { + if field == &boundary.field { + let key = match value { + CompiledPlanValue::FromInput { input } => { + json_key(inputs.get(input)) + } + CompiledPlanValue::FromEffect { effect, .. } => { + reserved.get(effect).copied() + } + CompiledPlanValue::Literal { value } => json_key(Some(value)), + }; + MembershipLocks::collect(&mut needed, profile, boundary, key); + } + } + } + } + } + let mut membership = Self { + keys, + locks: MembershipLocks::acquire(transaction, needed).await?, + used: BTreeSet::new(), + }; + if observed.missing_target { + return Err(MutationError::PreconditionFailed); + } + for ((entity, _), keys) in &membership.keys { + for (boundary, key) in claims.target_membership(entity).iter().zip(keys) { + record_admission( + &membership.locks, + &mut membership.used, + profile, + boundary, + *key, + )?; + } + } + Ok(membership) + } + + pub(super) fn verify_current( + &self, + claims: &ActionClaimContext, + current: &LockedActionTargets, + ) -> Result<(), MutationError> { + for ((entity, id), expected) in &self.keys { + let row = current + .rows + .get(&(entity.clone(), *id)) + .ok_or(MutationError::MembershipPreconditionFailed)?; + if keys_for_row(claims.target_membership(entity), Some(*id), &row.data) != *expected { + return Err(MutationError::RetryableConflict); + } + } + Ok(()) + } + + pub(super) fn authorize_effect( + &mut self, + profile: &str, + boundaries: &[CompiledMembershipBoundary], + proposed: &Map, + ) -> Result<(), MutationError> { + for (boundary, key) in boundaries + .iter() + .zip(keys_for_row(boundaries, None, proposed)) + { + record_admission(&self.locks, &mut self.used, profile, boundary, key)?; + } + Ok(()) + } + + pub(super) async fn recheck_used_authority( + &self, + transaction: &Transaction<'_>, + ) -> Result<(), MutationError> { + for (helper, key) in &self.used { + if !probe(transaction, helper, *key).await? { + return Err(MutationError::MembershipPreconditionFailed); + } + } + Ok(()) + } +} + +fn record_admission( + locks: &MembershipLocks, + used: &mut BTreeSet, + profile: &str, + boundary: &CompiledMembershipBoundary, + key: Option, +) -> Result<(), MutationError> { + let key = key + .filter(|key| locks.allows(profile, boundary, Some(*key))) + .ok_or(MutationError::MembershipPreconditionFailed)?; + used.insert(( + target_function_name(profile, &boundary.membership_entity), + key, + )); + Ok(()) +} + +#[allow(clippy::too_many_arguments)] +pub(super) async fn preflight_evidence( + transaction: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + claims: &ActionClaimContext, + target_authority: &BTreeMap>, + inputs: &ActionInputs, + patch_bases: &BTreeMap, + reserved: &BTreeMap, +) -> Result<(), MutationError> { + let profile = claims.access_profile(); + if let Some(handler) = &action.handler { + for slot in &handler.writes { + let entity_id = &slot.ceiling.target_entity_id; + let entity = registry + .entities() + .get(entity_id) + .ok_or(MutationError::InvalidRequest)?; + let disclosure = crate::disclosure::plan(entity, profile); + let base = patch_bases.get(&slot.id); + if function_slot_can_write( + &slot.ceiling, + claims.target_membership(entity_id), + base.map(|base| &base.data), + inputs, + |field| { + entity + .fields + .get(field) + .is_some_and(|field| field.encryption.is_some()) + }, + |field, value| { + let (Some(boundaries), Some(base)) = (target_authority.get(entity_id), base) + else { + return false; + }; + permits_patch_value(entity, &disclosure, boundaries, base, field, value) + }, + |boundary, key| probe_action_membership(transaction, profile, boundary, Some(key)), + ) + .await? + { + return Ok(()); + } + } + return Err(MutationError::MembershipPreconditionFailed); + } + let ordered = ordered_action_effects(&action.effects)?; + for group in ordered_action_effect_groups(&ordered, patch_bases, reserved)? { + let effect = group[0]; + let entity = registry + .entities() + .get(&effect.target.entity_id) + .ok_or(MutationError::InvalidRequest)?; + let mut preview = patch_bases + .get(&effect.id) + .map(|base| base.data.clone()) + .unwrap_or_default(); + preview.extend(action_effect_group_document( + action, entity, &group, inputs, reserved, + )?); + probe_action_memberships( + transaction, + profile, + claims.target_membership(&entity.id), + None, + &preview, + ) + .await?; + } + Ok(()) +} + +fn permits_patch_value( + entity: &CompiledEntity, + disclosure: &crate::disclosure::DisclosurePlan<'_>, + boundaries: &[RowBoundaryContext], + base: &CurrentRow, + field: &str, + value: &Value, +) -> bool { + if link_key_refused(entity, field, value) { + return false; + } + // The base row already passed its claim boundaries. Only predicates on + // the emitted field need to be checked against the candidate value. + let changed = Map::from_iter([(field.to_owned(), value.clone())]); + boundaries + .iter() + .filter(|boundary| boundary.field() == field) + .all(|boundary| { + snapshot_matches_boundaries( + entity, + &changed, + base.record_uuid, + std::slice::from_ref(boundary), + ) + .is_ok_and(|matches| matches) + }) + && matches!( + plan_write_disclosure(disclosure, Some(&base.data), &changed), + PlanWriteDisclosure::RecordVisible { update: Ok(()) } + ) +} + +async fn function_slot_can_write<'a, F>( + ceiling: &CompiledPlanWrite, + boundaries: &'a [CompiledMembershipBoundary], + base: Option<&Map>, + inputs: &ActionInputs, + is_encrypted: impl Fn(&str) -> bool, + permits_value: impl Fn(&str, &Value) -> bool, + mut probe_membership: impl FnMut(&'a CompiledMembershipBoundary, Uuid) -> F, +) -> Result +where + F: std::future::Future> + Send, +{ + let patch = ceiling.operation == Operation::Patch; + let mut has_mutation = !patch; + let mut by_field = BTreeMap::<&str, Vec<&CompiledMembershipBoundary>>::new(); + for boundary in boundaries { + by_field.entry(&boundary.field).or_default().push(boundary); + } + for (&field, boundaries) in &by_field { + // A covered field can be set from a declared input or retained by + // omission. A fresh create ID cannot supply current membership. + let mut candidates = reference_input_values(ceiling, field, inputs) + .filter(|value| !patch || permits_value(field, value)) + .filter_map(|value| json_key(Some(value)).map(|key| (key, true))) + .collect::>(); + if let Some(existing) = base.and_then(|base| json_key(base.get(field))) { + candidates.entry(existing).or_insert(false); + } + let mut authorized = false; + for (key, emits_mutation) in candidates { + let mut permitted = true; + for &boundary in boundaries { + if !probe_membership(boundary, key).await? { + permitted = false; + break; + } + } + if permitted { + authorized = true; + has_mutation |= emits_mutation; + if has_mutation { + break; + } + } + } + if !authorized { + return Ok(false); + } + } + // Every membership constraint is satisfiable. A Patch still needs a + // permitted set or clear somewhere in its authored ceiling. + Ok(has_mutation + || base.is_some_and(|base| { + ceiling.fields.iter().any(|field| { + !by_field.contains_key(field.as_str()) + && independent_patch_mutation( + ceiling, + field, + base, + inputs, + is_encrypted(field), + &permits_value, + ) + }) + })) +} + +fn reference_input_values<'a>( + ceiling: &'a CompiledPlanWrite, + field: &str, + inputs: &'a ActionInputs, +) -> impl Iterator { + ceiling + .reference_sources + .get(field) + .filter(|_| ceiling.fields.contains(field)) + .into_iter() + .flat_map(|sources| &sources.inputs) + .filter_map(|input| inputs.get(input)) +} + +fn independent_patch_mutation( + ceiling: &CompiledPlanWrite, + field: &str, + base: &Map, + inputs: &ActionInputs, + encrypted: bool, + permits_value: &impl Fn(&str, &Value) -> bool, +) -> bool { + if !ceiling.required_fields.contains(field) && permits_value(field, &Value::Null) { + return true; + } + if matches!( + ceiling.field_types.get(field), + Some(FieldTypeSource::Reference { .. }) + ) { + // FromEffect requires an emitted Create slot. A permitted Create can + // satisfy preflight itself, independently of this dependent Patch. + return reference_input_values(ceiling, field, inputs) + .any(|value| json_key(Some(value)).is_some() && permits_value(field, value)); + } + let permits_literal = |value: &Value| { + let members = [( + "set".to_owned(), + ProposedValue::Object(vec![(field.to_owned(), json_document(value.clone()))]), + )]; + decode_slot_mutations(ceiling, &members).is_ok() && permits_value(field, value) + }; + // Encrypted members in a stored row are opaque envelopes. Use a fresh + // typed witness when one is available without opening the stored value. + if !encrypted && base.get(field).is_some_and(permits_literal) { + return true; + } + // A previously stored string can exceed the Function ABI's byte bound + // even when a shorter literal of the same field type is representable. + let witness = match ceiling.field_types.get(field) { + Some(FieldTypeSource::String { min_length, .. }) + if *min_length as usize <= crate::rhai_planner::MAXIMUM_STRING_BYTES => + { + "a".repeat((*min_length as usize).max(1)) + } + Some(FieldTypeSource::Text { .. }) => "a".to_owned(), + Some(FieldTypeSource::Date) if encrypted => "2000-01-01".to_owned(), + Some(FieldTypeSource::Decimal { + scale, + minimum, + maximum, + .. + }) if encrypted => minimum + .as_ref() + .or(maximum.as_ref()) + .cloned() + .unwrap_or_else(|| { + if *scale == 0 { + "0".to_owned() + } else { + format!("0.{}", "0".repeat(usize::from(*scale))) + } + }), + _ => return false, + }; + permits_literal(&Value::String(witness)) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::model::CompiledPlanReferenceSources; + + const RETAINED: Uuid = Uuid::from_u128(1); + const ALLOWED: Uuid = Uuid::from_u128(2); + const REFUSED: Uuid = Uuid::from_u128(3); + + fn boundary(field: &str, source: &str) -> CompiledMembershipBoundary { + CompiledMembershipBoundary { + field: field.to_owned(), + membership_entity: source.to_owned(), + membership_table: String::new(), + membership_key_column: String::new(), + principal_column: String::new(), + active_column: String::new(), + } + } + + fn ceiling(fields: &[&str]) -> CompiledPlanWrite { + let reference = FieldTypeSource::Reference { + target: "key".to_owned(), + on_delete: Default::default(), + }; + CompiledPlanWrite { + target_entity_id: "target".to_owned(), + target_from_input: None, + operation: Operation::Patch, + fields: fields.iter().map(|field| (*field).to_owned()).collect(), + field_types: fields + .iter() + .map(|field| ((*field).to_owned(), reference.clone())) + .collect(), + required_fields: fields.iter().map(|field| (*field).to_owned()).collect(), + reference_sources: fields + .iter() + .map(|field| { + ( + (*field).to_owned(), + CompiledPlanReferenceSources { + inputs: BTreeSet::from([format!("{field}-input")]), + create_entities: BTreeSet::new(), + }, + ) + }) + .collect(), + } + } + + fn references(fields: &[(&str, Uuid)]) -> Map { + fields + .iter() + .map(|(field, key)| ((*field).to_owned(), Value::String(key.to_string()))) + .collect() + } + + async fn admits( + ceiling: &CompiledPlanWrite, + boundaries: &[CompiledMembershipBoundary], + base: &Map, + inputs: &ActionInputs, + ) -> bool { + function_slot_can_write( + ceiling, + boundaries, + Some(base), + inputs, + |_| false, + |_, _| true, + |boundary, key| { + std::future::ready(Ok( + key != REFUSED && !(boundary.membership_entity == "other" && key == ALLOWED) + )) + }, + ) + .await + .unwrap() + } + + #[tokio::test] + async fn omitting_covered_fields_cannot_supply_the_only_mutation() { + let ceiling = ceiling(&["first", "second"]); + let boundaries = [boundary("first", "source"), boundary("second", "source")]; + let base = references(&[("first", RETAINED), ("second", RETAINED)]); + let inputs = references(&[("first-input", REFUSED), ("second-input", REFUSED)]); + + assert!(!admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[tokio::test] + async fn one_covered_field_can_be_emitted_while_another_is_retained() { + let ceiling = ceiling(&["first", "second"]); + let boundaries = [boundary("first", "source"), boundary("second", "source")]; + let base = references(&[("first", RETAINED), ("second", RETAINED)]); + let inputs = references(&[("first-input", REFUSED), ("second-input", ALLOWED)]); + + assert!(admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[tokio::test] + async fn a_covered_field_must_satisfy_all_its_boundaries() { + let ceiling = ceiling(&["first", "second"]); + let boundaries = [ + boundary("first", "source"), + boundary("first", "other"), + boundary("second", "source"), + ]; + let base = references(&[("first", RETAINED), ("second", RETAINED)]); + let inputs = references(&[("first-input", ALLOWED), ("second-input", REFUSED)]); + + assert!(!admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[tokio::test] + async fn an_independently_writable_literal_allows_membership_keys_to_be_retained() { + let mut ceiling = ceiling(&["first", "second", "flag"]); + ceiling + .field_types + .insert("flag".to_owned(), FieldTypeSource::Boolean); + ceiling.reference_sources.remove("flag"); + let boundaries = [boundary("first", "source"), boundary("second", "source")]; + let mut base = references(&[("first", RETAINED), ("second", RETAINED)]); + base.insert("flag".to_owned(), Value::Bool(true)); + let inputs = references(&[("first-input", REFUSED), ("second-input", REFUSED)]); + + assert!(admits(&ceiling, &boundaries, &base, &inputs).await); + base.remove("second"); + assert!(!admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[tokio::test] + async fn an_independent_reference_requires_an_available_source_or_a_permitted_clear() { + let mut ceiling = ceiling(&["first", "other"]); + let boundaries = [boundary("first", "source")]; + let base = references(&[("first", RETAINED), ("other", RETAINED)]); + let mut inputs = references(&[("first-input", REFUSED)]); + assert!(!admits(&ceiling, &boundaries, &base, &inputs).await); + + inputs.extend(references(&[("other-input", ALLOWED)])); + assert!(admits(&ceiling, &boundaries, &base, &inputs).await); + + inputs.remove("other-input"); + ceiling.required_fields.remove("other"); + assert!(!independent_patch_mutation( + &ceiling, + "other", + &base, + &inputs, + false, + &|_, _| false, + )); + assert!(admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[tokio::test] + async fn a_single_covered_field_can_set_an_authorized_reference_input() { + let ceiling = ceiling(&["first"]); + let boundaries = [boundary("first", "source")]; + let base = references(&[("first", RETAINED)]); + + for key in [ALLOWED, RETAINED] { + let inputs = references(&[("first-input", key)]); + assert!(admits(&ceiling, &boundaries, &base, &inputs).await); + } + let inputs = references(&[("first-input", REFUSED)]); + assert!(!admits(&ceiling, &boundaries, &base, &inputs).await); + } + + #[test] + fn a_patch_candidate_obeys_the_selected_profiles_write_disclosure() { + let source = json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1", + "kind":"BRegProject", + "project":{"id":"write-disclosure","version":"1","defaultLanguage":"en", + "canonicalBaseIri":"https://unit.example.test"}, + "datasets":{"example":{}}, + "recordTypes":{"entry":{"primaryDataset":"example","route":"entries", + "mutationMode":"mutable","fields":[ + {"id":"mark","type":"string","maximumLength":20,"classification":"internal"}, + {"id":"note","type":"string","maximumLength":20,"classification":"internal"}, + {"id":"flag","type":"boolean","classification":"internal"} + ], + "disclosureConditions":{ + "hide-row":{"when":[{"type":"field-equals","field":"mark","value":"closed"}], + "withhold":"record","exemptProfiles":["officer"]}, + "hide-note":{"when":[{"type":"field-equals","field":"mark","value":"marked"}], + "withhold":"fields","fields":["note"],"exemptProfiles":["officer"]} + } + }}, + "accessProfiles":{ + "clerk":{"default":true,"principalClaim":"sub","requiredScopes":["records:write"], + "permissions":{"records":[{"recordType":"entry","operations":["get"], + "rowBoundaries":"unrestricted","readableFields":["mark","note","flag"]}]}}, + "officer":{"principalClaim":"sub","requiredScopes":["records:write"], + "permissions":{"records":[{"recordType":"entry","operations":["get"], + "rowBoundaries":"unrestricted","readableFields":["mark","note","flag"]}]}} + } + }); + let project = crate::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()) + .expect("write disclosure project parses"); + let registry = crate::compiler::compile_project( + &project, + &[], + crate::compiler::CompileProfile::Authoring, + ) + .expect("write disclosure project compiles"); + let entity = ®istry.entities()["entry"]; + let mut base = CurrentRow { + record_uuid: RETAINED, + record_id: RETAINED.to_string(), + record_revision: 1, + predecessor_revision: None, + record_lifecycle: "active".to_owned(), + before_data: None, + data: Map::from_iter([ + ("mark".to_owned(), json!("marked")), + ("note".to_owned(), json!("retained")), + ("flag".to_owned(), json!(false)), + ]), + }; + let permits = |profile, base: &CurrentRow, field, value: Value| { + permits_patch_value( + entity, + &crate::disclosure::plan(entity, profile), + &[], + base, + field, + &value, + ) + }; + assert!(permits("clerk", &base, "flag", json!(true))); + for (field, value) in [ + ("note", json!("retained")), + ("note", Value::Null), + ("mark", json!("open")), + ] { + assert!(permits("officer", &base, field, value.clone())); + assert!(!permits("clerk", &base, field, value)); + } + base.data.insert("mark".to_owned(), json!("open")); + assert!(permits("officer", &base, "mark", json!("closed"))); + assert!(!permits("clerk", &base, "mark", json!("closed"))); + base.data.insert("mark".to_owned(), json!(false)); + assert!(!permits("clerk", &base, "flag", json!(true))); + } + + #[test] + fn required_encrypted_scalars_have_typed_plaintext_witnesses() { + let mut ceiling = ceiling(&["value"]); + let stored = registry_platform_crypto::field_encryption::envelope_member_json(&[1; 40]); + let base = Map::from_iter([("value".to_owned(), stored)]); + for (field_type, expected) in [ + (FieldTypeSource::Date, "2000-01-01"), + ( + FieldTypeSource::Decimal { + precision: 4, + scale: 2, + minimum: Some("1.25".to_owned()), + maximum: Some("3.00".to_owned()), + }, + "1.25", + ), + ( + FieldTypeSource::Decimal { + precision: 3, + scale: 3, + minimum: None, + maximum: Some("-0.125".to_owned()), + }, + "-0.125", + ), + ( + FieldTypeSource::Decimal { + precision: 2, + scale: 2, + minimum: None, + maximum: None, + }, + "0.00", + ), + ] { + ceiling.field_types.insert("value".to_owned(), field_type); + assert!(independent_patch_mutation( + &ceiling, + "value", + &base, + &ActionInputs::new(), + true, + &|_, value| value.as_str() == Some(expected), + )); + } + } + + #[test] + fn a_stored_envelope_cannot_supply_a_structured_literal() { + let mut ceiling = ceiling(&["value"]); + ceiling.field_types.insert( + "value".to_owned(), + FieldTypeSource::Structured { + max_bytes: 1024, + schema: json!({"type":"object", "additionalProperties":true}), + }, + ); + let stored = registry_platform_crypto::field_encryption::envelope_member_json(&[1; 40]); + let base = Map::from_iter([("value".to_owned(), stored)]); + let inputs = ActionInputs::new(); + + assert!(!independent_patch_mutation( + &ceiling, + "value", + &base, + &inputs, + true, + &|_, _| true, + )); + } +} diff --git a/crates/registry-breg/src/mutation/membership.rs b/crates/registry-breg/src/mutation/membership.rs new file mode 100644 index 0000000000..31f6926fd3 --- /dev/null +++ b/crates/registry-breg/src/mutation/membership.rs @@ -0,0 +1,356 @@ +// SPDX-License-Identifier: Apache-2.0 + +use super::*; +use crate::membership::lock_function_name; +use crate::model::CompiledMembershipBoundary; + +pub(super) type LockKey = (String, Uuid); + +#[derive(Default)] +pub(super) struct MembershipLocks(BTreeMap); + +impl MembershipLocks { + pub(super) fn collect( + keys: &mut BTreeSet, + profile: &str, + boundary: &CompiledMembershipBoundary, + key: Option, + ) { + if let Some(key) = key { + keys.insert(( + lock_function_name(profile, &boundary.membership_entity), + key, + )); + } + } + + pub(super) async fn acquire( + transaction: &Transaction<'_>, + keys: BTreeSet, + ) -> Result { + let mut answers = BTreeMap::new(); + for (helper, key) in keys { + let answer = probe(transaction, &helper, key).await?; + answers.insert((helper, key), answer); + } + Ok(Self(answers)) + } + + pub(super) fn allows( + &self, + profile: &str, + boundary: &CompiledMembershipBoundary, + key: Option, + ) -> bool { + key.is_some_and(|key| { + self.0.get(&( + lock_function_name(profile, &boundary.membership_entity), + key, + )) == Some(&true) + }) + } +} + +pub(super) async fn probe( + transaction: &Transaction<'_>, + helper: &str, + key: Uuid, +) -> Result { + transaction + .query_one( + &format!("SELECT registry_context.{}($1)", quote_identifier(helper)), + &[&key], + ) + .await + .map_err(map_database_error)? + .try_get(0) + .map_err(map_database_error) +} + +pub(crate) async fn probe_action_memberships( + transaction: &Transaction<'_>, + profile: &str, + boundaries: &[CompiledMembershipBoundary], + record_id: Option, + snapshot: &Map, +) -> Result<(), MutationError> { + for boundary in boundaries { + if !probe_action_membership( + transaction, + profile, + boundary, + boundary_key(boundary, record_id, snapshot), + ) + .await? + { + return Err(MutationError::MembershipPreconditionFailed); + } + } + Ok(()) +} + +pub(super) async fn probe_action_membership( + transaction: &Transaction<'_>, + profile: &str, + boundary: &CompiledMembershipBoundary, + key: Option, +) -> Result { + let Some(key) = key else { + return Ok(false); + }; + probe( + transaction, + &crate::membership::target_function_name(profile, &boundary.membership_entity), + key, + ) + .await +} + +pub(super) fn json_key(value: Option<&Value>) -> Option { + value + .and_then(Value::as_str) + .and_then(|value| Uuid::parse_str(value).ok()) +} + +/// The membership key one boundary reads from a row. The canonical +/// identifier names the row itself, so its key is the row's own UUID, which +/// a proposed write that has none cannot supply. +pub(super) fn boundary_key( + boundary: &CompiledMembershipBoundary, + record_id: Option, + row: &Map, +) -> Option { + if boundary.field == crate::membership::CANONICAL_ID { + record_id + } else { + json_key(row.get(&boundary.field)) + } +} + +pub(super) fn keys_for_row( + boundaries: &[CompiledMembershipBoundary], + record_id: Option, + row: &Map, +) -> Vec> { + boundaries + .iter() + .map(|boundary| boundary_key(boundary, record_id, row)) + .collect() +} + +pub(super) struct RecordMembership<'a> { + profile: &'a str, + boundaries: &'a [CompiledMembershipBoundary], + observed: BTreeMap>>, + locks: MembershipLocks, +} + +impl<'a> RecordMembership<'a> { + pub(super) async fn prepare( + transaction: &Transaction<'_>, + entity: &'a CompiledEntity, + profile: &'a str, + items: impl IntoIterator, MutationBody)>, + ) -> Result, MutationError> { + let boundaries = crate::membership::boundaries(entity, profile); + if boundaries.is_empty() { + return Ok(None); + } + let mut record_ids = BTreeSet::new(); + let mut keys = BTreeSet::new(); + for (id, body) in items { + if let Some(id) = id { + record_ids.insert(Uuid::parse_str(id).map_err(|_| MutationError::InvalidRequest)?); + } + for boundary in boundaries { + match &body { + MutationBody::Create(data) => MembershipLocks::collect( + &mut keys, + profile, + boundary, + boundary_key(boundary, None, data), + ), + MutationBody::Patch(operations) => { + for operation in operations { + if let PatchOperation::Add { path, value } + | PatchOperation::Replace { path, value } = operation + { + if patch_field(path)? == boundary.field { + MembershipLocks::collect( + &mut keys, + profile, + boundary, + json_key(Some(value)), + ); + } + } + } + } + MutationBody::Tombstone => {} + } + } + } + let mut observed = BTreeMap::new(); + if !record_ids.is_empty() { + let columns = boundaries + .iter() + .map(|boundary| { + if boundary.field == crate::membership::CANONICAL_ID { + "record_id".to_owned() + } else { + quote_identifier(&entity.fields[&boundary.field].physical_name) + } + }) + .collect::>() + .join(", "); + let table = quote_identifier(&entity.physical_table); + let ids = record_ids.into_iter().collect::>(); + let rows = transaction + .query( + &format!( + "SELECT record_id, {columns} FROM registry_data.{table} + WHERE record_id = ANY($1::uuid[]) AND record_lifecycle = 'active'" + ), + &[&ids], + ) + .await + .map_err(map_database_error)?; + for row in rows { + let current = boundaries + .iter() + .enumerate() + .map(|(index, boundary)| { + let key = row.try_get(index + 1).map_err(map_database_error)?; + MembershipLocks::collect(&mut keys, profile, boundary, key); + Ok(key) + }) + .collect::, MutationError>>()?; + observed.insert(row.try_get(0).map_err(map_database_error)?, current); + } + } + Ok(Some(Self { + profile, + boundaries, + observed, + locks: MembershipLocks::acquire(transaction, keys).await?, + })) + } + + pub(super) fn authorize_existing(&self, id: Option<&str>) -> Result<(), MutationError> { + let id = Uuid::parse_str(id.ok_or(MutationError::InvalidRequest)?) + .map_err(|_| MutationError::InvalidRequest)?; + let keys = self + .observed + .get(&id) + .ok_or(MutationError::PreconditionFailed)?; + if self.allows(keys) { + Ok(()) + } else { + Err(MutationError::MembershipPreconditionFailed) + } + } + + pub(super) fn verify_locked(&self, current: &CurrentRow) -> Result<(), MutationError> { + let keys = keys_for_row(self.boundaries, Some(current.record_uuid), ¤t.data); + if self.observed.get(¤t.record_uuid) != Some(&keys) { + return Err(MutationError::MembershipKeyDrift); + } + if !self.allows(&keys) { + return Err(MutationError::MembershipPreconditionFailed); + } + Ok(()) + } + + pub(super) fn record_batch_write(&mut self, current: &CurrentRow) { + if let Some(keys) = self.observed.get_mut(¤t.record_uuid) { + *keys = keys_for_row(self.boundaries, Some(current.record_uuid), ¤t.data); + } + } + + pub(super) fn authorize_proposed( + &self, + data: &Map, + ) -> Result<(), MutationError> { + if self.allows(&keys_for_row(self.boundaries, None, data)) { + Ok(()) + } else { + Err(MutationError::MembershipWriteOutsideBoundary) + } + } + + fn allows(&self, keys: &[Option]) -> bool { + self.boundaries + .iter() + .zip(keys) + .all(|(boundary, key)| self.locks.allows(self.profile, boundary, *key)) + } +} + +/// The records a stored Record or Batch response names, by `recordId`. +pub(super) fn replayed_record_ids(body: &[u8]) -> Result, MutationError> { + let value: Value = serde_json::from_slice(body).map_err(|_| MutationError::Unavailable)?; + let ids = match value.get("results").and_then(Value::as_array) { + Some(results) => results + .iter() + .map(|result| result.get("recordId")) + .collect(), + None => vec![value.get("data").and_then(|data| data.get("recordId"))], + }; + ids.into_iter() + .map(|id| json_key(id).ok_or(MutationError::Unavailable)) + .collect() +} + +/// A replay returns a stored write only while the caller still holds the +/// membership each written row needs now. A removed member who resends a +/// key gets the refusal a fresh request would. +/// +/// The key comes from the record's latest revision, not the live row: a +/// tombstoned row, or one a create-only profile cannot read back, still has +/// its key there. A revision whose snapshot was erased cannot be rechecked, +/// so its replay is refused. +pub(super) async fn recheck_replayed_membership( + transaction: &Transaction<'_>, + entity: &CompiledEntity, + profile: &str, + record_ids: &[Uuid], +) -> Result<(), MutationError> { + let boundaries = crate::membership::boundaries(entity, profile); + if boundaries.is_empty() { + return Ok(()); + } + for record_id in record_ids { + let snapshot: Option = transaction + .query_opt( + "SELECT convert_from(snapshot, 'UTF8') + FROM registry_internal.registry_revisions + WHERE entity_id = $1::text AND record_id = $2::uuid + ORDER BY record_revision DESC + LIMIT 1", + &[&entity.id, record_id], + ) + .await + .map_err(map_database_error)? + .map(|row| row.try_get(0)) + .transpose() + .map_err(map_database_error)? + .flatten(); + let snapshot: Map = snapshot + .as_deref() + .and_then(|text| serde_json::from_str(text).ok()) + .ok_or(MutationError::MembershipPreconditionFailed)?; + for (index, key) in keys_for_row(boundaries, Some(*record_id), &snapshot) + .into_iter() + .enumerate() + { + let Some(key) = key else { + return Err(MutationError::MembershipPreconditionFailed); + }; + let helper = crate::membership::function_name(&entity.id, profile, index); + if !probe(transaction, &helper, key).await? { + return Err(MutationError::MembershipPreconditionFailed); + } + } + } + Ok(()) +} diff --git a/crates/registry-breg/src/mutation/proposal.rs b/crates/registry-breg/src/mutation/proposal.rs index 3dfb4a13cd..6d2f1a0e36 100644 --- a/crates/registry-breg/src/mutation/proposal.rs +++ b/crates/registry-breg/src/mutation/proposal.rs @@ -13,7 +13,7 @@ use crate::lifecycle::{ ProposalReviewProgress, ProposalStatus, ProposalTurn, ProposalTurnContext, }; use crate::model::{ - CompiledActionExecution, CompiledProposalReview, ProposalOperation, ProposalOwnership, + CompiledActionExecution, CompiledProposalReview, ProposalOperation, ProposalParty, }; use crate::postgres::{ begin_proposal_transaction, ActionClaimContext, ProposalAuthority, ProposalAuthorityOperation, @@ -92,6 +92,46 @@ fn check_current_proposal_grant(authority: &ProposalAuthority) -> Result<(), Mut Ok(()) } +async fn require_proposal_target_snapshot( + tx: &Transaction<'_>, + authority: &ProposalAuthority, + entity: &CompiledEntity, + id: Uuid, + snapshot: &Map, +) -> Result<(), MutationError> { + if !authority + .authorizes_snapshot(entity, id, snapshot) + .map_err(|_| MutationError::PreconditionFailed)? + { + return Err(MutationError::PreconditionFailed); + } + super::membership::probe_action_memberships( + tx, + authority.common.access_profile(), + authority.target_membership(&entity.id), + Some(id), + snapshot, + ) + .await +} + +fn proposal_mutation_target_error( + operation: ProposalAuthorityOperation, + error: MutationError, +) -> MutationError { + match (operation, error) { + ( + ProposalAuthorityOperation::Lifecycle( + ProposalOperation::Answer | ProposalOperation::Add, + ), + MutationError::PreconditionFailed, + ) => MutationError::AuthorizationRefused( + registry_platform_authcommon::FailedCheck::Visibility, + ), + (_, error) => error, + } +} + /// The answer to a target context the database refused to install. A context /// `install_target` rejects means the caller may not read that target. A /// store failure means nobody knows yet, so it answers 503 instead of being @@ -103,6 +143,25 @@ fn target_install_error(error: crate::postgres::PostgresKernelError) -> Mutation } } +struct ProposalMembershipLocks { + document_revision: i64, + observed: BTreeMap<(String, Uuid), Vec>>, + candidate_refusal: Option, + proofs: BTreeSet, + sources: BTreeSet, +} + +impl ProposalMembershipLocks { + async fn recheck(&self, tx: &Transaction<'_>) -> Result<(), MutationError> { + for (helper, key) in &self.proofs { + if !super::membership::probe(tx, helper, *key).await? { + return Err(MutationError::MembershipPreconditionFailed); + } + } + Ok(()) + } +} + fn validate_attachment_authority( action: &CompiledAction, authority: &ProposalAuthority, @@ -122,6 +181,7 @@ fn validate_attachment_authority( .iter() .find(|grant| { grant.profile_id == authority.common.access_profile() + && grant.party == authority.party && grant.operations.contains(&operation) }) .ok_or(MutationError::PreconditionFailed)?; @@ -215,10 +275,8 @@ fn validate_input_write_authority( let CompiledActionExecution::Proposal { proposal } = &action.execution else { return Err(MutationError::InvalidRequest); }; - let Some(writable) = proposal - .permissions - .iter() - .find(|grant| grant.profile_id == authority.common.access_profile()) + let Some(writable) = authority + .permission(proposal) .and_then(|grant| grant.writable_inputs.as_ref()) else { return Ok(()); @@ -231,6 +289,36 @@ fn validate_input_write_authority( } } +/// Once a subject is bound, Edit, Revise and Rebase restate its input exactly: +/// answers, files and messages on the Proposal belong to one person. To name +/// someone else, cancel and file again. +fn validate_bound_subject_input( + action: &CompiledAction, + document: &ProposalDocument, + values: &Map, +) -> Result<(), MutationError> { + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Err(MutationError::InvalidRequest); + }; + let (Some(subject), Some(_)) = (&proposal.subject, &document.header.subject_reference) else { + return Ok(()); + }; + let Some(declared) = action.inputs.iter().find(|input| input.id == subject.input) else { + return Err(MutationError::InvalidRequest); + }; + if values.get(&declared.id) + != document + .input + .as_ref() + .and_then(|prior| prior.get(&declared.id)) + { + return Err(MutationError::InvalidRequestAt( + crate::problem_location::RequestLocation::action_input(&declared.api_name), + )); + } + Ok(()) +} + /// The API name of the first declared input outside `writable` whose value /// differs from `base`. Presence is part of the handler input ABI, so an /// explicit null differs from an absent optional input. @@ -471,7 +559,8 @@ impl MutationTransaction { let document = proposal_store::load_document(tx, id, proposal_store::DocumentLock::Update).await?; self.authorize_proposal_document(tx, registry, &document, input.authority) - .await?; + .await + .map_err(|error| proposal_mutation_target_error(input.operation, error))?; let (binding, _) = self .proposal_document_binding(tx, registry, input, Some(&document)) .await?; @@ -620,6 +709,18 @@ impl MutationTransaction { }, )?; let entry = disclosure.annotate(entry, correlation); + let entry = match authority.party { + Some(party) => { + let mut record = entry.record().clone(); + record["partyRole"] = json!(party); + registry_platform_audit::AuditEntry::response( + crate::audit::AUDIT_SCHEMA, + correlation.request_id().to_string(), + record, + ) + } + None => entry, + }; self.audit .append(entry) .await @@ -731,8 +832,7 @@ impl MutationTransaction { let CompiledActionExecution::Proposal { proposal: policy } = &action.execution else { return Err(MutationError::InvalidRequest); }; - let response_contract=policy.permissions.iter().find(|permission| - permission.profile_id==input.authority.common.access_profile()) + let response_contract=input.authority.permission(policy) .map(|permission|{ let mut contract=json!({"operations":permission.operations, "readableAttachments":permission.readable_attachments,"writableAttachments":permission.writable_attachments}); @@ -818,6 +918,62 @@ impl MutationTransaction { ) } + /// The internal reference a bound subject is stored and matched under. + /// + /// Never project this value in a response, event, export or log. Like + /// the owner reference it is an unkeyed hash, and person identifiers are + /// often a small enough space to enumerate. No issuer takes part: the + /// stored value comes from the register, not from a token. + pub(crate) fn proposal_subject_reference(&self, value: &str) -> String { + crate::idempotency::sha256_reference( + "breg-proposal-subject-reference-v1", + &[&self.expected.database_id, value], + ) + } + + /// The keyed, database-scoped pseudonym audit records for a bound subject. + pub(crate) fn proposal_subject_pseudonym(&self, value: &str) -> Result { + self.audit + .profile() + .key_hasher() + .audit_reference_hash( + "breg-proposal-subject-v1", + &self.expected.database_id, + value, + ) + .map_err(|_| MutationError::Unavailable) + } + + /// Whether `principal` is the subject bound as `subject_reference`. Only + /// a person acting for themselves is ever matched: `person` carries the + /// admission's human test. + pub(crate) fn proposal_subject_matches( + &self, + subject_reference: Option<&str>, + principal: &str, + person: bool, + ) -> bool { + person + && subject_reference + .is_some_and(|stored| stored == self.proposal_subject_reference(principal)) + } + + /// The entry of the caller's profile that governs them on `document`. + pub(crate) fn party_selection( + &self, + document: &ProposalDocument, + authority: &ProposalAuthority, + ) -> crate::api::proposals::PartySelection { + crate::api::proposals::PartySelection::Proposal { + owner: document.header.owner_reference == self.proposal_owner_of(&authority.common), + subject: self.proposal_subject_matches( + document.header.subject_reference.as_deref(), + authority.common.principal(), + authority.person, + ), + } + } + /// The owner reference of the caller `authority` names. pub(crate) fn proposal_owner_of(&self, authority: &ActionClaimContext) -> String { self.proposal_owner_reference( @@ -927,18 +1083,37 @@ impl MutationTransaction { authority: &ProposalAuthority, lock_targets: bool, ) -> Result<(), MutationError> { - let action = proposal_action(registry, &document.action_id)?; if let Some(check) = proposal_document_refusal( &document.action_id, authority.common.action_id(), authority.proposal_scope.as_ref(), document.proposal_id, - authority.ownership, + authority.party, &document.header.owner_reference, || self.proposal_owner_of(&authority.common), + || { + self.proposal_subject_matches( + document.header.subject_reference.as_deref(), + authority.common.principal(), + authority.person, + ) + }, ) { return Err(MutationError::AuthorizationRefused(check)); } + self.check_proposal_targets(tx, registry, document, authority, lock_targets) + .await + } + + async fn check_proposal_targets( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + document: &ProposalDocument, + authority: &ProposalAuthority, + lock_targets: bool, + ) -> Result<(), MutationError> { + let action = proposal_action(registry, &document.action_id)?; for (entity_id, id) in &document.input_targets { let entity = registry .entities() @@ -1017,12 +1192,7 @@ impl MutationTransaction { ) ); let row = load_proposal_row(tx, entity, *id, lock).await?; - if !authority - .authorizes_snapshot(entity, *id, &row.data) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_proposal_target_snapshot(tx, authority, entity, *id, &row.data).await?; } if document.header.state == "submitted" && !document.header.current_proposal_erased { let workflow = @@ -1061,12 +1231,14 @@ impl MutationTransaction { .entities() .get(&target.entity_id) .ok_or(MutationError::PreconditionFailed)?; - if !authority - .authorizes_snapshot(entity, target.record_id, &target.after) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_proposal_target_snapshot( + tx, + authority, + entity, + target.record_id, + &target.after, + ) + .await?; } } if document.header.state == "applied" { @@ -1104,12 +1276,7 @@ impl MutationTransaction { .await .map_err(target_install_error)?; let current = load_proposal_row(tx, entity, id, false).await?; - if !authority - .authorizes_snapshot(entity, id, ¤t.data) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_proposal_target_snapshot(tx, authority, entity, id, ¤t.data).await?; } } Ok(()) @@ -1136,8 +1303,14 @@ impl MutationTransaction { let tx = guarded.transaction(); let document = proposal_store::load_document(tx, id, proposal_store::DocumentLock::None).await?; - self.authorize_proposal_document(tx, registry, &document, input.authority) - .await?; + self.check_proposal_document( + tx, + registry, + &document, + input.authority, + !input.authority.locks_membership(), + ) + .await?; let (binding, _) = self .proposal_document_binding(tx, registry, input, Some(&document)) .await?; @@ -1153,6 +1326,7 @@ impl MutationTransaction { 0, &[], replayed_public_reason(stored.response.body())?, + None, )?; check_current_proposal_grant(input.authority)?; guarded @@ -1321,28 +1495,39 @@ impl MutationTransaction { } else { None }; + let membership = if input.authority.locks_membership() { + self.lock_apply_memberships( + tx, + registry, + action, + input.authority, + input.proposal_id.ok_or(MutationError::InvalidRequest)?, + ) + .await? + } else { + None + }; let existing = if let Some(id) = input.proposal_id { let document = proposal_store::load_document(tx, id, proposal_store::DocumentLock::Update).await?; - if let Err(error) = self - .authorize_proposal_document(tx, registry, &document, input.authority) - .await + if membership + .as_ref() + .is_some_and(|locks| locks.document_revision != document.header.workflow_revision) + || (input.authority.locks_membership() + && document.header.state == "submitted" + && membership.is_none()) { - if matches!( - (&error, input.operation), - ( - MutationError::PreconditionFailed, - ProposalAuthorityOperation::Lifecycle( - ProposalOperation::Answer | ProposalOperation::Add - ) - ) - ) { - return Err(MutationError::AuthorizationRefused( - registry_platform_authcommon::FailedCheck::Visibility, - )); - } - return Err(error); + return Err(MutationError::PreconditionFailed); } + self.check_proposal_document( + tx, + registry, + &document, + input.authority, + !input.authority.locks_membership(), + ) + .await + .map_err(|error| proposal_mutation_target_error(input.operation, error))?; Some(document) } else { None @@ -1379,6 +1564,7 @@ impl MutationTransaction { 0, &[], replayed_public_reason(stored.response.body())?, + None, )?; check_current_proposal_grant(input.authority)?; guarded @@ -1399,6 +1585,7 @@ impl MutationTransaction { let mut result_count = 0u16; let mut changed_inputs = Vec::new(); let mut terminal_error = None; + let mut bound_subject = None; let (id, from_state, transition) = match input.operation { ProposalAuthorityOperation::Start => { if existing.is_some() { @@ -1657,7 +1844,7 @@ impl MutationTransaction { let resolved = proposal_prepare::resolve_targets( registry, action, &values, effects, &creates, )?; - let (bases, guards) = self + let (bases, guards, subject_field) = self .load_submission_bases( tx, registry, @@ -1669,6 +1856,16 @@ impl MutationTransaction { trusted_now, ) .await?; + bound_subject = self + .bind_proposal_subject( + tx, + action, + document, + input.authority, + &values, + subject_field, + ) + .await?; // The exact-command replay lookup ran before plan evaluation. // Reserve only for this fresh Submit, then include every // generated value in the frozen effects and digest. Apply @@ -1677,6 +1874,16 @@ impl MutationTransaction { let mut create_fields = proposal_prepare::materialize_create_fields( registry, &values, &resolved, )?; + proposal_prepare::authorize_candidates_before_allocation( + tx, + registry, + input.authority, + &values, + &resolved, + &create_fields, + &bases, + ) + .await?; for effect in resolved .effects .iter() @@ -1836,6 +2043,7 @@ impl MutationTransaction { &values, document.input.as_ref(), )?; + validate_bound_subject_input(action, document, &values)?; changed_inputs = action .inputs .iter() @@ -2079,6 +2287,8 @@ impl MutationTransaction { document, input.authority, frozen, + membership.as_ref(), + &targets, ) .await?; self.verify_frozen_guards( @@ -2090,6 +2300,12 @@ impl MutationTransaction { frozen, ) .await?; + if let Some(error) = membership + .as_ref() + .and_then(|locks| locks.candidate_refusal.as_ref()) + { + return Err(error.clone()); + } self.apply_frozen_proposal( tx, registry, @@ -2100,6 +2316,7 @@ impl MutationTransaction { &binding, application_id, timer_staging.as_ref(), + membership.as_ref(), ) .await } @@ -2198,6 +2415,7 @@ impl MutationTransaction { 0, &[], ProposalReadDisclosure::default(), + None, )?; if tokio::time::Instant::now() >= deadline { return Err(MutationError::Unavailable); @@ -2311,6 +2529,7 @@ impl MutationTransaction { result_count, &changed_inputs, ProposalReadDisclosure::for_value(&value), + bound_subject.as_deref(), )?; if tokio::time::Instant::now() >= deadline { return Err(MutationError::Unavailable); @@ -2395,6 +2614,7 @@ impl MutationTransaction { count: u16, changed_inputs: &[String], disclosure: ProposalReadDisclosure, + bound_subject: Option<&str>, ) -> Result { let terminal = TerminalAudit { context: input.authority.common.audit_context().cloned(), @@ -2452,6 +2672,12 @@ impl MutationTransaction { if let Some(revision) = input.authority.system_grant_revision() { record["systemApplyGrantRevision"] = json!(revision); } + if let Some(party) = input.authority.party { + record["partyRole"] = json!(party); + } + if let Some(pseudonym) = bound_subject { + record["subjectPseudonym"] = json!(pseudonym); + } Ok(disclosure.annotate( registry_platform_audit::AuditEntry::response( crate::audit::AUDIT_SCHEMA, @@ -2502,14 +2728,8 @@ impl MutationTransaction { .await .map_err(|_| MutationError::PreconditionFailed)?; let row = load_proposal_row(tx, entity, *id, true).await?; - if !authority - .authorizes_snapshot(entity, *id, &row.data) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_proposal_target_snapshot(tx, authority, entity, *id, &row.data).await?; } - let _ = action; Ok(()) } @@ -2527,8 +2747,9 @@ impl MutationTransaction { trusted_now: time::OffsetDateTime, ) -> Result< ( - BTreeMap<(String, Uuid), (i64, Map)>, + proposal_prepare::ProposalPatchBases, BTreeMap)>, + Option, ), MutationError, > { @@ -2573,12 +2794,7 @@ impl MutationTransaction { .await .map_err(|_| MutationError::PreconditionFailed)?; let row = load_proposal_row(tx, entity, id, true).await?; - if !authority - .authorizes_snapshot(entity, id, &row.data) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_proposal_target_snapshot(tx, authority, entity, id, &row.data).await?; rows.insert((entity_id, id), (row.record_revision, row.data)); } for ((entity, id), operation) in &resolved.records { @@ -2629,51 +2845,227 @@ impl MutationTransaction { .clone(); guards.insert(input_id.clone(), (id, revision, row)); } - Ok((bases, guards)) + // The `field` form of a subject reads the referenced Record's field + // under the same Preparation read a commit guard uses. The value is + // compared and hashed, never returned to the submitter. + let subject_field = match &action.execution { + CompiledActionExecution::Proposal { proposal } => match &proposal.subject { + Some(crate::contract::ProposalSubjectSource { + input: input_id, + field: Some(field), + }) => { + let entity = reference_input_entity(action, input_id)?; + let id = input + .get(input_id) + .and_then(Value::as_str) + .and_then(|id| Uuid::parse_str(id).ok()) + .ok_or(MutationError::InvalidRequest)?; + let (_, row) = rows + .get(&(entity.to_owned(), id)) + .ok_or(MutationError::PreconditionFailed)?; + Some(row.get(field).cloned().unwrap_or(Value::Null)) + } + _ => None, + }, + CompiledActionExecution::Immediate => None, + }; + Ok((bases, guards, subject_field)) } - async fn lock_frozen_scope( + /// Bind the Proposal's subject at Submit, or confirm the bound one. The + /// subject is the declared input's value, or the field the reference + /// input's Record holds. A Submit that names someone other than the + /// submitter needs `submitsFor: anyone`. Returns the subject pseudonym + /// audit records when this Submit bound it. + async fn bind_proposal_subject( &self, tx: &Transaction<'_>, - registry: &CompiledRegistry, action: &CompiledAction, document: &ProposalDocument, authority: &ProposalAuthority, - frozen: &crate::proposal_workflow::ProposalSnapshot, - ) -> Result<(), MutationError> { - let mut targets = BTreeMap::new(); - for target in frozen.input_targets() { - let id = Uuid::parse_str(target.record_id.as_str()) - .map_err(|_| MutationError::PreconditionFailed)?; - targets.insert((target.record_type.clone(), id), None); + values: &Map, + subject_field: Option, + ) -> Result, MutationError> { + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Err(MutationError::InvalidRequest); + }; + let Some(subject) = &proposal.subject else { + return Ok(None); + }; + let declared = action + .inputs + .iter() + .find(|input| input.id == subject.input) + .ok_or(MutationError::InvalidRequest)?; + let at_input = || { + MutationError::InvalidRequestAt(crate::problem_location::RequestLocation::action_input( + &declared.api_name, + )) + }; + let value = match subject_field { + Some(field) => field, + None => values.get(&subject.input).cloned().unwrap_or(Value::Null), + }; + let value = value.as_str().unwrap_or_default(); + // A submitter who files only for themselves learns one thing: whether + // the subject is them. An empty value answers as anyone else does. + if value != authority.common.principal() && !authority.submits_for_anyone { + return Err(MutationError::ProposalSubjectNotCaller); } - for effect in frozen.effects() { - if let Some(id) = effect.target().existing_record_id() { - targets.insert( - ( - effect.target().entity_id().as_str().to_owned(), - Uuid::parse_str(id.as_str()) - .map_err(|_| MutationError::PreconditionFailed)?, - ), - effect - .target() - .base_revision() - .map(|revision| revision.get()), - ); + if value.is_empty() { + return Err(at_input()); + } + let reference = self.proposal_subject_reference(value); + match &document.header.subject_reference { + Some(stored) if *stored == reference => Ok(None), + Some(_) => Err(MutationError::ProposalSubjectChanged), + None => { + proposal_store::bind_subject(tx, &action.id, document.proposal_id, &reference) + .await?; + Ok(Some(self.proposal_subject_pseudonym(value)?)) } } - if let Some(guards) = frozen.application_preconditions() { - for target in &guards.targets { - targets.insert( - ( - target.entity_id.clone(), - Uuid::parse_str(target.record_id.as_str()) - .map_err(|_| MutationError::PreconditionFailed)?, - ), - Some(target.expected_revision), - ); + } + + async fn lock_apply_memberships( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + authority: &ProposalAuthority, + id: Uuid, + ) -> Result, MutationError> { + use super::membership::{keys_for_row, MembershipLocks}; + + let document = + proposal_store::load_document(tx, id, proposal_store::DocumentLock::None).await?; + self.check_proposal_visibility(tx, registry, &document, authority) + .await?; + if document.header.state != "submitted" || document.header.current_proposal_erased { + return Ok(None); + } + let workflow = proposal_store::load(tx, &document.action_id, id, false).await?; + let frozen = workflow + .current_proposal() + .ok_or(MutationError::PreconditionFailed)?; + let targets = proposal_store::load_targets( + tx, + &document.action_id, + id, + document.header.submission_version, + ) + .await?; + proposal_prepare::validate_frozen_targets(frozen, &targets)?; + + let profile = authority.common.access_profile(); + let mut needed = BTreeSet::new(); + let mut observed = BTreeMap::new(); + let mut proofs = BTreeSet::new(); + let mut sources = BTreeSet::new(); + for ((entity_id, record_id), revision) in frozen_scope(frozen)? { + let boundaries = authority.target_membership(&entity_id); + if boundaries.is_empty() { + continue; + } + let entity = ®istry.entities()[&entity_id]; + authority + .install_target( + tx, + registry, + id, + frozen.version().get(), + ProposalTargetPhase::Application, + &entity_id, + record_id, + Operation::Get, + &proposal_read_fields(action, &entity_id), + revision, + Some(frozen.effect_digest().as_str()), + ) + .await + .map_err(target_install_error)?; + let row = load_proposal_row(tx, entity, record_id, false).await?; + let keys = keys_for_row(boundaries, Some(record_id), &row.data); + for (boundary, key) in boundaries.iter().zip(&keys) { + MembershipLocks::collect(&mut needed, profile, boundary, *key); + } + observed.insert((entity_id, record_id), keys); + } + for target in &targets { + let boundaries = authority.target_membership(&target.entity_id); + for (boundary, key) in + boundaries + .iter() + .zip(keys_for_row(boundaries, None, &target.after)) + { + MembershipLocks::collect(&mut needed, profile, boundary, key); + } + } + // The shared package lock is already held. Take source locks before + // locking the Proposal state or any target row. + let locks = MembershipLocks::acquire(tx, needed).await?; + let mut admit = |entity: &str, keys: &[Option]| { + let boundaries = authority.target_membership(entity); + if !boundaries + .iter() + .zip(keys) + .all(|(boundary, key)| locks.allows(profile, boundary, *key)) + { + return false; + } + for (boundary, key) in boundaries.iter().zip(keys.iter().flatten()) { + proofs.insert(( + crate::membership::target_function_name(profile, &boundary.membership_entity), + *key, + )); + sources.insert(boundary.membership_entity.clone()); + } + true + }; + for ((entity, _), keys) in &observed { + if !admit(entity, keys) { + return Err(MutationError::MembershipPreconditionFailed); + } + } + let mut candidate_refusal = None; + for target in &targets { + if !admit( + &target.entity_id, + &keys_for_row( + authority.target_membership(&target.entity_id), + None, + &target.after, + ), + ) { + if target.operation != Operation::Patch { + candidate_refusal = Some(MutationError::MembershipPreconditionFailed); + } else if candidate_refusal.is_none() { + candidate_refusal = Some(MutationError::MembershipWriteOutsideBoundary); + } } } + Ok(Some(ProposalMembershipLocks { + document_revision: document.header.workflow_revision, + observed, + candidate_refusal, + proofs, + sources, + })) + } + + #[allow(clippy::too_many_arguments)] + async fn lock_frozen_scope( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + authority: &ProposalAuthority, + frozen: &crate::proposal_workflow::ProposalSnapshot, + membership: Option<&ProposalMembershipLocks>, + snapshots: &[ProposalTargetSnapshot], + ) -> Result<(), MutationError> { + let targets = frozen_scope(frozen)?; for ((entity_id, id), revision) in targets { let entity = registry .entities() @@ -2696,12 +3088,38 @@ impl MutationTransaction { .await .map_err(|_| MutationError::PreconditionFailed)?; let row = load_proposal_row(tx, entity, id, true).await?; + if let Some(expected) = + membership.and_then(|locks| locks.observed.get(&(entity_id.clone(), id))) + { + if super::membership::keys_for_row( + authority.target_membership(&entity_id), + Some(id), + &row.data, + ) != *expected + { + return Err(MutationError::PreconditionFailed); + } + } if !authority .authorizes_snapshot(entity, id, &row.data) .map_err(|_| MutationError::PreconditionFailed)? { return Err(MutationError::PreconditionFailed); } + // A known candidate refusal prevents all writes. Check the frozen + // Patch bases here because the effect loop will never reach them. + if membership.is_some_and(|locks| locks.candidate_refusal.is_some()) + && snapshots.iter().any(|snapshot| { + snapshot.entity_id == entity_id + && snapshot.record_id == id + && snapshot.expected_revision.is_some_and(|revision| { + revision != row.record_revision + || snapshot.before.as_ref() != Some(&row.data) + }) + }) + { + return Err(MutationError::ProposalTargetChanged); + } } Ok(()) } @@ -2852,6 +3270,7 @@ impl MutationTransaction { binding: &crate::idempotency::ResolvedIdempotencyBinding, application_id: Uuid, timer_staging: Option<&RecordTimerStaging>, + membership: Option<&ProposalMembershipLocks>, ) -> Result<(Vec, Vec), MutationError> { let action = proposal_action(registry, &document.action_id)?; let mut observed = Vec::new(); @@ -3007,6 +3426,9 @@ impl MutationTransaction { PlanWriteOrigin::ProposalApplication, ) .await?; + if let Some(locks) = membership.filter(|locks| locks.sources.contains(&entity.id)) { + locks.recheck(tx).await?; + } let reference = record_reference( self.audit.profile(), &self.expected.activation_id, @@ -3236,10 +3658,8 @@ impl MutationTransaction { let CompiledActionExecution::Proposal { proposal } = &action.execution else { return Err(MutationError::PreconditionFailed); }; - let permission = proposal - .permissions - .iter() - .find(|permission| permission.profile_id == authority.common.access_profile()) + let permission = authority + .permission(proposal) .ok_or(MutationError::PreconditionFailed)?; if authority.operation == ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetTaskGrantContext) @@ -3288,7 +3708,7 @@ impl MutationTransaction { || document.action_id != authority.common.action_id() || document.header.current_proposal_erased || !permission.targets.is_empty() - || permission.ownership.is_some() + || permission.party.is_some() || authority .proposal_scope .as_ref() @@ -3576,6 +3996,8 @@ impl MutationTransaction { if accepted.request_id != request.request_id || accepted.policy != request.policy { return Err(MutationError::PreconditionFailed); } + self.check_proposal_targets(tx, registry, document, authority, false) + .await?; value["policy"] = json!(accepted.policy); } match authority.operation { @@ -3673,6 +4095,10 @@ impl MutationTransaction { if let Some(title) = &document.action_title { value["title"] = json!(title); } + // The party whose entry admitted the caller; staff reads carry none. + if let Some(party) = current.party { + value["partyRole"] = json!(party); + } // `blockedReason` is the public package-compatibility marker. A // refused manual application is exposed through `applicationStatus` // instead, whose reason vocabulary already includes that outcome. @@ -3735,6 +4161,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Lifecycle(ProposalOperation::Get), Some(document.proposal_id), + self.party_selection(document, current), ) { Some(authority) => link_readable( self.check_proposal_document(tx, registry, document, &authority, false) @@ -3794,11 +4221,7 @@ impl MutationTransaction { let CompiledActionExecution::Proposal { proposal } = &action.execution else { return Err(MutationError::InvalidRequest); }; - if let Some(permission) = proposal - .permissions - .iter() - .find(|permission| permission.profile_id == get_authority.common.access_profile()) - { + if let Some(permission) = get_authority.permission(proposal) { if let Some(inputs) = public_inputs(action, &permission.readable_inputs, document.input.as_ref()) { @@ -3891,6 +4314,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Lifecycle(operation), Some(document.proposal_id), + self.party_selection(document, current), ) }; let Some(authority) = authority else { @@ -3904,6 +4328,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Start, None, + crate::api::proposals::PartySelection::Any, ) .is_none() { @@ -4069,10 +4494,7 @@ impl MutationTransaction { let CompiledActionExecution::Proposal { proposal: policy } = &action.execution else { return Err(MutationError::Unavailable); }; - let permission = policy - .permissions - .iter() - .find(|permission| permission.profile_id == current.common.access_profile()); + let permission = current.permission(policy); if let Some(permission) = permission { // Attachments are Get-scoped like the inputs: the same gate decides them. let read = get_authority.as_ref(); @@ -4083,6 +4505,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Lifecycle(ProposalOperation::Edit), Some(document.proposal_id), + self.party_selection(document, current), ); let write = match write { Some(authority) => link_readable( @@ -4403,6 +4826,7 @@ fn application_actor_disclosed( }; Ok(proposal.permissions.iter().any(|permission| { permission.profile_id == authority.common.access_profile() + && permission.party == authority.party && permission .operations .contains(&ProposalOperation::GetApplicationActor) @@ -4424,6 +4848,44 @@ fn public_application( value } +fn frozen_scope( + frozen: &crate::proposal_workflow::ProposalSnapshot, +) -> Result>, MutationError> { + let mut targets = BTreeMap::new(); + for target in frozen.input_targets() { + let id = Uuid::parse_str(target.record_id.as_str()) + .map_err(|_| MutationError::PreconditionFailed)?; + targets.insert((target.record_type.clone(), id), None); + } + for effect in frozen.effects() { + if let Some(id) = effect.target().existing_record_id() { + targets.insert( + ( + effect.target().entity_id().as_str().to_owned(), + Uuid::parse_str(id.as_str()).map_err(|_| MutationError::PreconditionFailed)?, + ), + effect + .target() + .base_revision() + .map(|revision| revision.get()), + ); + } + } + if let Some(guards) = frozen.application_preconditions() { + for target in &guards.targets { + targets.insert( + ( + target.entity_id.clone(), + Uuid::parse_str(target.record_id.as_str()) + .map_err(|_| MutationError::PreconditionFailed)?, + ), + Some(target.expected_revision), + ); + } + } + Ok(targets) +} + fn proposal_action<'a>( registry: &'a CompiledRegistry, id: &str, @@ -4604,17 +5066,17 @@ fn proposal_turn_context( pub(crate) const PUBLIC_REASON_REFERENCE: &str = "proposal-review-public-reason"; pub(crate) const REVIEW_PROGRESS_REFERENCE: &str = "proposal-review-progress"; -/// Whether a Get-authority document check lets the caller read the Proposal. -/// Only the two refusals a Proposal read gives a caller who may not read it -/// withhold what Get serves. A conflict, a retryable conflict or any other -/// failure stays an error, so nobody takes a failure for a refusal that would -/// silently omit what the caller may read. +/// Whether the document check lets the caller see a Proposal in a projection. +/// A refusal omits the candidate from a collection or a link. A store failure +/// still fails the request, since the caller may be entitled to the candidate. pub(crate) fn link_readable(outcome: Result<(), MutationError>) -> Result { match outcome { Ok(()) => Ok(true), - Err(MutationError::AuthorizationRefused(_) | MutationError::PreconditionFailed) => { - Ok(false) - } + Err( + MutationError::AuthorizationRefused(_) + | MutationError::PreconditionFailed + | MutationError::MembershipPreconditionFailed, + ) => Ok(false), Err(error) => Err(error), } } @@ -4917,6 +5379,36 @@ async fn load_proposal_row( #[cfg(test)] mod disclosure_tests { use super::*; + + #[test] + fn attachment_and_answer_target_concealment_keeps_the_observed_cause() { + use registry_platform_authcommon::FailedCheck; + + for operation in [ProposalOperation::Answer, ProposalOperation::Add] { + let operation = ProposalAuthorityOperation::Lifecycle(operation); + assert_eq!( + proposal_mutation_target_error(operation, MutationError::PreconditionFailed), + MutationError::AuthorizationRefused(FailedCheck::Visibility), + ); + for error in [ + MutationError::MembershipPreconditionFailed, + MutationError::Unavailable, + ] { + assert_eq!( + proposal_mutation_target_error(operation, error.clone()), + error + ); + } + } + assert_eq!( + proposal_mutation_target_error( + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Edit), + MutationError::PreconditionFailed, + ), + MutationError::PreconditionFailed, + ); + } + fn coordinator(database: &str, activation: &str, key: u8, issuer: &str) -> MutationTransaction { let (audit, _capture) = crate::audit::test_support::capturing( registry_platform_audit::AuditProfile::production_from_secret_bytes( @@ -5130,6 +5622,7 @@ mod disclosure_tests { current_proposal_erased: false, applier_reference: None, application_reason_present: false, + subject_reference: None, }, }; let authority_for = |issuer: Option<&str>| { @@ -5139,6 +5632,7 @@ mod disclosure_tests { ProposalAuthorityOperation::Lifecycle(ProposalOperation::Get), "alice", "directory-editor", + Some(ProposalParty::Owner), Some("directory-administration"), BTreeMap::from([( "contact".to_owned(), @@ -5222,14 +5716,16 @@ mod disclosure_tests { /// The check a Proposal document fails against the caller's authority, if /// any: another action, a Proposal outside the grant's bound scope, or a /// Proposal another caller owns. +#[allow(clippy::too_many_arguments)] fn proposal_document_refusal( document_action_id: &str, authority_action_id: &str, scope: Option<&BTreeSet>, proposal_id: Uuid, - ownership: Option, + party: Option, document_owner: &str, caller_owner: impl FnOnce() -> String, + caller_subject: impl FnOnce() -> bool, ) -> Option { use registry_platform_authcommon::FailedCheck; if document_action_id != authority_action_id { @@ -5238,8 +5734,14 @@ fn proposal_document_refusal( if scope.is_some_and(|scope| !scope.contains(&proposal_id)) { return Some(FailedCheck::TaskGrantScope); } - if ownership == Some(ProposalOwnership::Caller) && document_owner != caller_owner() { - return Some(FailedCheck::Ownership); + match party { + Some(ProposalParty::Owner) if document_owner != caller_owner() => { + return Some(FailedCheck::Ownership); + } + Some(ProposalParty::Subject) if !caller_subject() => { + return Some(FailedCheck::Ownership); + } + _ => {} } None } @@ -5257,7 +5759,14 @@ mod document_refusal_tests { let check = |action: &str, scope: Option<&BTreeSet>, proposal: Uuid, ownership, who: &str| { proposal_document_refusal( - action, "action-a", scope, proposal, ownership, who, owner, + action, + "action-a", + scope, + proposal, + ownership, + who, + owner, + || false, ) }; assert_eq!( @@ -5279,7 +5788,7 @@ mod document_refusal_tests { "action-a", Some(&scope), id, - Some(ProposalOwnership::Caller), + Some(ProposalParty::Owner), "owner-b" ), Some(FailedCheck::Ownership) @@ -5289,13 +5798,35 @@ mod document_refusal_tests { "action-a", Some(&scope), id, - Some(ProposalOwnership::Caller), + Some(ProposalParty::Owner), "owner-a" ), None ); // Another owner's Proposal is admitted when ownership is not the caller's. assert_eq!(check("action-a", None, id, None, "owner-b"), None); + // A subject entry admits only the bound subject, whoever owns it. + assert_eq!( + check( + "action-a", + None, + id, + Some(ProposalParty::Subject), + "owner-a" + ), + Some(FailedCheck::Ownership) + ); + let subject = proposal_document_refusal( + "action-a", + "action-a", + None, + id, + Some(ProposalParty::Subject), + "owner-b", + owner, + || true, + ); + assert_eq!(subject, None); } } @@ -5397,7 +5928,7 @@ mod input_write_tests { {"id":"value","type":"string","required":true,"maximumLength":64,"classification":"internal"}, {"id":"licence-number","type":"string","required":false,"maximumLength":64,"classification":"internal"}], "plan":{"type":"fixed","effects":[{"id":"name","target":{"fromInput":"target"},"operation":"patch","set":{"name":{"fromInput":"value"}}}]}}}, - "accessProfiles":{"clerk": {"default":true,"principalClaim":"sub","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"clerk": {"default":true,"principalClaim":"sub","requiredScopes":["records:write"],"permissions":{ "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}]}}}}); let project = crate::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); diff --git a/crates/registry-breg/src/mutation/proposal/additions.rs b/crates/registry-breg/src/mutation/proposal/additions.rs index 5ff58fe47a..9239e3b403 100644 --- a/crates/registry-breg/src/mutation/proposal/additions.rs +++ b/crates/registry-breg/src/mutation/proposal/additions.rs @@ -29,6 +29,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Lifecycle(ProposalOperation::Add), Some(document.proposal_id), + self.party_selection(document, current), ) .filter(|_| permission.writable_attachments.contains(&slot.id)); let write = match write { diff --git a/crates/registry-breg/src/mutation/proposal/asks.rs b/crates/registry-breg/src/mutation/proposal/asks.rs index 76297ccd1e..43e0ff1af7 100644 --- a/crates/registry-breg/src/mutation/proposal/asks.rs +++ b/crates/registry-breg/src/mutation/proposal/asks.rs @@ -118,6 +118,7 @@ impl MutationTransaction { Some(current.common.access_profile()), ProposalAuthorityOperation::Lifecycle(ProposalOperation::Answer), Some(document.proposal_id), + self.party_selection(document, current), ); // Questions and answers reach only the party who may answer on this // Proposal. The Answer admission carries the human test, so other Get diff --git a/crates/registry-breg/src/mutation/proposal/context_projection.rs b/crates/registry-breg/src/mutation/proposal/context_projection.rs index 489b642fcd..e59c367511 100644 --- a/crates/registry-breg/src/mutation/proposal/context_projection.rs +++ b/crates/registry-breg/src/mutation/proposal/context_projection.rs @@ -27,24 +27,30 @@ pub(super) async fn fields( .iter() .find(|permission| { permission.profile_id == authority.common.access_profile() + && permission.party == authority.party && permission.operations.contains(&match authority.operation { ProposalAuthorityOperation::Lifecycle(operation) => operation, ProposalAuthorityOperation::Start => return false, }) }) .ok_or(MutationError::PreconditionFailed)?; - let document_contract = if mapping + let fields = mapping .fields .iter() - .filter(|(field, _)| selected_fields.is_none_or(|selected| selected.contains(*field))) - .map(|(_, source)| source) - .any(|source| { - matches!( - source, - ProposalContextValueSource::Document { .. } - | ProposalContextValueSource::Additions { .. } - ) - }) { + .filter(|(field, _)| selected_fields.is_none_or(|selected| selected.contains(*field))); + if fields + .clone() + .any(|(field, _)| !permission.readable_context_fields.contains(field)) + { + return Err(MutationError::PreconditionFailed); + } + let document_contract = if fields.clone().any(|(_, source)| { + matches!( + source, + ProposalContextValueSource::Document { .. } + | ProposalContextValueSource::Additions { .. } + ) + }) { Some( crate::compiler::review_context::compile_schema(registry, action) .map_err(|_| MutationError::Unavailable)? @@ -64,12 +70,9 @@ pub(super) async fn fields( { return Err(MutationError::PreconditionFailed); } - let targets = if mapping - .fields - .iter() - .filter(|(field, _)| selected_fields.is_none_or(|selected| selected.contains(*field))) - .map(|(_, source)| source) - .any(|source| matches!(source, ProposalContextValueSource::Changes { .. })) + let targets = if fields + .clone() + .any(|(_, source)| matches!(source, ProposalContextValueSource::Changes { .. })) { frozen .verify_digest(&crate::proposal_workflow::ProposalKey::new( @@ -89,14 +92,20 @@ pub(super) async fn fields( } else { Vec::new() }; - let mut projected = Map::new(); - for (field, source) in &mapping.fields { - if selected_fields.is_some_and(|selected| !selected.contains(field)) { - continue; - } - if !permission.readable_context_fields.contains(field) { - return Err(MutationError::PreconditionFailed); - } + // Resolve the selected Record scopes before acquiring document metadata. + // Keep the canonical field order independently of acquisition order. + let record_source = |source: &ProposalContextValueSource| { + matches!( + source, + ProposalContextValueSource::Record { .. } | ProposalContextValueSource::Changes { .. } + ) + }; + let mut projected = BTreeMap::new(); + for (field, source) in fields + .clone() + .filter(|(_, source)| record_source(source)) + .chain(fields.filter(|(_, source)| !record_source(source))) + { let resolved = match source { ProposalContextValueSource::Additions { slot } => { let schema = document_contract @@ -192,12 +201,7 @@ pub(super) async fn fields( .and_then(|id| Uuid::parse_str(id).ok()) .ok_or(MutationError::PreconditionFailed)?; let row = load_proposal_row(tx, entity, id, false).await?; - if !authority - .authorizes_snapshot(entity, id, &row.data) - .map_err(|_| MutationError::PreconditionFailed)? - { - return Err(MutationError::PreconditionFailed); - } + require_snapshot(tx, entity, record, authority, id, &row.data).await?; let optional = !entity .fields .get(field) @@ -293,7 +297,7 @@ pub(super) async fn fields( }; projected.insert(field.clone(), resolved); } - Ok(projected) + Ok(projected.into_iter().collect()) } /// Prepare refuses a submission that omits a required input, so the frozen @@ -345,13 +349,10 @@ async fn require_snapshot( id: Uuid, snapshot: &Map, ) -> Result<(), MutationError> { - if !authority - .authorizes_snapshot(entity, id, snapshot) + if !record + .context + .authorizes_record_snapshot(entity, snapshot, id) .map_err(|_| MutationError::PreconditionFailed)? - || !record - .context - .authorizes_record_snapshot(entity, snapshot, id) - .map_err(|_| MutationError::PreconditionFailed)? { return Err(MutationError::PreconditionFailed); } @@ -379,7 +380,7 @@ async fn require_snapshot( return Err(MutationError::PreconditionFailed); } } - Ok(()) + require_proposal_target_snapshot(tx, authority, entity, id, snapshot).await } /// The members the profile may not see on `state`. A record the profile diff --git a/crates/registry-breg/src/package.rs b/crates/registry-breg/src/package.rs index 3de0ad7e37..aee51a5e7e 100644 --- a/crates/registry-breg/src/package.rs +++ b/crates/registry-breg/src/package.rs @@ -795,7 +795,7 @@ pub enum PackageError { Binding, #[error("the package compiler derivation failed")] Derivation, - #[error("the sealed sources use historical Action Plan spelling or the generated artifacts differ from this release's compiler output")] + #[error("the sealed sources use historical Action Plan or Proposal grant spelling, or the generated artifacts differ from this release's compiler output")] GeneratedArtifactsMismatch, /// A package whose generated files name a Record type `entityId`, as /// releases up to v0.41.0 wrote them. @@ -2349,7 +2349,9 @@ fn additive_migration_plan( .map(|statement| (statement.id.as_str(), statement)) .collect::>(); for (id, statement) in &candidate_probe_functions { - if previous_probe_functions.get(id) != Some(statement) { + if previous_probe_functions.get(id) != Some(statement) + || (refresh_compiler_owned_ddl && id.starts_with("registry_context.membership_")) + { new_statement_ids.insert((*id).to_owned()); if previous_probe_functions.contains_key(id) { replacement_statement_ids.insert((*id).to_owned()); @@ -2769,6 +2771,26 @@ fn additive_migration_plan( new_statement_ids.insert(id.clone()); } } + let previous_index = crate::membership::index_statement(previous_entity); + let candidate_index = crate::membership::index_statement(candidate_entity); + // A baseline compiled without the index still projects it when + // regenerated here. Refresh it on compiler drift even if the model + // declares the same membership columns. + if refresh_compiler_owned_ddl || previous_index != candidate_index { + if let Some((id, name, _)) = previous_index { + removed_dependency_statements.push(DdlStatement { + id: format!("{id}.drop"), + kind: DdlStatementKind::Index, + sql: format!( + "DROP INDEX IF EXISTS registry_data.{}", + quote_identifier(&name) + ), + }); + } + if let Some((id, _, _)) = candidate_index { + new_statement_ids.insert(id); + } + } } let mut statements = removed_dependency_statements; @@ -4847,8 +4869,8 @@ fn load_closure( /// The refusal for stored sources that do not parse. A package closure holds /// sources an earlier release may have written, so the refusal carries the /// reader's diagnostics for the operator to act on. No release seals a file -/// that mixes or doubles the Action Plan spellings, so such a file is a -/// modified package rather than an earlier release's sources. +/// that mixes Action Plan spellings or doubles an Action Plan or Proposal +/// grant key, so such a file is a modified package. fn source_refusal(failure: &CompileFailure) -> PackageError { const SHOWN: usize = 3; let diagnostics = failure.diagnostics(); @@ -4856,7 +4878,8 @@ fn source_refusal(failure: &CompileFailure) -> PackageError { diagnostic.code == "breg.action-plan.mixed-spelling" || (diagnostic.code == "yaml.duplicate-key" && (diagnostic.path.ends_with(".functions") - || diagnostic.path.ends_with(".function"))) + || diagnostic.path.ends_with(".function") + || diagnostic.path.ends_with(".ownership"))) }) { return PackageError::Integrity; } @@ -4889,7 +4912,7 @@ impl PackageSourceMode { } /// Parse verified source bytes. Only predecessor planning and rehearsal can -/// use translated historical Action Plan keys. +/// use translated historical Action Plan or Proposal grant keys. fn parse_package_sources( manifest: &PackageManifest, loaded: &BTreeMap>, diff --git a/crates/registry-breg/src/package/tests/immediate_actions.rs b/crates/registry-breg/src/package/tests/immediate_actions.rs index 789155762b..9a477042c6 100644 --- a/crates/registry-breg/src/package/tests/immediate_actions.rs +++ b/crates/registry-breg/src/package/tests/immediate_actions.rs @@ -151,7 +151,7 @@ fn ordinary_policy_source(auditor_operations: Option<&[&str]>) -> Value { {"id":"person-code", "type":"string", "maximumLength":40, "required":true, "classification":"internal"}, {"id":"sensitive-note", "type":"string", "maximumLength":120, "classification":"internal"} ]}}, - "accessProfiles":{"operator": { "default":true, "principalClaim":"principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": { "default":true, "principalClaim":"principal","requiredScopes":["records:write"], "permissions":{"records":[{"recordType":"person", "operations":["create","get","list"], "readableFields":["person-code","sensitive-note"], "writableFields":["person-code","sensitive-note"], "rowBoundaries":"unrestricted"}]}}} @@ -599,7 +599,7 @@ fn reviewed_successor_does_not_duplicate_action_policies_for_new_entity() { candidate["accessProfiles"] = json!({"task-operator": { "default":true, "principalClaim":"principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "permissions":{"actions":[{"action":"create-task", "operations":["invoke"], "targets":[{"recordType":"task", "rowBoundaries":"unrestricted"}], "results":["task"]}]} }}); let after = compile(&candidate); diff --git a/crates/registry-breg/src/postgres/cancellation.rs b/crates/registry-breg/src/postgres/cancellation.rs index d60add4206..f538c31823 100644 --- a/crates/registry-breg/src/postgres/cancellation.rs +++ b/crates/registry-breg/src/postgres/cancellation.rs @@ -19,6 +19,10 @@ use std::time::Duration; +use deadpool_postgres::ClientWrapper; +use tokio::sync::OwnedSemaphorePermit; +use tokio_postgres::{CancelToken, Client}; + use super::RuntimePool; /// How long a guard waits for the cancel request and then for the cancelled @@ -123,11 +127,62 @@ impl Drop for Discarded { /// travels on its own connection and may land on whatever the session runs /// next, so a cancelled session is never reused. async fn stop_and_discard(session: Discarded, token: tokio_postgres::CancelToken) { - let _ = tokio::time::timeout(QUERY_CANCEL_TIMEOUT, session.pool.cancel_query(token)).await; if let Some(client) = &session.client { - // The empty query is answered only after every request queued before - // it, including the cancelled statement and the rollback its dropped - // transaction queued, so its answer means the backend is idle. - let _ = tokio::time::timeout(QUERY_CANCEL_TIMEOUT, client.simple_query("")).await; + cancel_and_drain(&session.pool, token, client).await; + } +} + +async fn cancel_and_drain(pool: &RuntimePool, token: CancelToken, client: &Client) { + let _ = tokio::time::timeout(QUERY_CANCEL_TIMEOUT, pool.cancel_query(token)).await; + // The empty query is answered only after every request queued before + // it, including the cancelled statement and the rollback its dropped + // transaction queued, so its answer means the backend is idle. + let _ = tokio::time::timeout(QUERY_CANCEL_TIMEOUT, client.simple_query("")).await; +} + +/// The dedicated staging session retains its permit while cancellation drains it. +pub(crate) struct AttachmentStagingGuard { + pool: RuntimePool, + session: Option<(ClientWrapper, OwnedSemaphorePermit)>, +} + +impl AttachmentStagingGuard { + pub(super) fn new( + pool: RuntimePool, + client: ClientWrapper, + permit: OwnedSemaphorePermit, + ) -> Self { + Self { + pool, + session: Some((client, permit)), + } + } + + pub(crate) fn client(&mut self) -> &mut ClientWrapper { + &mut self + .session + .as_mut() + .expect("the staging session is guarded") + .0 + } + + pub(crate) fn disarm(mut self) { + drop(self.session.take()); + } +} + +impl Drop for AttachmentStagingGuard { + fn drop(&mut self) { + if let Some((client, permit)) = self.session.take() { + let Ok(runtime) = tokio::runtime::Handle::try_current() else { + return; + }; + let pool = self.pool.clone(); + runtime.spawn(async move { + cancel_and_drain(&pool, client.cancel_token(), &client).await; + drop(client); + drop(permit); + }); + } } } diff --git a/crates/registry-breg/src/postgres/catalog.rs b/crates/registry-breg/src/postgres/catalog.rs index f66111969c..232c70d0d5 100644 --- a/crates/registry-breg/src/postgres/catalog.rs +++ b/crates/registry-breg/src/postgres/catalog.rs @@ -154,6 +154,7 @@ const MANAGED_INTERNAL_INDEXES: &[&str] = &[ "registry_internal.registry_proposal_review_completion_reconcile", "registry_internal.registry_proposal_review_submission_jobs", "registry_internal.registry_proposal_review_submissions_request", + "registry_internal.registry_proposal_subject", "registry_internal.registry_record_attachment_live_references", super::timer::TIMER_BINDINGS_OPEN_INDEX, super::timer::TIMER_DUE_INDEX, @@ -1574,6 +1575,15 @@ async fn verify_closed_ambient_catalog( projection_definers.push(*security_definer); } } + let membership_identities: Vec<_> = expected_catalog + .objects + .iter() + .filter(|object| { + object.kind == ManagedObjectKind::Function + && object.name.starts_with("registry_context.membership_") + }) + .map(|object| object.name.as_str()) + .collect(); let row = client .query_one( "SELECT @@ -1617,12 +1627,17 @@ async fn verify_closed_ambient_catalog( AND p.proisstrict AND p.provolatile = 'i' AND p.proconfig = ARRAY['search_path=pg_catalog']) - OR (p.proname ~ '^membership_[0-9a-f]{24}$' + OR (p.proname ~ '^membership_(target_|lock_)?[0-9a-f]{24}$' + AND ('registry_context.' || p.proname || '(uuid)') = ANY($6::text[]) AND pg_catalog.pg_get_function_identity_arguments(p.oid) = 'uuid' AND p.prorettype = 'boolean'::regtype AND NOT p.proretset AND NOT p.prosecdef - AND p.provolatile = 's') + AND p.provolatile::text = CASE WHEN p.proname ~ '^membership_lock_' THEN 'v' ELSE 's' END + AND p.prokind = 'f' + AND p.proisstrict AND NOT p.proleakproof + AND p.prolang = (SELECT oid FROM pg_catalog.pg_language WHERE lanname = 'plpgsql') + AND p.proconfig = ARRAY['search_path=pg_catalog']) OR (p.proname ~ '^consent_[0-9a-f]{24}$' AND pg_catalog.pg_get_function_identity_arguments(p.oid) = '' AND p.prorettype = 'uuid'::regtype @@ -1695,7 +1710,7 @@ async fn verify_closed_ambient_catalog( ) OR EXISTS ( SELECT 1 FROM pg_catalog.pg_publication WHERE puballtables )", - &[&MANAGED_SCHEMAS, &projection_identities, &projection_returns, &projection_sets, &projection_definers], + &[&MANAGED_SCHEMAS, &projection_identities, &projection_returns, &projection_sets, &projection_definers, &membership_identities], ) .await?; if (0..5).any(|index| row.get::<_, bool>(index)) { diff --git a/crates/registry-breg/src/postgres/config.rs b/crates/registry-breg/src/postgres/config.rs index 38b0643dfa..a810d7e5ec 100644 --- a/crates/registry-breg/src/postgres/config.rs +++ b/crates/registry-breg/src/postgres/config.rs @@ -1,12 +1,21 @@ // SPDX-License-Identifier: Apache-2.0 -use std::{error::Error as _, fmt, sync::OnceLock, time::Duration}; - -use deadpool_postgres::{Manager, ManagerConfig, Pool, RecyclingMethod, Runtime}; +use std::{ + error::Error as _, + fmt, + sync::{Arc, OnceLock}, + time::Duration, +}; + +use deadpool_postgres::{ + ClientWrapper, ConfigConnectImpl, Connect, Manager, ManagerConfig, Pool, RecyclingMethod, + Runtime, +}; use tokio_postgres::NoTls; use tokio_postgres::{config::SslMode, CancelToken, Config}; use tokio_postgres_rustls::MakeRustlsConnect; +use super::cancellation::AttachmentStagingGuard; use super::{PostgresKernelError, Result}; const MAX_POOL_SIZE: usize = 128; @@ -348,6 +357,8 @@ impl ConnectionConfig { Ok(RuntimePool { pool, transport: self.transport.clone(), + postgres: self.postgres.clone(), + attachment_staging: Arc::new(tokio::sync::Semaphore::new(1)), }) } } @@ -416,6 +427,8 @@ fn connector_from_roots(roots: rustls::RootCertStore) -> Result, } /// Value-free causes that operator tooling may report for a refused database @@ -568,6 +581,43 @@ impl RuntimePool { self.pool.get().await.map_err(|_| PostgresKernelError::Pool) } + /// Durable S3 staging while the caller's primary transaction holds its + /// membership and target locks. One separate session per pool prevents + /// pool exhaustion when every ordinary connection is in use. + pub(crate) async fn attachment_staging_connection(&self) -> Result { + let permit = Arc::clone(&self.attachment_staging) + .acquire_owned() + .await + .map_err(|_| PostgresKernelError::Pool)?; + let connect = async { + match &self.transport { + Transport::Tls { connector, .. } => { + ConfigConnectImpl { + tls: connector.clone(), + } + .connect(&self.postgres) + .await + } + Transport::Plaintext(_) => { + ConfigConnectImpl { tls: NoTls } + .connect(&self.postgres) + .await + } + } + }; + let (client, task) = match self.pool.timeouts().create { + Some(timeout) => tokio::time::timeout(timeout, connect) + .await + .map_err(|_| PostgresKernelError::Pool)??, + None => connect.await?, + }; + Ok(AttachmentStagingGuard::new( + self.clone(), + ClientWrapper::new(client, task), + permit, + )) + } + pub(crate) async fn get_for_startup( &self, ) -> std::result::Result { diff --git a/crates/registry-breg/src/postgres/context.rs b/crates/registry-breg/src/postgres/context.rs index 1d0334d95e..720847b318 100644 --- a/crates/registry-breg/src/postgres/context.rs +++ b/crates/registry-breg/src/postgres/context.rs @@ -9,6 +9,7 @@ use registry_platform_canonical_json::canonicalize_json; use serde_json::{json, Value}; use time::{format_description::well_known::Rfc3339, OffsetDateTime}; use tokio_postgres::types::Type; +use tokio_postgres::IsolationLevel; use uuid::Uuid; use crate::contract::{BoundaryOperator, Operation}; @@ -56,6 +57,7 @@ pub(crate) struct ActionClaimContext { principal: String, access_profile: String, purpose: Option, + target_memberships: BTreeMap>, result_effects: BTreeSet, audit_context: Option, task_grant: Option, @@ -75,6 +77,7 @@ impl ActionClaimContext { principal, access_profile, purpose, + target_memberships: BTreeMap::new(), result_effects, audit_context: None, task_grant: None, @@ -84,6 +87,35 @@ impl ActionClaimContext { Ok(context) } + pub(crate) fn with_target_memberships( + mut self, + memberships: BTreeMap>, + ) -> Self { + self.target_memberships = memberships; + self + } + + pub(crate) fn locks_membership(&self) -> bool { + !self.target_memberships.is_empty() + } + + pub(crate) fn is_membership_source(&self, entity: &str) -> bool { + self.target_memberships + .values() + .flatten() + .any(|boundary| boundary.membership_entity == entity) + } + + pub(crate) fn target_membership( + &self, + entity: &str, + ) -> &[crate::model::CompiledMembershipBoundary] { + self.target_memberships + .get(entity) + .map(Vec::as_slice) + .unwrap_or_default() + } + /// Name the issuer that verified the caller. Its keys and proposals are /// recorded under it. An issuer in the engine's reserved namespace is /// refused. @@ -617,6 +649,25 @@ impl ClaimContext { entity: &crate::model::CompiledEntity, row: &serde_json::Map, record_id: Uuid, + ) -> Result { + self.authorizes_record_snapshot_at(entity, row, record_id, false) + } + + pub(crate) fn authorizes_record_snapshot_before_allocation( + &self, + entity: &crate::model::CompiledEntity, + row: &serde_json::Map, + record_id: Uuid, + ) -> Result { + self.authorizes_record_snapshot_at(entity, row, record_id, true) + } + + fn authorizes_record_snapshot_at( + &self, + entity: &crate::model::CompiledEntity, + row: &serde_json::Map, + record_id: Uuid, + before_allocation: bool, ) -> Result { self.validate()?; if entity.id != self.entity_id { @@ -625,13 +676,23 @@ impl ClaimContext { // A state the profile may not see is outside its boundary, as the // restrictive disclosure policies would refuse it. A state that // cannot be evaluated counts as withheld. - if crate::disclosure::plan(entity, &self.access_profile) - .withholds_record(row) - .unwrap_or(true) - { + let disclosure = crate::disclosure::plan(entity, &self.access_profile); + let withheld = if before_allocation { + disclosure.withholds_record_before_allocation(row) + } else { + disclosure.withholds_record(row) + }; + if withheld.unwrap_or(true) { return Ok(false); } - snapshot_matches_boundaries(entity, row, record_id, &self.row_boundaries) + snapshot_matches_selected_boundaries( + entity, + row, + record_id, + self.row_boundaries + .iter() + .filter(|boundary| !before_allocation || !is_allocated_field(entity, boundary)), + ) } } @@ -727,6 +788,7 @@ pub(crate) struct ImmediateActionTargetContext { lock_only: bool, application_id: Option, target_row_boundaries: Vec, + membership_boundaries: Vec, timer: Option, canonical_context: String, } @@ -801,6 +863,10 @@ impl ImmediateActionTargetContext { &target_boundaries, &target_grant.row_boundaries, )?; + let membership_boundaries = action_claims.target_membership(&binding.target_entity_id); + if membership_boundaries != target_grant.membership_boundaries { + return Err(invalid_context()); + } let mut context = Self { action_id: binding.action_id, contract_fingerprint: binding.contract_fingerprint, @@ -817,6 +883,7 @@ impl ImmediateActionTargetContext { lock_only: binding.lock_only, application_id: binding.application_id, target_row_boundaries: target_boundaries, + membership_boundaries: membership_boundaries.to_vec(), timer: None, canonical_context: String::new(), }; @@ -925,6 +992,7 @@ impl ImmediateActionTargetContext { lock_only: binding.lock_only, application_id: binding.application_id, target_row_boundaries: Vec::new(), + membership_boundaries: Vec::new(), timer: Some(TimerActionTargetAuthority { timer_id: timer.id.clone(), target_input_id: None, @@ -1041,6 +1109,7 @@ impl ImmediateActionTargetContext { lock_only: binding.lock_only, application_id: binding.application_id, target_row_boundaries: Vec::new(), + membership_boundaries: Vec::new(), timer: Some(TimerActionTargetAuthority { timer_id: timer.id.clone(), target_input_id: target_input_id.map(str::to_owned), @@ -1061,11 +1130,41 @@ impl ImmediateActionTargetContext { Ok(context) } + pub(crate) fn membership_boundaries(&self) -> &[crate::model::CompiledMembershipBoundary] { + &self.membership_boundaries + } + #[must_use] pub(crate) fn canonical_context(&self) -> &str { &self.canonical_context } + pub(crate) fn authorize_create_before_allocation( + &self, + entity: &crate::model::CompiledEntity, + row: &serde_json::Map, + record_id: Uuid, + ) -> Result<()> { + self.validate()?; + if self.operation != Operation::Create + || entity.id != self.target_entity_id + || record_id != self.target_record_id + { + return Err(invalid_context()); + } + if !snapshot_matches_selected_boundaries( + entity, + row, + record_id, + self.target_row_boundaries + .iter() + .filter(|boundary| !is_allocated_field(entity, boundary)), + )? { + return Err(invalid_context()); + } + Ok(()) + } + pub(crate) fn authorize_rows( &self, target_entity: &crate::model::CompiledEntity, @@ -1311,6 +1410,7 @@ pub(crate) struct ImmediateActionLinkContext { target_entity_id: String, target_record_id: Uuid, target_row_boundaries: Vec, + membership_boundaries: Vec, canonical_context: String, } @@ -1383,6 +1483,10 @@ impl ImmediateActionLinkContext { &target_boundaries, &target_grant.row_boundaries, )?; + let membership_boundaries = action_claims.target_membership(&binding.target_entity_id); + if membership_boundaries != target_grant.membership_boundaries { + return Err(invalid_context()); + } let mut context = Self { action_id: binding.action_id, contract_fingerprint: binding.contract_fingerprint, @@ -1395,6 +1499,7 @@ impl ImmediateActionLinkContext { target_entity_id: binding.target_entity_id, target_record_id: binding.target_record_id, target_row_boundaries: target_boundaries, + membership_boundaries: membership_boundaries.to_vec(), canonical_context: String::new(), }; context.canonical_context = Self::canonicalize(&context)?; @@ -1402,6 +1507,10 @@ impl ImmediateActionLinkContext { Ok(context) } + pub(crate) fn membership_boundaries(&self) -> &[crate::model::CompiledMembershipBoundary] { + &self.membership_boundaries + } + #[must_use] pub(crate) fn canonical_context(&self) -> &str { &self.canonical_context @@ -1701,6 +1810,25 @@ pub(crate) fn snapshot_matches_boundaries( row: &serde_json::Map, record_id: Uuid, boundaries: &[RowBoundaryContext], +) -> Result { + snapshot_matches_selected_boundaries(entity, row, record_id, boundaries) +} + +fn is_allocated_field( + entity: &crate::model::CompiledEntity, + boundary: &RowBoundaryContext, +) -> bool { + entity + .fields + .get(boundary.field()) + .is_some_and(|field| field.generate.is_some()) +} + +fn snapshot_matches_selected_boundaries<'a>( + entity: &crate::model::CompiledEntity, + row: &serde_json::Map, + record_id: Uuid, + boundaries: impl IntoIterator, ) -> Result { for boundary in boundaries { let (actual, field_type) = if boundary.field() == entity.canonical_id.id { @@ -1922,21 +2050,7 @@ impl GuardedTransaction<'_> { /// outruns the budget fails its read instead of holding the shared /// Registry lock and a pooled connection for an unbounded time. pub(crate) async fn set_statement_budget(&self, budget: Duration) -> Result<()> { - if budget.is_zero() || budget > Duration::from_secs(30) { - return Err(PostgresKernelError::Configuration( - "statement budget must be between 1 millisecond and 30 seconds", - )); - } - let budget_millis = i32::try_from(budget.as_millis()).map_err(|_| { - PostgresKernelError::Configuration("statement budget is outside PostgreSQL bounds") - })?; - self.transaction - .execute( - "SELECT set_config('statement_timeout', $1::text, true)", - &[&format!("{budget_millis}ms")], - ) - .await?; - Ok(()) + set_transaction_statement_budget(&self.transaction, budget).await } pub async fn commit(self) -> Result<()> { @@ -1982,6 +2096,27 @@ impl GuardedTransaction<'_> { } } +pub(crate) async fn set_transaction_statement_budget( + transaction: &Transaction<'_>, + budget: Duration, +) -> Result<()> { + if budget.is_zero() || budget > Duration::from_secs(30) { + return Err(PostgresKernelError::Configuration( + "statement budget must be between 1 millisecond and 30 seconds", + )); + } + let budget_millis = i32::try_from(budget.as_millis()).map_err(|_| { + PostgresKernelError::Configuration("statement budget is outside PostgreSQL bounds") + })?; + transaction + .execute( + "SELECT set_config('statement_timeout', $1::text, true)", + &[&format!("{budget_millis}ms")], + ) + .await?; + Ok(()) +} + #[derive(Debug)] pub(crate) enum RegistryLockFailure { Timeout, @@ -2014,7 +2149,17 @@ pub(crate) async fn begin_registry_transaction<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, ) -> Result> { - begin_registry_transaction_with_reason(client, lock_key, lock_timeout, expected) + begin_registry_transaction_at_isolation(client, lock_key, lock_timeout, expected, None).await +} + +async fn begin_registry_transaction_at_isolation<'a>( + client: &'a mut Client, + lock_key: RegistryLockKey, + lock_timeout: Duration, + expected: &ExpectedRegistryIdentity, + isolation: Option, +) -> Result> { + begin_registry_transaction_inner(client, lock_key, lock_timeout, expected, false, isolation) .await .map_err(|error| match error { RegistryTransactionError::Kernel(error) => error, @@ -2035,7 +2180,7 @@ pub(crate) async fn begin_registry_transaction_with_reason<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, ) -> std::result::Result, RegistryTransactionError> { - begin_registry_transaction_inner(client, lock_key, lock_timeout, expected, false).await + begin_registry_transaction_inner(client, lock_key, lock_timeout, expected, false, None).await } pub(crate) async fn begin_registry_read_transaction_with_reason<'a>( @@ -2044,7 +2189,7 @@ pub(crate) async fn begin_registry_read_transaction_with_reason<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, ) -> std::result::Result, RegistryTransactionError> { - begin_registry_transaction_inner(client, lock_key, lock_timeout, expected, true).await + begin_registry_transaction_inner(client, lock_key, lock_timeout, expected, true, None).await } async fn begin_registry_transaction_inner<'a>( @@ -2053,6 +2198,7 @@ async fn begin_registry_transaction_inner<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, read_only: bool, + isolation: Option, ) -> std::result::Result, RegistryTransactionError> { expected.validate()?; if lock_timeout.is_zero() || lock_timeout > Duration::from_secs(30) { @@ -2061,7 +2207,16 @@ async fn begin_registry_transaction_inner<'a>( ) .into()); } - let transaction = client.transaction().await?; + let transaction = match isolation { + Some(level) => { + client + .build_transaction() + .isolation_level(level) + .start() + .await? + } + None => client.transaction().await?, + }; if read_only { transaction .batch_execute("SET TRANSACTION READ ONLY") @@ -2098,6 +2253,15 @@ async fn begin_registry_transaction_inner<'a>( _ => RegistryLockFailure::Database, }) })?; + verify_registry_transaction_identity(&transaction, lock_key, expected).await?; + Ok(GuardedTransaction { transaction }) +} + +pub(crate) async fn verify_registry_transaction_identity( + transaction: &tokio_postgres::Transaction<'_>, + lock_key: RegistryLockKey, + expected: &ExpectedRegistryIdentity, +) -> std::result::Result<(), RegistryTransactionError> { let state = transaction .query_typed_opt( "SELECT package_id, database_id, active_package_digest, @@ -2119,11 +2283,11 @@ async fn begin_registry_transaction_inner<'a>( if !ready { return Err(PostgresKernelError::RegistryUnavailable.into()); } - let timer_protocol = super::timer::read_timer_protocol(&*transaction).await?; + let timer_protocol = super::timer::read_timer_protocol(transaction).await?; if timer_protocol.protocol_version != super::timer::SUPPORTED_TIMER_PROTOCOL_VERSION { return Err(RegistryTransactionError::TimerProtocolUnsupported); } - Ok(GuardedTransaction { transaction }) + Ok(()) } /// Starts a record transaction and installs authority only after the shared @@ -2134,9 +2298,29 @@ pub async fn begin_record_transaction<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, claims: &ClaimContext, +) -> Result> { + begin_record_transaction_for_write(client, lock_key, lock_timeout, expected, claims, false) + .await +} + +pub(crate) async fn begin_record_transaction_for_write<'a>( + client: &'a mut Client, + lock_key: RegistryLockKey, + lock_timeout: Duration, + expected: &ExpectedRegistryIdentity, + claims: &ClaimContext, + locks_membership: bool, ) -> Result> { claims.validate()?; - let guarded = begin_registry_transaction(client, lock_key, lock_timeout, expected).await?; + let isolation = locks_membership.then_some(IsolationLevel::ReadCommitted); + let guarded = begin_registry_transaction_at_isolation( + client, + lock_key, + lock_timeout, + expected, + isolation, + ) + .await?; let transaction = guarded.transaction(); // A JSON array of strings; `[]` for a client no organization lists. let recipients = serde_json::to_string(&claims.recipients).map_err(|_| invalid_context())?; @@ -2170,9 +2354,29 @@ pub async fn begin_action_transaction<'a>( lock_timeout: Duration, expected: &ExpectedRegistryIdentity, claims: &ActionClaimContext, +) -> Result> { + begin_action_transaction_for_write(client, lock_key, lock_timeout, expected, claims, false) + .await +} + +pub(crate) async fn begin_action_transaction_for_write<'a>( + client: &'a mut Client, + lock_key: RegistryLockKey, + lock_timeout: Duration, + expected: &ExpectedRegistryIdentity, + claims: &ActionClaimContext, + locks_membership: bool, ) -> Result> { claims.validate()?; - let guarded = begin_registry_transaction(client, lock_key, lock_timeout, expected).await?; + let isolation = locks_membership.then_some(IsolationLevel::ReadCommitted); + let guarded = begin_registry_transaction_at_isolation( + client, + lock_key, + lock_timeout, + expected, + isolation, + ) + .await?; let transaction = guarded.transaction(); transaction .execute( @@ -2691,10 +2895,10 @@ mod tests { "disclosureConditions":{"hide": {"when":[{"type":"field-equals","field":"level","value":"secret"}], "withhold":"record","exemptProfiles":["officer"]}}}}, "accessProfiles":{ - "clerk": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "clerk": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{"recordType":"entry","operations":["get","create"], "rowBoundaries":"unrestricted","readableFields":["level"],"writableFields":["level"]}]}}, - "officer": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "officer": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{"recordType":"entry","operations":["get","create"], "rowBoundaries":"unrestricted","readableFields":["level"],"writableFields":["level"]}]}}}}); let project = crate::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()) @@ -3175,7 +3379,7 @@ mod tests { "accessProfiles":{"contact-registrar": { "default":true, "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["contact-registration"], "permissions":{"actions":[{ "action":"rename-household-local", diff --git a/crates/registry-breg/src/postgres/interlock.rs b/crates/registry-breg/src/postgres/interlock.rs index 23a1a5c55d..b6ca9b2fc1 100644 --- a/crates/registry-breg/src/postgres/interlock.rs +++ b/crates/registry-breg/src/postgres/interlock.rs @@ -109,6 +109,7 @@ pub(crate) struct PackageDdlStatement<'a> { pub checksum: &'a str, pub kind: DdlStatementKind, pub pattern_field: Option<(&'a str, &'a str)>, + pub membership_source: Option<&'a str>, pub ordinal: i32, } @@ -445,6 +446,7 @@ impl DedicatedApplyConnection { statement.sql, statement.kind, statement.pattern_field, + statement.membership_source, runtime_role, ) .await @@ -898,6 +900,7 @@ impl DedicatedApplyConnection { statement.sql, statement.kind, statement.pattern_field, + statement.membership_source, runtime_role, ) .await?; @@ -3070,6 +3073,7 @@ async fn execute_initial_package_ddl_in( statement.sql, statement.kind, statement.pattern_field, + statement.membership_source, runtime_role, ) .await?; @@ -3080,6 +3084,7 @@ async fn execute_initial_package_ddl_in( statement.sql, statement.kind, statement.pattern_field, + statement.membership_source, runtime_role, ) .await?; @@ -5086,6 +5091,7 @@ mod tests { checksum: "", kind, pattern_field: None, + membership_source: None, ordinal: 0, }; assert!(compiler_statement_runs_after_reviewed_steps(&statement( @@ -5171,7 +5177,7 @@ mod tests { "accessProfiles": {"caseworker": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "case", "rowBoundaries": "unrestricted", diff --git a/crates/registry-breg/src/postgres/mod.rs b/crates/registry-breg/src/postgres/mod.rs index b861eadbed..a163c8f926 100644 --- a/crates/registry-breg/src/postgres/mod.rs +++ b/crates/registry-breg/src/postgres/mod.rs @@ -56,7 +56,8 @@ pub use config::{ TlsPolicy, }; pub(crate) use context::{ - begin_action_transaction, begin_timer_action_transaction, + begin_action_transaction, begin_action_transaction_for_write, + begin_record_transaction_for_write, begin_timer_action_transaction, create_row_matches_request_boundaries, snapshot_matches_boundaries, validate_invoke_target_boundaries, ActionClaimContext, ImmediateActionLinkBinding, ImmediateActionLinkContext, ImmediateActionTargetBinding, ImmediateActionTargetContext, @@ -70,7 +71,8 @@ pub use context::{ }; pub(crate) use context::{ begin_registry_read_transaction_with_reason, begin_registry_transaction, - begin_registry_transaction_with_reason, RegistryLockFailure, RegistryTransactionError, + begin_registry_transaction_with_reason, set_transaction_statement_budget, + verify_registry_transaction_identity, RegistryLockFailure, RegistryTransactionError, }; pub(crate) use context::{install_spatial_bbox_context, validate_field_value, SpatialBboxContext}; pub use failure::PostgresFailure; @@ -103,7 +105,7 @@ pub(crate) use migration_ledger::{ MigrationLedgerEntry, MigrationLedgerStep, MigrationLedgerStepKind, }; pub use migration_ledger::{ActivationPlanKind, RoleMode}; -pub(crate) use mutation::api_boundary; +pub(crate) use mutation::{api_boundary, ActionTargetMembershipObservation}; pub use mutation::{ IngestionChunkSubmitInput, IngestionRunCreateInput, IngestionRunListQuery, IngestionServiceError, PostgresRecordMutationService, @@ -231,7 +233,6 @@ pub use roles::{ spatial_bbox_role, verify_btree_gist, verify_migration_role, verify_postgis, RuntimeWriteAuthority, SqlIdentifier, MIN_POSTGIS_MAJOR, MIN_POSTGIS_MINOR, }; -pub(crate) use schema::compiled_pattern_field; pub use schema::install_compiled_schema; #[cfg(feature = "postgres-test")] #[doc(hidden)] @@ -239,6 +240,7 @@ pub use schema::reconcile_compiled_runtime_acl_for_test; pub(crate) use schema::verify_postgres_17_or_newer; #[cfg(all(feature = "runtime", feature = "tooling"))] pub(crate) use schema::PreparedSchemaTestCatalogVerifier; +pub(crate) use schema::{compiled_membership_source, compiled_pattern_field}; #[cfg(all(feature = "runtime", feature = "tooling"))] pub use schema::{ prepare_schema_test_database_with_connections, PreparedSchemaTestDatabase, SchemaMeasurement, @@ -407,6 +409,10 @@ pub enum PostgresKernelError { FieldPatternSyntax { entity_id: String, field_id: String }, #[error("existing rows do not conform to a persisted field pattern")] FieldPatternExistingRows { entity_id: String, field_id: String }, + /// Authored identifiers only; key and principal values never cross this + /// boundary. + #[error("existing active membership rows repeat a key and principal")] + MembershipDuplicateLiveRows { entity_id: String }, /// Authored record identifiers only; field values never cross this boundary. #[error("field-encryption backfill would collide blind indexes of existing records")] FieldEncryptionBlindCollision { diff --git a/crates/registry-breg/src/postgres/mutation.rs b/crates/registry-breg/src/postgres/mutation.rs index 5c7e99c70a..71806ab3c7 100644 --- a/crates/registry-breg/src/postgres/mutation.rs +++ b/crates/registry-breg/src/postgres/mutation.rs @@ -37,6 +37,13 @@ use super::{ pub(super) const REQUEST_ACTION_TIMEOUT: Duration = Duration::from_secs(30); +pub(crate) enum ActionTargetMembershipObservation { + Authorized, + OutsideBoundary, + Withheld, + Missing, +} + fn action_timeout_for_http_deadline(http_request_timeout: Duration) -> Duration { REQUEST_ACTION_TIMEOUT.min(http_request_timeout) } @@ -434,6 +441,7 @@ impl PostgresRecordMutationService { deadline, self.coordinator.execute_immediate_action( guard.client(), + &self.pool, &self.registry, input, &claims, @@ -562,6 +570,96 @@ impl PostgresRecordMutationService { result } + pub(crate) async fn observe_action_target_membership( + &self, + context: &AuthorizedRequestContext, + entity: &crate::model::CompiledEntity, + record: uuid::Uuid, + revision: i64, + memberships: &[crate::model::CompiledMembershipBoundary], + disclosed_fields: &std::collections::BTreeSet, + ) -> Result { + let claims = strict_claim_context(&self.registry, context, &entity.id)?; + let client = self + .pool + .get() + .await + .map_err(|_| MutationError::Unavailable)?; + let mut guard = QueryCancellationGuard::new(self.pool.clone(), client); + let guarded = super::begin_record_transaction( + guard.client(), + self.lock_key, + self.lock_timeout, + &self.expected, + &claims, + ) + .await + .map_err(|_| MutationError::Unavailable)?; + let predicates = memberships + .iter() + .map(|boundary| { + let probe = crate::membership::RowProbe { + function: crate::membership::target_function_name( + claims.access_profile(), + &boundary.membership_entity, + ), + field: boundary.field.clone(), + form: crate::membership::RowProbeForm::PerKey, + }; + if probe.field == entity.canonical_id.id { + probe.sql("record_id") + } else { + probe.sql(&format!( + "\"{}\"", + entity.fields[&probe.field].physical_name + )) + } + }) + .collect::>() + .join(" AND "); + let disclosure = crate::disclosure::plan(entity, claims.access_profile()); + let mut withholds = disclosure + .conditions() + .iter() + .filter_map(|condition| { + let crate::model::DisclosureWithhold::Fields(fields) = &condition.withhold else { + return None; + }; + (!fields.is_disjoint(disclosed_fields)).then(|| { + crate::disclosure::when_sql(entity, &condition.when, &|field| { + format!("\"{}\"", entity.fields[field].physical_name) + }) + }) + }) + .collect::>(); + withholds.push("false".into()); + let withheld = withholds.join(" OR "); + // Check the Action's boundary on the same revision as the ordinary + // GET. Evaluate field withholding only for an admitted target. + let sql = format!( + "SELECT CASE WHEN ({predicates}) IS NOT TRUE THEN false + WHEN ({withheld}) IS TRUE THEN NULL + ELSE true END + FROM registry_data.\"{}\" WHERE record_id=$1 AND record_revision=$2 AND record_lifecycle='active'", + entity.physical_table, + ); + let row = guarded + .transaction() + .query_opt(&sql, &[&record, &revision]) + .await + .map_err(|_| MutationError::Unavailable)?; + drop(guarded); + guard.disarm(); + let Some(row) = row else { + return Ok(ActionTargetMembershipObservation::Missing); + }; + match row.try_get(0).map_err(|_| MutationError::Unavailable)? { + Some(true) => Ok(ActionTargetMembershipObservation::Authorized), + Some(false) => Ok(ActionTargetMembershipObservation::OutsideBoundary), + None => Ok(ActionTargetMembershipObservation::Withheld), + } + } + pub async fn action_target_conditions( &self, input: ActionTargetConditionsInput<'_>, @@ -1905,6 +2003,7 @@ impl PostgresRecordMutationService { return self .finish_ingestion_submission( context, + correlation, &input, self.coordinator .execute_batch_with_fault(&mut writer, request, fault) @@ -1914,6 +2013,7 @@ impl PostgresRecordMutationService { } self.finish_ingestion_submission( context, + correlation, &input, self.coordinator.execute_batch(&mut writer, request).await, ) @@ -2011,6 +2111,7 @@ impl PostgresRecordMutationService { async fn finish_ingestion_submission( &self, context: &AuthorizedRequestContext, + correlation: &RequestCorrelation, input: &IngestionChunkSubmitInput, outcome: Result, ) -> Result { @@ -2055,6 +2156,13 @@ impl PostgresRecordMutationService { IngestionAttemptOutcome::InvalidItem, Some(IngestionServiceError::RequestInvalid), ), + MutationError::MembershipPreconditionFailed + | MutationError::MembershipWriteOutsideBoundary => { + crate::correlation::record_refusal_check( + registry_platform_authcommon::FailedCheck::Membership, correlation, + ); + (IngestionAttemptOutcome::Refused, Some(IngestionServiceError::PreconditionFailed)) + } MutationError::PreconditionFailed | MutationError::ProposalTargetChanged | MutationError::FieldGuardFailed { .. } @@ -2063,6 +2171,8 @@ impl PostgresRecordMutationService { | MutationError::Conflict | MutationError::ProposalUniqueConflict | MutationError::ProposalRejected + | MutationError::ProposalSubjectNotCaller + | MutationError::ProposalSubjectChanged | MutationError::AuthorizationRefused(_) // Ingestion consumes the batch mutation outcome through // its run protocol. Its item refusal remains the generic @@ -2077,6 +2187,7 @@ impl PostgresRecordMutationService { | MutationError::IdempotencyExpired | MutationError::Unavailable | MutationError::RetryableConflict + | MutationError::MembershipKeyDrift | MutationError::CommitUnresolved | MutationError::MigrationLockHeld | MutationError::PostureMismatch { .. } @@ -2448,7 +2559,11 @@ fn strict_action_context( context.purpose().map(str::to_owned), context.result_effects().clone(), ) - .map(|claims| claims.with_audit_context(context.audit_context().cloned())) + .map(|claims| { + claims + .with_target_memberships(context.target_memberships().clone()) + .with_audit_context(context.audit_context().cloned()) + }) .and_then(|claims| claims.with_verified_issuer(context.caller_issuer())) .and_then(|claims| match context.task_grant() { Some(binding) => claims.with_task_grant(binding.clone()), diff --git a/crates/registry-breg/src/postgres/proposal.rs b/crates/registry-breg/src/postgres/proposal.rs index 2d658246c1..ed4cb34bf6 100644 --- a/crates/registry-breg/src/postgres/proposal.rs +++ b/crates/registry-breg/src/postgres/proposal.rs @@ -6,7 +6,7 @@ use super::*; use crate::api::proposals::ReviewDocumentSource; use crate::api::proposals::{ProposalListQuery, ProposalMutationInput}; use crate::api::VerifiedRequestClaims; -use crate::model::{ProposalOperation, ProposalOwnership}; +use crate::model::{ProposalOperation, ProposalParty}; use crate::mutation::{link_readable, CheckedProposalTaskAuthority, ProposalApplyPreflight}; use crate::postgres::{begin_proposal_transaction, ProposalAuthority, ProposalAuthorityOperation}; use crate::proposal_store; @@ -24,19 +24,22 @@ struct ProposalReviewSnapshot { } // Keep status selection in the single candidate query before its scan bound. -// Caller ownership is exact here, so another holder's Proposal never reaches a -// per-candidate read; `$4` pairs each `$1` Action with the caller's owner -// reference, or NULL when that authority is not ownership-scoped. `$5` and `$6` +// Party binding is exact here, so another holder's Proposal never reaches a +// per-candidate read; `$4` and `$7` pair each `$1` Action with the caller's +// owner or subject reference, both NULL when that authority is bound to no +// party. `$5` and `$6` // are the caller's optional `action` and `state` filters: they only narrow rows // the collection authority already lists, so applying them here spends the scan // budget on candidates that can match without revealing anything further. -const PROPOSAL_LIST_CANDIDATES: &str = "SELECT p.proposal_id,p.action_id,p.workflow_revision,({open_ask}) AS ask_open FROM registry_internal.registry_proposal_state p +const PROPOSAL_LIST_CANDIDATES: &str = "SELECT p.proposal_id,p.action_id,p.workflow_revision,({open_ask}) AS ask_open,p.owner_reference,p.subject_reference FROM registry_internal.registry_proposal_state p WHERE p.action_id=ANY($1) AND ($2::uuid IS NULL OR p.proposal_id>$2) AND ($5::text IS NULL OR p.action_id=$5) AND ($6::text IS NULL OR p.state=$6) - AND EXISTS (SELECT 1 FROM unnest($1::text[],$4::text[]) AS a(action_id,owner_reference) + AND EXISTS (SELECT 1 FROM unnest($1::text[],$4::text[],$7::text[]) AS a(action_id,owner_reference,subject_reference) WHERE a.action_id=p.action_id - AND (a.owner_reference IS NULL OR a.owner_reference=p.owner_reference)) + AND ((a.owner_reference IS NULL AND a.subject_reference IS NULL) + OR a.owner_reference=p.owner_reference + OR a.subject_reference=p.subject_reference)) AND (NOT $3 OR (p.state='submitted' AND p.blocked_reason IS NULL AND EXISTS ( SELECT 1 FROM registry_internal.registry_proposal_submissions s LEFT JOIN registry_internal.registry_proposal_review_submissions review @@ -79,6 +82,7 @@ impl PostgresRecordMutationService { &vec![None::; actions.len()], &Option::::None, &Option::::None, + &vec![None::; actions.len()], ], ) .await @@ -413,6 +417,26 @@ impl PostgresRecordMutationService { authority, ) .await?; + // The admitting entry, party included, must still read this + // slot: the route chose it before the document was locked. + let readable = self + .registry + .actions() + .actions + .iter() + .find(|action| action.id == document.action_id) + .and_then(|action| match &action.execution { + crate::model::CompiledActionExecution::Proposal { proposal } => { + authority.permission(proposal) + } + crate::model::CompiledActionExecution::Immediate => None, + }) + .is_some_and(|grant| grant.readable_attachments.contains(slot)); + if !readable { + return Err(MutationError::AuthorizationRefused( + registry_platform_authcommon::FailedCheck::Visibility, + )); + } } if document.header.submission_version != i64::from(version) { return Err(MutationError::PreconditionFailed); @@ -603,20 +627,20 @@ impl PostgresRecordMutationService { pub(crate) async fn proposal_route_target( &self, id: Uuid, - ) -> Result, MutationError> { + ) -> Result)>, MutationError> { let deadline = tokio::time::Instant::now() + self.action_timeout; let client = tokio::time::timeout_at(deadline, self.pool.get()) .await .map_err(|_| MutationError::Unavailable)? .map_err(|_| MutationError::Unavailable)?; let mut guard = QueryCancellationGuard::new(self.pool.clone(), client); - let sql = "SELECT action_id, owner_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1"; + let sql = "SELECT action_id, owner_reference, subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1"; match tokio::time::timeout_at(deadline, guard.client().query_opt(sql, &[&id])).await { Ok(row) => { guard.disarm(); Ok(row .map_err(|_| MutationError::Unavailable)? - .map(|row| (row.get(0), row.get(1)))) + .map(|row| (row.get(0), row.get(1), row.get(2)))) } Err(_) => { guard.cancel_and_discard().await; @@ -625,13 +649,140 @@ impl PostgresRecordMutationService { } } - pub(crate) fn proposal_owner_matches( + /// The party match of the verified caller on one Proposal, from its + /// stored owner and subject references. + pub(crate) fn party_selection( + &self, + claims: &crate::api::VerifiedRequestClaims, + owner_reference: &str, + subject_reference: Option<&str>, + ) -> crate::api::proposals::PartySelection { + let Some(principal) = claims.principal() else { + return crate::api::proposals::PartySelection::Proposal { + owner: false, + subject: false, + }; + }; + crate::api::proposals::PartySelection::Proposal { + owner: self.coordinator.proposal_owner_reference( + self.coordinator.caller_issuer(claims.caller_issuer()), + principal, + ) == owner_reference, + subject: self.coordinator.proposal_subject_matches( + subject_reference, + principal, + crate::api::proposals::acts_for_self(claims), + ), + } + } + + /// The List authority that governs the caller on one candidate: the + /// profile's entry bound to no party, else its owner entry for a + /// Proposal the caller filed, else its subject entry. None when the + /// governing entry does not hold List. + fn governing_list_authority<'a>( + &self, + authorities: &'a [ProposalAuthority], + action_id: &str, + owner_reference: &str, + subject_reference: Option<&str>, + ) -> Option<&'a ProposalAuthority> { + let mut candidates = authorities + .iter() + .filter(|authority| authority.common.action_id() == action_id); + let first = candidates.clone().next()?; + let action = self + .registry + .actions() + .actions + .iter() + .find(|action| action.id == action_id)?; + let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution else { + return None; + }; + let person = authorities + .iter() + .filter(|authority| authority.common.action_id() == action_id) + .any(|authority| authority.person); + let parties = crate::api::proposals::PartySelection::Proposal { + owner: self.coordinator.proposal_owner_of(&first.common) == owner_reference, + subject: self.coordinator.proposal_subject_matches( + subject_reference, + first.common.principal(), + person, + ), + }; + let grant = crate::api::proposals::select_proposal_grant( + proposal, + first.common.access_profile(), + ProposalOperation::List, + parties, + )?; + candidates.find(|authority| authority.party == grant.party) + } + + /// Whether a `target` filter matches a Proposal for this authority. A + /// subject's filter matches only through the reference inputs its entry + /// reads, so it cannot learn a reference its projection hides. + fn target_filter_matches( + &self, + document: &proposal_store::ProposalDocument, + authority: &ProposalAuthority, + target: Uuid, + ) -> bool { + if authority.party != Some(ProposalParty::Subject) { + return document.input_targets.iter().any(|(_, id)| *id == target); + } + let Some(action) = self + .registry + .actions() + .actions + .iter() + .find(|action| action.id == document.action_id) + else { + return false; + }; + let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution else { + return false; + }; + let Some(permission) = authority.permission(proposal) else { + return false; + }; + let target = target.to_string(); + action.inputs.iter().any(|input| { + matches!( + input.field_type, + crate::contract::FieldTypeSource::Reference { .. } + ) && permission.readable_inputs.contains(&input.id) + && document + .input + .as_ref() + .and_then(|values| values.get(&input.id)) + .and_then(Value::as_str) + == Some(target.as_str()) + }) + } + + /// Whether the admitting entry's party matches the caller on the + /// Proposal. An entry bound to no party always does; the transaction + /// checks again. + pub(crate) fn proposal_party_matches( &self, authority: &ProposalAuthority, owner_reference: &str, + subject_reference: Option<&str>, ) -> bool { - authority.ownership != Some(ProposalOwnership::Caller) - || self.coordinator.proposal_owner_of(&authority.common) == owner_reference + party_admits( + authority.party, + || self.coordinator.proposal_owner_of(&authority.common) == owner_reference, + || { + self.coordinator.proposal_subject_matches( + subject_reference, + authority.common.principal(), + authority.person, + ) + }, + ) } pub(crate) async fn proposal_visible( @@ -1584,10 +1735,25 @@ impl PostgresRecordMutationService { let owner_references = authorities .iter() .map(|authority| { - (authority.ownership == Some(crate::model::ProposalOwnership::Caller)) + (authority.party == Some(ProposalParty::Owner)) .then(|| self.coordinator.proposal_owner_of(&authority.common)) }) .collect::>(); + // A subject authority lists only for a person acting for themselves; + // any other caller's subject entry matches no Proposal. + let subject_references = authorities + .iter() + .map(|authority| { + (authority.party == Some(ProposalParty::Subject)).then(|| { + if authority.person { + self.coordinator + .proposal_subject_reference(authority.common.principal()) + } else { + String::new() + } + }) + }) + .collect::>(); let mut after = query.after; let mut items = Vec::new(); let mut has_more = false; @@ -1610,6 +1776,7 @@ impl PostgresRecordMutationService { &owner_references, &query.action, &query.state, + &subject_references, ], ) .await @@ -1622,10 +1789,12 @@ impl PostgresRecordMutationService { let id: Uuid = candidate.get(0); let action_id: String = candidate.get(1); after = Some(id); - let Some(authority) = authorities - .iter() - .find(|authority| authority.common.action_id() == action_id) - else { + let Some(authority) = self.governing_list_authority( + authorities, + &action_id, + &candidate.get::<_, String>(4), + candidate.get::<_, Option>(5).as_deref(), + ) else { continue; }; let guarded = begin_proposal_transaction( @@ -1646,27 +1815,21 @@ impl PostgresRecordMutationService { .await?; #[cfg(feature = "postgres-test")] self.pause_proposal_read_for_test().await; - match self - .coordinator - .authorize_proposal_document( - guarded.transaction(), - &self.registry, - &document, - authority, - ) - .await - { - Ok(()) => {} - Err( - MutationError::AuthorizationRefused(_) | MutationError::PreconditionFailed, - ) => { - guarded - .rollback() - .await - .map_err(|_| MutationError::Unavailable)?; - continue; - } - Err(error) => return Err(error), + if !link_readable( + self.coordinator + .authorize_proposal_document( + guarded.transaction(), + &self.registry, + &document, + authority, + ) + .await, + )? { + guarded + .rollback() + .await + .map_err(|_| MutationError::Unavailable)?; + continue; } // Only an authorized UUID may become a continuation. An extra // authorized candidate proves another bounded page is useful. @@ -1693,7 +1856,7 @@ impl PostgresRecordMutationService { || document.header.owner_reference == self.coordinator.proposal_owner_of(&authority.common)) && query.target.is_none_or(|target| { - document.input_targets.iter().any(|(_, id)| *id == target) + self.target_filter_matches(&document, authority, target) }); if matches { let value = self @@ -1790,7 +1953,10 @@ impl PostgresRecordMutationService { items .iter() .filter(|item| { + // Each party's entry counts only the items it governed. item["actionId"].as_str() == Some(authority.common.action_id()) + && item.get("partyRole") + == authority.party.map(|party| json!(party)).as_ref() }) .count() }), @@ -1826,6 +1992,7 @@ mod tests { registry_platform_authcommon::FailedCheck::Ownership, ), MutationError::PreconditionFailed, + MutationError::MembershipPreconditionFailed, ] { assert_eq!(link_readable(Err(refusal)), Ok(false)); } @@ -1843,3 +2010,40 @@ mod tests { } } } + +/// The route-level party decision: an entry bound to no party admits, an +/// owner entry admits only the owner, and a subject entry only the subject. +fn party_admits( + party: Option, + owner: impl FnOnce() -> bool, + subject: impl FnOnce() -> bool, +) -> bool { + match party { + None => true, + Some(ProposalParty::Owner) => owner(), + Some(ProposalParty::Subject) => subject(), + } +} + +#[cfg(test)] +mod party_admission_tests { + use super::*; + + #[test] + fn each_party_entry_admits_only_its_own_party() { + for (party, owner, subject, admitted) in [ + (None, false, false, true), + (Some(ProposalParty::Owner), true, false, true), + (Some(ProposalParty::Owner), false, true, false), + (Some(ProposalParty::Subject), false, true, true), + (Some(ProposalParty::Subject), true, false, false), + (Some(ProposalParty::Subject), false, false, false), + ] { + assert_eq!( + party_admits(party, || owner, || subject), + admitted, + "{party:?} owner={owner} subject={subject}" + ); + } + } +} diff --git a/crates/registry-breg/src/postgres/proposal_context.rs b/crates/registry-breg/src/postgres/proposal_context.rs index 54b88f1d9d..03dc8bc592 100644 --- a/crates/registry-breg/src/postgres/proposal_context.rs +++ b/crates/registry-breg/src/postgres/proposal_context.rs @@ -3,7 +3,9 @@ //! Proposal grants are independent from Action start and record CRUD grants. use super::*; -use crate::model::{CompiledActionExecution, ProposalOperation, ProposalOwnership}; +use crate::model::{ + CompiledActionExecution, CompiledMembershipBoundary, ProposalOperation, ProposalParty, +}; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum ProposalAuthorityOperation { @@ -24,15 +26,24 @@ pub(crate) enum ProposalTargetPhase { pub(crate) struct ProposalAuthority { pub(crate) common: ActionClaimContext, pub(crate) operation: ProposalAuthorityOperation, - pub(crate) ownership: Option, + /// The party the admitting entry is bound to. `None` for an entry bound + /// to no party and for Start. + pub(crate) party: Option, + /// Submit may name someone other than the submitter as the subject. + pub(crate) submits_for_anyone: bool, pub(crate) readable_review_progress: bool, pub(crate) targets: BTreeMap>, + target_memberships: BTreeMap>, pub(crate) task_grant: Option, pub(crate) proposal_scope: Option>, /// Whether this caller may receive applicant answers to review asks and /// download the files they cite. Only Proposal admission of a verified /// human caller sets it; every other authority is built without it. pub(crate) receives_review_answers: bool, + /// The admission's human test alone: a verified person acting for no one + /// else and under no task grant. Only such a caller is matched as a + /// subject. Review reads clear the answers flag, never this one. + pub(crate) person: bool, system: Option, } @@ -56,6 +67,7 @@ impl ProposalAuthority { operation: ProposalAuthorityOperation, principal: &str, profile: &str, + party: Option, purpose: Option<&str>, targets: BTreeMap>, ) -> Result { @@ -68,7 +80,8 @@ impl ProposalAuthority { let CompiledActionExecution::Proposal { proposal } = &action.execution else { return Err(invalid_context()); }; - let ownership; + let selected_party; + let submits_for_anyone; let readable_review_progress; let expected = match operation { ProposalAuthorityOperation::Start => { @@ -77,26 +90,41 @@ impl ProposalAuthority { .iter() .find(|p| p.profile_id == profile && p.operations.contains(&Operation::Start)) .ok_or_else(invalid_context)?; - ownership = None; + selected_party = None; + submits_for_anyone = false; readable_review_progress = false; permission - .targets - .iter() - .map(|t| (t.entity_id.as_str(), &t.row_boundaries)) + .entity_target_locks() + .map(|t| { + ( + t.entity_id.as_str(), + (&t.row_boundaries, &t.membership_boundaries), + ) + }) .collect::>() } ProposalAuthorityOperation::Lifecycle(operation) => { let permission = proposal .permissions .iter() - .find(|p| p.profile_id == profile && p.operations.contains(&operation)) + .find(|p| { + p.profile_id == profile + && p.party == party + && p.operations.contains(&operation) + }) .ok_or_else(invalid_context)?; - ownership = permission.ownership; + selected_party = permission.party; + submits_for_anyone = permission.submits_for_anyone; readable_review_progress = permission.readable_review_progress; permission .targets .iter() - .map(|t| (t.entity_id.as_str(), &t.row_boundaries)) + .map(|t| { + ( + t.entity_id.as_str(), + (&t.row_boundaries, &t.membership_boundaries), + ) + }) .collect::>() } }; @@ -110,9 +138,15 @@ impl ProposalAuthority { boundaries, expected .get(entity_id.as_str()) - .ok_or_else(invalid_context)?, + .ok_or_else(invalid_context)? + .0, )?; } + let target_memberships = expected + .into_iter() + .filter(|(_, (_, memberships))| !memberships.is_empty()) + .map(|(id, (_, memberships))| (id.to_owned(), memberships.clone())) + .collect(); Ok(Self { common: ActionClaimContext::new( action_id.to_owned(), @@ -122,12 +156,15 @@ impl ProposalAuthority { BTreeSet::new(), )?, operation, - ownership, + party: selected_party, + submits_for_anyone, readable_review_progress, targets, + target_memberships, task_grant: None, proposal_scope: None, receives_review_answers: false, + person: false, system: None, }) } @@ -247,12 +284,15 @@ impl ProposalAuthority { BTreeSet::new(), )?, operation: ProposalAuthorityOperation::Lifecycle(ProposalOperation::Apply), - ownership: None, + party: None, + submits_for_anyone: false, readable_review_progress: false, targets, + target_memberships: BTreeMap::new(), task_grant: None, proposal_scope: Some(BTreeSet::from([proposal_id])), receives_review_answers: false, + person: false, system: Some(SystemApplyAuthority { grant: grant.clone(), proposal_id, @@ -269,6 +309,37 @@ impl ProposalAuthority { }) } + /// The compiled Proposal entry this authority was admitted by. Start + /// authority is admitted by an Action grant, so it names the entry the + /// starter's draft is governed by: the profile's entry bound to no party, + /// or its owner entry. + pub(crate) fn permission<'a>( + &self, + proposal: &'a crate::model::CompiledProposalPolicy, + ) -> Option<&'a crate::model::CompiledProposalPermission> { + let profile = self.common.access_profile(); + proposal.permissions.iter().find(|permission| { + permission.profile_id == profile + && match self.operation { + ProposalAuthorityOperation::Start => { + matches!(permission.party, None | Some(ProposalParty::Owner)) + } + ProposalAuthorityOperation::Lifecycle(_) => permission.party == self.party, + } + }) + } + + pub(crate) fn target_membership(&self, entity_id: &str) -> &[CompiledMembershipBoundary] { + self.target_memberships + .get(entity_id) + .map_or(&[], Vec::as_slice) + } + + pub(crate) fn locks_membership(&self) -> bool { + self.operation == ProposalAuthorityOperation::Lifecycle(ProposalOperation::Apply) + && !self.target_memberships.is_empty() + } + pub(crate) fn is_system(&self) -> bool { self.system.is_some() } @@ -295,6 +366,23 @@ impl ProposalAuthority { snapshot_matches_boundaries(entity, snapshot, id, boundaries) } + pub(crate) fn authorizes_create_before_allocation( + &self, + entity: &crate::model::CompiledEntity, + id: Uuid, + snapshot: &serde_json::Map, + ) -> Result { + let boundaries = self.targets.get(&entity.id).ok_or_else(invalid_context)?; + snapshot_matches_selected_boundaries( + entity, + snapshot, + id, + boundaries + .iter() + .filter(|boundary| !is_allocated_field(entity, boundary)), + ) + } + #[allow(clippy::too_many_arguments)] pub(crate) async fn install_target( &self, @@ -453,6 +541,7 @@ impl ProposalAuthority { "targetEntityId": target_entity_id, "targetRecordId": target_record_id, "operation": match operation {Operation::Get=>"get",Operation::Create=>"create",Operation::Patch=>"patch",_=>return Err(invalid_context())}, "selectedAccessProfile": self.common.access_profile(), + "party": self.party, "principal": self.common.principal(), "purpose": self.common.purpose(), "rowBoundaries": boundaries.iter().map(|b| json!({"field":b.field(),"operator":b.operator().as_str(),"values":b.values()})).collect::>(), "fields": fields, @@ -477,7 +566,7 @@ impl fmt::Debug for ProposalAuthority { f.debug_struct("ProposalAuthority") .field("common", &self.common) .field("operation", &self.operation) - .field("ownership", &self.ownership) + .field("party", &self.party) .field("target_count", &self.targets.len()) .finish() } @@ -492,5 +581,13 @@ pub(crate) async fn begin_proposal_transaction<'a>( expected: &ExpectedRegistryIdentity, authority: &ProposalAuthority, ) -> Result> { - begin_action_transaction(client, lock_key, lock_timeout, expected, &authority.common).await + begin_action_transaction_for_write( + client, + lock_key, + lock_timeout, + expected, + &authority.common, + authority.locks_membership(), + ) + .await } diff --git a/crates/registry-breg/src/postgres/rehearsal.rs b/crates/registry-breg/src/postgres/rehearsal.rs index 980ff5d7c8..a5b1e147dd 100644 --- a/crates/registry-breg/src/postgres/rehearsal.rs +++ b/crates/registry-breg/src/postgres/rehearsal.rs @@ -33,9 +33,10 @@ use super::{ }, migration_ledger::statement_checksum, schema::{ - compiled_pattern_field, connect_schema_test, execute_compiled_ddl_statement, - install_compiled_schema, is_spatial_candidate_view_sql, pattern_field_for_constraint, - reconcile_compiled_runtime_acl, refuse_existing_managed_objects, + compiled_membership_source, compiled_pattern_field, connect_schema_test, + execute_compiled_ddl_statement, install_compiled_schema, is_spatial_candidate_view_sql, + pattern_field_for_constraint, reconcile_compiled_runtime_acl, + refuse_existing_managed_objects, }, verify_migration_role, ConnectionConfig, SqlIdentifier, }; @@ -193,6 +194,10 @@ pub async fn rehearse_successor_migration( checksum, kind: statement.kind, pattern_field: compiled_pattern_field(candidate.registry(), &statement.id), + membership_source: compiled_membership_source( + candidate.registry(), + &statement.id, + ), ordinal: i32::try_from(ordinal).ok()?, }, }) @@ -396,6 +401,7 @@ async fn rehearse_compiler_statement( statement.ddl.sql, statement.ddl.kind, None, + None, runtime_role, ) .await diff --git a/crates/registry-breg/src/postgres/schema.rs b/crates/registry-breg/src/postgres/schema.rs index 64aa615e90..280bb7f4db 100644 --- a/crates/registry-breg/src/postgres/schema.rs +++ b/crates/registry-breg/src/postgres/schema.rs @@ -86,6 +86,7 @@ pub async fn install_compiled_schema( &statement.sql, statement.kind, compiled_pattern_field(registry, &statement.id), + compiled_membership_source(registry, &statement.id), runtime_role, ) .await?; @@ -96,6 +97,7 @@ pub async fn install_compiled_schema( &statement.sql, statement.kind, None, + None, runtime_role, ) .await?; @@ -376,19 +378,50 @@ pub(crate) async fn execute_compiled_ddl_statement( sql: &str, kind: DdlStatementKind, pattern_field: Option<(&str, &str)>, + membership_source: Option<&str>, runtime_role: &SqlIdentifier, ) -> Result<()> { if kind == DdlStatementKind::View && is_spatial_candidate_view_sql(sql) { execute_spatial_candidate_view_ddl(client, sql, runtime_role).await } else { - client - .batch_execute(sql) - .await - .map_err(|error| map_pattern_database_error(error, pattern_field))?; + client.batch_execute(sql).await.map_err(|error| { + map_membership_index_error(&error, membership_source) + .unwrap_or_else(|| map_pattern_database_error(error, pattern_field)) + })?; Ok(()) } } +/// The membership source whose generated live-row index `statement_id` +/// builds. +pub(crate) fn compiled_membership_source<'a>( + registry: &'a CompiledRegistry, + statement_id: &str, +) -> Option<&'a str> { + registry + .entities() + .values() + .filter(|entity| entity.membership.is_some()) + .find(|entity| statement_id == format!("entity.{}.membership.key-index", entity.id)) + .map(|entity| entity.id.as_str()) +} + +/// Existing active rows that repeat a key and principal stop the unique +/// live-row index from building. Name the source, never the values. +fn map_membership_index_error( + error: &tokio_postgres::Error, + membership_source: Option<&str>, +) -> Option { + (error.code() == Some(&tokio_postgres::error::SqlState::UNIQUE_VIOLATION)) + .then_some(membership_source) + .flatten() + .map( + |entity_id| PostgresKernelError::MembershipDuplicateLiveRows { + entity_id: entity_id.to_owned(), + }, + ) +} + pub(crate) fn compiled_pattern_field<'a>( registry: &'a CompiledRegistry, statement_id: &str, diff --git a/crates/registry-breg/src/problem.rs b/crates/registry-breg/src/problem.rs index e823b1d66c..1f2fd495d6 100644 --- a/crates/registry-breg/src/problem.rs +++ b/crates/registry-breg/src/problem.rs @@ -52,6 +52,8 @@ pub enum ProblemCode { ProfileNotAuthorized, ProposalRejected, ProposalReviewResultMismatch, + ProposalSubjectChanged, + ProposalSubjectNotCaller, ProposalSubmissionExpired, QueryCursorInvalid, QueryFilterRequired, @@ -105,6 +107,8 @@ impl ProblemCode { Self::ProfileNotAuthorized, Self::ProposalRejected, Self::ProposalReviewResultMismatch, + Self::ProposalSubjectChanged, + Self::ProposalSubjectNotCaller, Self::ProposalSubmissionExpired, Self::QueryCursorInvalid, Self::QueryFilterRequired, @@ -161,6 +165,8 @@ impl ProblemCode { Self::ProfileNotAuthorized, Self::ProposalRejected, Self::ProposalReviewResultMismatch, + Self::ProposalSubjectChanged, + Self::ProposalSubjectNotCaller, Self::ProposalSubmissionExpired, Self::QueryCursorInvalid, Self::QueryFilterRequired, @@ -213,6 +219,8 @@ impl ProblemCode { Self::ProfileNotAuthorized => "profile.not-authorized", Self::ProposalRejected => "proposal.rejected", Self::ProposalReviewResultMismatch => "proposal.review-result-mismatch", + Self::ProposalSubjectChanged => "proposal.subject-changed", + Self::ProposalSubjectNotCaller => "proposal.subject-not-caller", Self::ProposalSubmissionExpired => "proposal.submission-expired", Self::QueryCursorInvalid => "query.cursor-invalid", Self::QueryFilterRequired => "query.filter-required", @@ -247,6 +255,7 @@ impl ProblemCode { Self::AuthenticationRefused | Self::DevelopmentTaskAssertion => 401, Self::IngestionProfileMismatch | Self::ProfileNotAuthorized + | Self::ProposalSubjectNotCaller | Self::WriteOutsideBoundary => 403, Self::LookupUnresolved | Self::ResourceNotFound => 404, Self::AttachmentSlotWriteOnce @@ -258,6 +267,7 @@ impl ProblemCode { | Self::IngestionRunNotOpen | Self::MutationConflict | Self::ProposalRejected + | Self::ProposalSubjectChanged | Self::StatisticalDatasetVersionConflict => 409, Self::IdempotencyExpired | Self::IngestionReceiptErased @@ -360,6 +370,8 @@ impl ProblemCode { } Self::PreconditionFailed => "The mutation precondition failed.", Self::ProposalReviewResultMismatch => "The current review result does not match the retained approval.", + Self::ProposalSubjectChanged => "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.", + Self::ProposalSubjectNotCaller => "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.", Self::PreconditionRequired => "The mutation precondition is required.", Self::ProfileNotAuthorized => "No access profile admits this caller for this request.", Self::ProposalRejected => { diff --git a/crates/registry-breg/src/proposal_artifacts.rs b/crates/registry-breg/src/proposal_artifacts.rs index 8aaec7be4e..7aa4232485 100644 --- a/crates/registry-breg/src/proposal_artifacts.rs +++ b/crates/registry-breg/src/proposal_artifacts.rs @@ -758,6 +758,13 @@ pub(super) fn append_operation_problems(operation: &mut Value, method: &str) { if id == "proposals.get-submission" { codes.push(ProblemCode::ProposalSubmissionExpired); } + // Submit binds the subject of an Action that declares one. + if id == "proposals.submit" { + codes.extend([ + ProblemCode::ProposalSubjectNotCaller, + ProblemCode::ProposalSubjectChanged, + ]); + } append_problem_codes(operation, &codes); } diff --git a/crates/registry-breg/src/proposal_ddl.rs b/crates/registry-breg/src/proposal_ddl.rs index 8b70753088..d915c28ee5 100644 --- a/crates/registry-breg/src/proposal_ddl.rs +++ b/crates/registry-breg/src/proposal_ddl.rs @@ -28,16 +28,24 @@ pub(super) fn target_policies( else { continue; }; + let first_policy = result.len(); add_read_policies( &mut result, entity, action, &grant.profile_id, + None, &grant.required_purposes, &target.row_boundaries, "preparation", "start", ); + crate::membership::append_target_probes( + entity, + &grant.profile_id, + &target.membership_boundaries, + &mut result[first_policy..], + ); } for grant in &proposal.permissions { let Some(target) = grant @@ -47,6 +55,8 @@ pub(super) fn target_policies( else { continue; }; + let party = party_qualifier(grant, &proposal.permissions); + let first_policy = result.len(); for operation in &grant.operations { let name = match operation { ProposalOperation::Get => "get", @@ -70,6 +80,7 @@ pub(super) fn target_policies( entity, action, &grant.profile_id, + party, &grant.required_purposes, &target.row_boundaries, "inspection", @@ -84,6 +95,7 @@ pub(super) fn target_policies( entity, action, &grant.profile_id, + party, &grant.required_purposes, &target.row_boundaries, "preparation", @@ -96,11 +108,18 @@ pub(super) fn target_policies( entity, action, &grant.profile_id, + party, &grant.required_purposes, &target.row_boundaries, ); } } + crate::membership::append_target_probes( + entity, + &grant.profile_id, + &target.membership_boundaries, + &mut result[first_policy..], + ); } if let Some(grant) = &proposal.system_apply_grant { add_system_policies(&mut result, entity, action, grant); @@ -109,11 +128,32 @@ pub(super) fn target_policies( result } +/// The party a grant's policies are qualified by. A profile's owner and +/// subject entries may bound the same target differently, so once a profile +/// holds a subject entry each of its party entries gets its own policies, +/// matched against the party the runtime admitted. Every other grant keeps +/// its unqualified policies and names. +fn party_qualifier( + grant: &crate::model::CompiledProposalPermission, + permissions: &[crate::model::CompiledProposalPermission], +) -> Option<&'static str> { + use crate::model::ProposalParty; + let qualified = permissions.iter().any(|entry| { + entry.profile_id == grant.profile_id && entry.party == Some(ProposalParty::Subject) + }); + match grant.party { + Some(ProposalParty::Owner) if qualified => Some("owner"), + Some(ProposalParty::Subject) => Some("subject"), + _ => None, + } +} + #[allow(clippy::too_many_arguments)] fn common( entity: &CompiledEntity, action: &CompiledAction, profile: &str, + party: Option<&str>, purposes: &BTreeSet, boundaries: &[crate::contract::RowBoundarySource], phase: &str, @@ -159,6 +199,9 @@ fn common( format!("record_lifecycle = 'active'"), target_boundary_expression(CONTEXT, "rowBoundaries", entity, boundaries), ]; + if let Some(party) = party { + expressions.push(format!("{CONTEXT} ->> 'party' = {}", quote_literal(party))); + } if !purposes.is_empty() { expressions.push(format!( "NULLIF(current_setting('registry.purpose', true), '') IN ({})", @@ -178,6 +221,7 @@ fn add_read_policies( entity: &CompiledEntity, action: &CompiledAction, profile: &str, + party: Option<&str>, purposes: &BTreeSet, boundaries: &[crate::contract::RowBoundarySource], phase: &str, @@ -189,6 +233,7 @@ fn add_read_policies( entity, action, profile, + party, purposes, boundaries, phase, @@ -201,6 +246,7 @@ fn add_read_policies( action, entity, profile, + party, phase, authority_operation, PolicyCommand::Select, @@ -219,6 +265,7 @@ fn add_read_policies( action, entity, profile, + party, phase, authority_operation, PolicyCommand::Update, @@ -236,6 +283,7 @@ fn add_application_policies( entity: &CompiledEntity, action: &CompiledAction, profile: &str, + party: Option<&str>, purposes: &BTreeSet, boundaries: &[crate::contract::RowBoundarySource], ) { @@ -243,6 +291,7 @@ fn add_application_policies( entity, action, profile, + party, purposes, boundaries, "application", @@ -258,6 +307,7 @@ fn add_application_policies( action, entity, profile, + party, "application", "get", PolicyCommand::Select, @@ -274,6 +324,7 @@ fn add_application_policies( action, entity, profile, + party, "application", "get", PolicyCommand::Update, @@ -327,6 +378,7 @@ fn add_application_policies( action, entity, profile, + party, "application", suffix, PolicyCommand::Select, @@ -344,7 +396,15 @@ fn add_application_policies( }; result.push(DdlPolicy { permissive: true, - name: policy_name(action, entity, profile, "application", suffix, command), + name: policy_name( + action, + entity, + profile, + party, + "application", + suffix, + command, + ), command, access_profile: profile.to_owned(), applies_to: ordinary_policy_role(entity), @@ -508,7 +568,7 @@ fn add_system_policies( for command in [PolicyCommand::Select, PolicyCommand::Update] { result.push(DdlPolicy { permissive: true, - name: policy_name(action, entity, PROFILE, phase, "get", command), + name: policy_name(action, entity, PROFILE, None, phase, "get", command), command, access_profile: PROFILE.to_owned(), applies_to: ordinary_policy_role(entity), @@ -540,6 +600,7 @@ fn add_system_policies( action, entity, PROFILE, + None, "application", operation_name(operation), PolicyCommand::Select, @@ -561,6 +622,7 @@ fn add_system_policies( action, entity, PROFILE, + None, "application", operation_name(operation), command, @@ -582,6 +644,7 @@ fn policy_name( action: &CompiledAction, entity: &CompiledEntity, profile: &str, + party: Option<&str>, phase: &str, operation: &str, command: PolicyCommand, @@ -599,6 +662,11 @@ fn policy_name( hash.update((value.len() as u64).to_be_bytes()); hash.update(value.as_bytes()); } + // A party-qualified policy adds its party; every other name is unchanged. + if let Some(party) = party { + hash.update((party.len() as u64).to_be_bytes()); + hash.update(party.as_bytes()); + } // PostgreSQL truncates identifiers after 63 bytes. Keep the complete // generated name below that boundary so installation and verification // compare exactly the same policy identity. diff --git a/crates/registry-breg/src/proposal_hooks.rs b/crates/registry-breg/src/proposal_hooks.rs index ccc015add8..49badf3851 100644 --- a/crates/registry-breg/src/proposal_hooks.rs +++ b/crates/registry-breg/src/proposal_hooks.rs @@ -263,9 +263,10 @@ fn exact_inventory(expected: &[CompiledEventDelivery], actual: &[&CompiledEventD }) } -#[cfg(all(test, feature = "runtime"))] +#[cfg(test)] #[path = "../tests/support/proposal_hooks_model.rs"] -mod test_model; +#[cfg_attr(not(feature = "runtime"), allow(dead_code))] +pub(crate) mod test_model; #[cfg(all(test, feature = "runtime"))] #[test] diff --git a/crates/registry-breg/src/proposal_prepare.rs b/crates/registry-breg/src/proposal_prepare.rs index de8392fccb..8b666ed80b 100644 --- a/crates/registry-breg/src/proposal_prepare.rs +++ b/crates/registry-breg/src/proposal_prepare.rs @@ -26,6 +26,8 @@ pub(crate) struct ResolvedProposalTargets { pub records: BTreeMap<(String, Uuid), Operation>, } +pub(crate) type ProposalPatchBases = BTreeMap<(String, Uuid), (i64, Map)>; + type ProposalCreateFields = BTreeMap<(String, Uuid), Map>; #[derive(Clone, Debug)] @@ -226,6 +228,77 @@ pub(crate) fn materialize_create_fields( Ok(creates) } +/// Check candidate boundaries before reserving generated identifiers. +pub(crate) async fn authorize_candidates_before_allocation( + tx: &tokio_postgres::Transaction<'_>, + registry: &CompiledRegistry, + authority: &crate::postgres::ProposalAuthority, + input: &Map, + resolved: &ResolvedProposalTargets, + creates: &ProposalCreateFields, + bases: &ProposalPatchBases, +) -> Result<(), MutationError> { + use crate::mutation::probe_action_memberships; + + let profile = authority.common.access_profile(); + for ((entity, id), snapshot) in creates { + let compiled = ®istry.entities()[entity]; + if !authority + .authorizes_create_before_allocation(compiled, *id, snapshot) + .map_err(|_| MutationError::PreconditionFailed)? + { + return Err(MutationError::PreconditionFailed); + } + probe_action_memberships( + tx, + profile, + authority.target_membership(entity), + Some(*id), + snapshot, + ) + .await?; + } + let mut patches = BTreeMap::new(); + for effect in resolved + .effects + .iter() + .filter(|effect| effect.operation == Operation::Patch) + { + let entity = &effect.target.entity_id; + let key = (entity.clone(), resolved.effect_records[&effect.id]); + let after = patches + .entry(key.clone()) + .or_insert_with(|| bases[&key].1.clone()); + for mutation in &effect.mutations { + match mutation { + CompiledPlanMutation::Set { field, value } => { + after.insert(field.clone(), resolve_plan_value(input, resolved, value)?); + } + CompiledPlanMutation::Clear { field } => { + after.insert(field.clone(), Value::Null); + } + } + } + } + for ((entity, id), snapshot) in patches { + if !authority + .authorizes_snapshot(®istry.entities()[&entity], id, &snapshot) + .map_err(|_| MutationError::PreconditionFailed)? + { + return Err(MutationError::PreconditionFailed); + } + probe_action_memberships( + tx, + profile, + authority.target_membership(&entity), + Some(id), + &snapshot, + ) + .await?; + } + Ok(()) +} + fn resolve_plan_value( input: &Map, resolved: &ResolvedProposalTargets, @@ -269,7 +342,7 @@ pub(crate) fn prepare( input_revision: i64, package_fingerprint: &str, resolved: &ResolvedProposalTargets, - bases: BTreeMap<(String, Uuid), (i64, Map)>, + bases: ProposalPatchBases, guard_bases: BTreeMap)>, ) -> Result { let create_fields = materialize_create_fields(registry, input, resolved)?; @@ -295,7 +368,7 @@ pub(crate) fn prepare_with_reserved_create_fields( package_fingerprint: &str, resolved: &ResolvedProposalTargets, reserved_create_fields: BTreeMap<(String, Uuid), Map>, - bases: BTreeMap<(String, Uuid), (i64, Map)>, + bases: ProposalPatchBases, guard_bases: BTreeMap)>, ) -> Result { let CompiledActionExecution::Proposal { proposal: policy } = &action.execution else { diff --git a/crates/registry-breg/src/proposal_prepare/tests.rs b/crates/registry-breg/src/proposal_prepare/tests.rs index caf57b2641..e429ecf82d 100644 --- a/crates/registry-breg/src/proposal_prepare/tests.rs +++ b/crates/registry-breg/src/proposal_prepare/tests.rs @@ -33,9 +33,9 @@ fn source(effects: Value) -> Value { {"id":"two","type":"reference","target":"target","classification":"internal"}, {"id":"value","type":"string","maximumLength":64,"required":true,"classification":"internal"} ],"plan":{"type":"fixed","effects":effects}}}, - "accessProfiles":{"submitter": {"default":true,"principalClaim":"sub","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"submitter": {"default":true,"principalClaim":"sub","requiredScopes":["proposals:write"],"permissions":{ "actions":[{"action":"change-target","operations":["start"],"targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}], - "proposals":[{"action":"change-target","operations":["get","submit","apply"],"ownership":"caller","targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}] + "proposals":[{"action":"change-target","operations":["get","submit","apply"],"party":"owner","targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}] }}} }) } diff --git a/crates/registry-breg/src/proposal_retention.rs b/crates/registry-breg/src/proposal_retention.rs index cbf9a184f4..6fc96623d5 100644 --- a/crates/registry-breg/src/proposal_retention.rs +++ b/crates/registry-breg/src/proposal_retention.rs @@ -1518,7 +1518,7 @@ async fn erase_proposal_detail_in_transaction( transaction .execute( "UPDATE registry_internal.registry_proposal_state - SET input=NULL,action_title=NULL, + SET input=NULL,action_title=NULL,subject_reference=NULL, detail_erased_at=transaction_timestamp(),updated_at=transaction_timestamp() WHERE action_id=$1 AND proposal_id=$2 AND detail_erased_at IS NULL", &[&scope.action_id, &scope.proposal_id], diff --git a/crates/registry-breg/src/proposal_store.rs b/crates/registry-breg/src/proposal_store.rs index 91068e69cf..4f3cdd7a2f 100644 --- a/crates/registry-breg/src/proposal_store.rs +++ b/crates/registry-breg/src/proposal_store.rs @@ -168,6 +168,12 @@ pub(crate) async fn install( ON registry_internal.registry_proposal_targets (target_entity_id, target_record_id); CREATE INDEX IF NOT EXISTS registry_proposal_queue ON registry_internal.registry_proposal_state (action_id, state, proposal_id); + ALTER TABLE registry_internal.registry_proposal_state + ADD COLUMN IF NOT EXISTS subject_reference text + CHECK (subject_reference IS NULL OR subject_reference <> ''); + CREATE INDEX IF NOT EXISTS registry_proposal_subject + ON registry_internal.registry_proposal_state (subject_reference, proposal_id) + WHERE subject_reference IS NOT NULL; CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_applications ( action_id text NOT NULL, proposal_id uuid NOT NULL, @@ -350,6 +356,9 @@ pub(crate) async fn load_task_authority( #[allow(dead_code)] pub(crate) struct ProposalWorkflowHeader { pub owner_reference: String, + /// Bound once, at the first Submit of an Action that declares a subject. + /// Like `owner_reference`, an unkeyed hash that is never projected. + pub subject_reference: Option, pub state: String, pub submission_version: i64, pub workflow_revision: i64, @@ -363,6 +372,7 @@ impl std::fmt::Debug for ProposalWorkflowHeader { formatter .debug_struct("ProposalWorkflowHeader") .field("has_owner_reference", &!self.owner_reference.is_empty()) + .field("has_subject_reference", &self.subject_reference.is_some()) .field("state", &self.state) .field("submission_version", &self.submission_version) .field("workflow_revision", &self.workflow_revision) @@ -404,6 +414,29 @@ pub(crate) async fn initialize_draft( Ok(()) } +/// Bind the Proposal's subject. The caller holds the state lock and has +/// compared any reference already bound; a bound subject is never replaced. +pub(crate) async fn bind_subject( + transaction: &Transaction<'_>, + entity_id: &str, + record_id: Uuid, + subject_reference: &str, +) -> Result<(), MutationError> { + let updated = transaction + .execute( + "UPDATE registry_internal.registry_proposal_state SET subject_reference=$3 + WHERE action_id=$1 AND proposal_id=$2 + AND (subject_reference IS NULL OR subject_reference=$3)", + &[&entity_id, &record_id, &subject_reference], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + if updated != 1 { + return Err(MutationError::Unavailable); + } + Ok(()) +} + /// Store the authored Action input directly, preserving missing versus null. /// The caller owns the state lock, transition fence, and current authority. pub(crate) async fn save_draft_input( @@ -773,7 +806,7 @@ pub(crate) async fn load_header( "SELECT s.owner_reference, s.state, s.submission_version, s.workflow_revision, COALESCE(s.detail_erased_at IS NOT NULL, false) OR COALESCE(p.erased_at IS NOT NULL, false), a.applied_by, - a.reason_present + a.reason_present, s.subject_reference FROM registry_internal.registry_proposal_state s LEFT JOIN registry_internal.registry_proposal_submissions p ON p.action_id = s.action_id @@ -808,6 +841,7 @@ pub(crate) async fn load_header( // The applications join is outer: a request without an application has // no reason to record. application_reason_present: row.get::<_, Option>(6).unwrap_or(false), + subject_reference: row.get(7), }) } @@ -1463,11 +1497,14 @@ mod tests { current_proposal_erased: false, applier_reference: Some("private-applier-reference-canary".to_owned()), application_reason_present: true, + subject_reference: Some("private-subject-reference-canary".to_owned()), }; let debug = format!("{header:?}"); assert!(!debug.contains("private-owner-reference-canary")); assert!(!debug.contains("private-applier-reference-canary")); + assert!(!debug.contains("private-subject-reference-canary")); assert!(debug.contains("has_owner_reference: true")); + assert!(debug.contains("has_subject_reference: true")); assert!(debug.contains("has_applier_reference: true")); } diff --git a/crates/registry-breg/src/proposal_subject.rs b/crates/registry-breg/src/proposal_subject.rs new file mode 100644 index 0000000000..cbce0d9b7d --- /dev/null +++ b/crates/registry-breg/src/proposal_subject.rs @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: Apache-2.0 +//! A Record field a Proposal subject is read from decides who may follow +//! that Proposal, so writing it is authority, as writing a membership +//! principal is. + +use std::collections::{BTreeMap, BTreeSet}; + +use crate::contract::{ + ActionExecutionSource, ActionPlanSource, ActionSource, BoundaryOperator, EntitySource, + FieldTypeSource, MembershipRowBoundarySource, Operation, RegistryProject, RowBoundarySource, +}; +use crate::diagnostics::Diagnostic; + +fn refuse(location: &str, record_type: &str, field: &str, errors: &mut Vec) { + errors.push(Diagnostic::error( + "breg.proposal.subject-field-write", + location, + &format!( + "`{record_type}.{field}` names the subject of a Proposal, so whoever writes it chooses who may follow that Proposal. Grant this write without row boundaries to staff who may decide who a Record is about, bound it on `{field}` by the profile's own principal claim, or make the change through a Proposal Action" + ), + )); +} + +/// The Record type and field each Action's `subject.field` reads. +fn subject_fields( + actions: &BTreeMap, +) -> BTreeSet<(String, String)> { + actions + .values() + .filter_map(|collected| { + let action = &collected.source; + let ActionExecutionSource::Proposal { proposal } = &action.execution else { + return None; + }; + let subject = proposal.subject.as_ref()?; + let field = subject.field.as_ref()?; + action + .inputs + .iter() + .find(|input| input.id == subject.input) + .and_then(|input| match &input.field_type { + FieldTypeSource::Reference { target, .. } => { + Some((target.clone(), field.clone())) + } + _ => None, + }) + }) + .collect() +} + +/// Whether a grant's rows let its writer name anyone in `field`: it is +/// bounded, yet not on `field` by the profile's own principal claim. A grant +/// with no boundary at all is unrestricted by the author's choice. +fn bounded_off_field( + rows: &[RowBoundarySource], + memberships: &[MembershipRowBoundarySource], + field: &str, + principal_claim: Option<&str>, +) -> bool { + (!rows.is_empty() || !memberships.is_empty()) + && !rows.iter().any(|row| { + row.field == field + && row.operator == BoundaryOperator::Equals + && Some(row.claim.as_str()) == principal_claim + }) +} + +/// Whether a plan can set `field` of `record_type` with no person deciding: +/// an immediate Action, or a Proposal Action with no required review that the +/// built-in executor applies. A reviewed or manually applied Proposal puts a +/// person between the writer and the write. +fn plan_sets_field(action: &ActionSource, record_type: &str, field: &str) -> bool { + if let ActionExecutionSource::Proposal { proposal } = &action.execution { + if matches!( + proposal.review, + crate::contract::ProposalReviewSource::Required { .. } + ) || matches!( + proposal.application, + crate::contract::ProposalApplicationSource::Manual {} + ) { + return false; + } + } + match &action.plan { + ActionPlanSource::Fixed { effects } => effects.iter().any(|effect| { + crate::membership::writes_target(action, &effect.target, record_type) + && matches!(effect.operation, Operation::Create | Operation::Patch) + && effect.set.contains_key(field) + }), + ActionPlanSource::Function { writes, .. } => writes.iter().any(|ceiling| { + crate::membership::writes_target(action, &ceiling.target, record_type) + && matches!(ceiling.operation, Operation::Create | Operation::Patch) + && ceiling.fields.iter().any(|candidate| candidate == field) + }), + } +} + +/// Refuse a bounded grant that can set a field a Proposal subject is read +/// from: a direct Create, Batch, Import or Patch of it, or an Action whose +/// plan sets it with no person deciding. Unrestricted grants, grants bounded +/// on the field by their own principal, and reviewed or manually applied +/// Proposal Actions stay admitted. +pub(crate) fn validate_field_writes( + project: &RegistryProject, + actions: &BTreeMap, + entities: &BTreeMap, + errors: &mut Vec, +) { + let principal_claim = |profile: &str| { + project + .access_profiles + .iter() + .find(|candidate| candidate.id == profile) + .map(|candidate| candidate.principal_claim.as_str()) + }; + for (record_type, field) in subject_fields(actions) { + let Some(entity) = entities.get(&record_type) else { + continue; + }; + for grant in &entity.access_profiles { + let memberships = grant + .membership_boundaries + .iter() + .map(|boundary| boundary.entry()) + .collect::>(); + let writes = grant.operations.iter().any(|operation| { + matches!( + operation, + Operation::Create | Operation::Batch | Operation::Import | Operation::Patch + ) + }) && grant.writable_fields.contains(&field); + if writes + && bounded_off_field( + &grant.row_boundaries, + &memberships, + &field, + principal_claim(&grant.id), + ) + { + refuse( + &format!( + "recordTypes[id={record_type}].accessProfiles[id={}].writableFields", + grant.id + ), + &record_type, + &field, + errors, + ); + } + } + for profile in &project.access_profiles { + for grant in &profile.permissions.actions { + let Some(target) = grant + .targets + .iter() + .find(|target| target.entity == record_type) + else { + continue; + }; + if bounded_off_field( + &target.row_boundaries, + &target.membership_row_boundaries, + &field, + Some(profile.principal_claim.as_str()), + ) && actions.get(&grant.action).is_some_and(|collected| { + plan_sets_field(&collected.source, &record_type, &field) + }) { + refuse( + &format!( + "accessProfiles[id={}].permissions.actions[action={}].targets[recordType={record_type}]", + profile.id, grant.action + ), + &record_type, + &field, + errors, + ); + } + } + } + } +} diff --git a/crates/registry-breg/src/runtime_config.rs b/crates/registry-breg/src/runtime_config.rs index f2bda3adb3..ae26b695ac 100644 --- a/crates/registry-breg/src/runtime_config.rs +++ b/crates/registry-breg/src/runtime_config.rs @@ -5502,6 +5502,80 @@ mod tests { use super::RuntimeConfigError; use crate::attachment_verification_worker::ATTEMPT_BUDGET; + fn open_membership_registry() -> crate::CompiledRegistry { + use serde_json::{json, Value}; + let mut source: Value = serde_json::from_str(include_str!( + "../../../products/breg/fixtures/organization-membership-access/registry.yaml" + )) + .unwrap(); + source["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + source["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("steward"); + source["accessProfiles"]["member"]["principalClaim"] = json!("sub"); + source["accessProfiles"]["member"]["requiredScopes"] = json!("unrestricted"); + let project = crate::parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); + crate::compile_project(&project, &[], crate::CompileProfile::Authoring).unwrap() + } + + fn membership_runtime(two_issuers: bool) -> super::RuntimeConfig { + use registry_platform_config::{DeclaredPosture, Posture, PostureSource}; + let example = include_str!("../../../products/breg/examples/minimal/runtime.example.yaml"); + let mut runtime = example.replace("principal: registry_principal", "principal: sub"); + let first = runtime.find(" primary:\n").unwrap(); + let end = runtime.find(" authorityClaims:\n").unwrap(); + let definition = format!("{} actorKind: human\n", &runtime[first..end]); + let mut issuers = definition.clone(); + if two_issuers { + issuers.push_str( + &definition + .replace("primary:", "second:") + .replace( + "https://issuer.example.com", + "https://other-issuer.example.com", + ) + .replace("directory-client", "second-directory-client"), + ); + } + runtime.replace_range(first..end, &issuers); + super::parse_runtime_config( + &runtime, + DeclaredPosture { + posture: Posture::Development, + source: PostureSource::Flag, + }, + ) + .unwrap() + } + + #[test] + fn a_membership_bounded_profile_reachable_from_two_issuers_refuses_at_startup() { + let runtime = membership_runtime(true); + let diagnostics = runtime.authentication().access_profile_diagnostics( + &open_membership_registry(), + None, + None, + ); + assert_eq!(diagnostics.len(), 1); + assert_eq!(diagnostics[0].code, "breg.runtime.principal-across-issuers"); + } + + #[test] + fn an_open_profile_bounded_by_membership_is_not_listed_as_scopeless_without_subject_rule() { + let runtime = membership_runtime(false); + let registry = open_membership_registry(); + let settings = runtime + .authentication() + .combination_posture_settings(®istry); + assert!(!settings + .iter() + .any(|found| found.setting.code == "breg.posture.scopeless-without-subject-rule")); + } + #[test] fn a_loopback_name_reaches_the_pool_as_numeric_loopback_addresses() { // A fixed answer, so the test needs no particular `localhost` mapping diff --git a/crates/registry-breg/src/tests/action_handler_benchmark_tests.rs b/crates/registry-breg/src/tests/action_handler_benchmark_tests.rs index 79b85cbfb0..e7a377bb58 100644 --- a/crates/registry-breg/src/tests/action_handler_benchmark_tests.rs +++ b/crates/registry-breg/src/tests/action_handler_benchmark_tests.rs @@ -51,7 +51,7 @@ fn acceptance_action() -> CompiledAction { "plan":{"type":"scripted","actionPlan":"register-plan","inputs":["identifier","given-name","family-name"], "refusals":[{"code":"blank-name","label":"At least one name part is required."}], "writes":[{"id":"person","target":{"recordType":"person"},"operation":"create","fields":["identifier","display-name"]}]}}}, - "accessProfiles":{"writer": {"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[ + "accessProfiles":{"writer": {"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[ {"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person"]}]}}} }); let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); @@ -105,7 +105,7 @@ fn characterization_action(script: &str) -> CompiledAction { "refusals":[{"code":"blank-label","label":"A label is required."}], "writes":[{"id":"record","target":{"recordType":"record"},"operation":"create","fields":["label","count","amount"]}] }}}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{ "actions":[ {"action":"register-record","operations":["invoke"],"targets":[{"recordType":"record","rowBoundaries":"unrestricted"}],"results":["record"]} ] diff --git a/crates/registry-breg/src/tests/action_outcome_wasm_parity_tests.rs b/crates/registry-breg/src/tests/action_outcome_wasm_parity_tests.rs index e9fa4ba207..105b000a6f 100644 --- a/crates/registry-breg/src/tests/action_outcome_wasm_parity_tests.rs +++ b/crates/registry-breg/src/tests/action_outcome_wasm_parity_tests.rs @@ -57,7 +57,7 @@ fn person_action(script: &str) -> CompiledAction { {"id":"friend","target":{"recordType":"person"},"operation":"create","fields":["name","friend"]}, {"id":"existing","target":{"fromInput":"person"},"operation":"patch","fields":["name","friend"]} ]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} + "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} }); let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); compile_project_with_assets( @@ -101,7 +101,7 @@ fn record_action(script: &str) -> CompiledAction { ],"plan":{"type":"scripted","actionPlan":"record-plan","inputs":["label","count","amount"],"refusals":[{"code":"blank-label","label":"A label is required."}], "writes":[{"id":"record","target":{"recordType":"record"},"operation":"create","fields":["label","count","amount"]}] }}}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{ "actions":[ {"action":"register-record","operations":["invoke"],"targets":[{"recordType":"record","rowBoundaries":"unrestricted"}],"results":["record"]} ] diff --git a/crates/registry-breg/src/tests/artifacts_response_schema_tests.rs b/crates/registry-breg/src/tests/artifacts_response_schema_tests.rs index b87c64c93b..55dfcbcdb0 100644 --- a/crates/registry-breg/src/tests/artifacts_response_schema_tests.rs +++ b/crates/registry-breg/src/tests/artifacts_response_schema_tests.rs @@ -1140,7 +1140,7 @@ fn compiled_bound_writer_registry() -> CompiledRegistry { "actions": [ {"action": "set-person-phone", "operations": ["invoke"], "targets": targets}, {"action": "propose-person-phone", "operations": ["start"], "targets": targets}], - "proposals": [{"action": "propose-person-phone", "ownership": "caller", + "proposals": [{"action": "propose-person-phone", "party": "owner", "operations": ["get", "list", "edit", "submit", "cancel", "apply"], "readableInputs": ["person", "phone"], "targets": targets}]}}) }; @@ -1318,7 +1318,7 @@ fn compiled_record_condition_writer_registry( "actions": [ {"action": "write-person", "operations": ["invoke"], "targets": targets}, {"action": "propose-person", "operations": ["start"], "targets": targets}], - "proposals": [{"action": "propose-person", "ownership": "caller", + "proposals": [{"action": "propose-person", "party": "owner", "operations": ["get", "list", "edit", "submit", "cancel", "apply"], "readableInputs": if effect == "patch" { json!(["person", "phone", "protected"]) } else { json!(["phone", "protected"]) }, "targets": targets}]}}) diff --git a/crates/registry-breg/src/tests/wasm_runtime_tests.rs b/crates/registry-breg/src/tests/wasm_runtime_tests.rs index 4187d57dd6..5aa29391c3 100644 --- a/crates/registry-breg/src/tests/wasm_runtime_tests.rs +++ b/crates/registry-breg/src/tests/wasm_runtime_tests.rs @@ -153,7 +153,7 @@ fn wasm_person_action(module_bytes: &[u8]) -> CompiledAction { ],"plan":{"type":"scripted","actionPlan":"person-plan","inputs":["given-name","family-name","person"],"refusals":[{"code":"blank-name","label":"A name is required."}],"writes":[ {"id":"person","target":{"recordType":"person"},"operation":"create","fields":["name","friend"]} ]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person"]}]}}} + "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person"]}]}}} }); let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); compile_project_with_assets( diff --git a/crates/registry-breg/src/tooling.rs b/crates/registry-breg/src/tooling.rs index 5ef0f2222a..80b0984c83 100644 --- a/crates/registry-breg/src/tooling.rs +++ b/crates/registry-breg/src/tooling.rs @@ -587,6 +587,7 @@ fn action_details( let Some(before) = before else { return details; }; + details.extend(target_boundary_details(&before, &after)); let codes = |input: &crate::model::CompiledActionInput| match &input.field_type { crate::contract::FieldTypeSource::VocabularyCode { values, .. } => json!(values), _ => Value::Null, @@ -620,6 +621,84 @@ fn action_details( details } +fn target_boundary_details( + before: &crate::model::CompiledAction, + after: &crate::model::CompiledAction, +) -> Vec { + use crate::model::CompiledActionExecution; + use serde_json::json; + + let mut details = Vec::new(); + let mut compare = |profile: &str, entity: &str, surface: &str, before, after| { + details.extend( + object_details(&before, &after, |field, left, right| { + (access_direction(field, left, right), None) + }) + .into_iter() + .map(|mut detail| { + detail.reason = Some(format!("{surface} target {entity} in profile {profile}")); + detail + }), + ); + }; + for grant in &before.permissions { + let Some(next) = after + .permissions + .iter() + .find(|next| next.profile_id == grant.profile_id) + else { + continue; + }; + for target in grant.entity_target_locks() { + let Some(other) = next + .entity_target_locks() + .find(|other| other.entity_id == target.entity_id) + else { + continue; + }; + compare( + &grant.profile_id, + &target.entity_id, + "Action", + json!({"rowBoundaries": target.row_boundaries, "membershipBoundaries": target.membership_boundaries}), + json!({"rowBoundaries": other.row_boundaries, "membershipBoundaries": other.membership_boundaries}), + ); + } + } + if let ( + CompiledActionExecution::Proposal { proposal: before }, + CompiledActionExecution::Proposal { proposal: after }, + ) = (&before.execution, &after.execution) + { + for grant in &before.permissions { + let Some(next) = after + .permissions + .iter() + .find(|next| next.profile_id == grant.profile_id) + else { + continue; + }; + for target in &grant.targets { + let Some(other) = next + .targets + .iter() + .find(|other| other.entity_id == target.entity_id) + else { + continue; + }; + compare( + &grant.profile_id, + &target.entity_id, + "Proposal", + json!({"rowBoundaries": target.row_boundaries, "membershipBoundaries": target.membership_boundaries}), + json!({"rowBoundaries": other.row_boundaries, "membershipBoundaries": other.membership_boundaries}), + ); + } + } + } + details +} + fn access_direction( field: &str, before: &serde_json::Value, diff --git a/crates/registry-breg/tests/access_explanation.rs b/crates/registry-breg/tests/access_explanation.rs index 0ceb6bb9f8..e55b199017 100644 --- a/crates/registry-breg/tests/access_explanation.rs +++ b/crates/registry-breg/tests/access_explanation.rs @@ -150,11 +150,9 @@ fn membership_source() -> Value { let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["records"][0]; grant["operations"] = json!(["get", "list"]); grant["writableFields"] = json!([]); - grant["rowBoundaries"] = json!("unrestricted"); - grant["membershipBoundaries"] = json!([{ - "field":"organization", "membershipRecordType":"membership", - "membershipKeyField":"organization", "principalField":"principal", "activeField":"active" - }]); + grant["rowBoundaries"] = json!([{"field":"organization","membership":"membership"}]); + source["recordTypes"]["membership"]["membership"] = + json!({"key":"organization","principal":"principal","active":"active"}); source } @@ -501,7 +499,7 @@ fn function_action_target_authority_uses_the_compiled_write_ceiling() { #[test] fn membership_row_reach_is_explicit_and_uses_the_selected_principal() { for (boundaries, rows, direct_claims) in [ - (json!("unrestricted"), "membership_bound", 0), + (json!([]), "membership_bound", 0), ( json!([{"field":"district", "claim":"districts", "operator":"in"}]), "claim_and_membership_bound", @@ -509,8 +507,11 @@ fn membership_row_reach_is_explicit_and_uses_the_selected_principal() { ), ] { let mut source = membership_source(); - source["accessProfiles"]["clerk"]["permissions"]["records"][0]["rowBoundaries"] = - boundaries.clone(); + let authored = + &mut source["accessProfiles"]["clerk"]["permissions"]["records"][0]["rowBoundaries"]; + if let Some(claims) = boundaries.as_array() { + authored.as_array_mut().unwrap().extend_from_slice(claims); + } let registry = compile(&source); let explanation = registry_breg::access::explain_access(®istry); let inspected = serde_json::to_value(&explanation).unwrap(); @@ -529,7 +530,10 @@ fn membership_row_reach_is_explicit_and_uses_the_selected_principal() { .unwrap(); assert_eq!(reach.rows, rows); assert_eq!(reach.membership_boundaries.len(), 1); - assert_eq!(reach.membership_boundaries[0].principal_field, "principal"); + assert_eq!( + serde_json::to_value(&reach.membership_boundaries[0]).unwrap()["principalField"], + "principal" + ); assert!(!registry.findings().iter().any(|finding| matches!( finding.code.as_str(), "breg.access.profile-unrestricted-rows" | "breg.access.profile-unrestricted-collection" @@ -546,24 +550,28 @@ fn membership_changes_report_authority_narrowing_and_widening() { use registry_breg::tooling::{classify_registry_diff, AccessChangeDirection}; let mut source = membership_source(); - source["recordTypes"]["membership"]["fields"] + let mut additional = source["recordTypes"]["membership"].clone(); + additional["route"] = json!("additional-memberships"); + additional["fields"] .as_array_mut() .unwrap() .push(json!({"id":"approved", "type":"boolean", "classification":"internal"})); - let mut additional = source["accessProfiles"]["clerk"]["permissions"]["records"][0] - ["membershipBoundaries"][0] - .clone(); - additional["activeField"] = json!("approved"); + additional["membership"]["active"] = json!("approved"); + source["recordTypes"]["additional-membership"] = additional; let mut boundaries = source["accessProfiles"]["clerk"]["permissions"]["records"][0] - ["membershipBoundaries"] + ["rowBoundaries"] .as_array() .unwrap() .clone(); - boundaries.push(additional); + boundaries.push(json!({"field":"organization","membership":"additional-membership"})); let registries = (0..=2) .map(|count| { - source["accessProfiles"]["clerk"]["permissions"]["records"][0] - ["membershipBoundaries"] = json!(&boundaries[..count]); + source["accessProfiles"]["clerk"]["permissions"]["records"][0]["rowBoundaries"] = + if count == 0 { + json!("unrestricted") + } else { + json!(&boundaries[..count]) + }; compile(&source) }) .collect::>(); @@ -615,3 +623,96 @@ fn synthetic_own_record_preview_reuses_principal_and_refuses_identity_override() ) .is_err()); } + +#[allow(dead_code)] +#[path = "support/proposal_hooks_model.rs"] +mod proposal_hooks_model; + +fn compiled_with_target_membership( + mut registry: Value, + targets: &str, +) -> registry_breg::CompiledRegistry { + let member_registry = compile(&membership_source()); + let boundary = &member_registry.entities()["entry"].membership_boundaries["clerk"][0]; + registry["entities"]["membership"] = json!(member_registry.entities()["membership"]); + for target in registry + .pointer_mut(targets) + .unwrap() + .as_array_mut() + .unwrap() + { + target["membershipBoundaries"] = json!([boundary]); + } + serde_json::from_value(registry).unwrap() +} + +const ACTION_TARGETS: &str = "/actionInventory/actions/0/permissions/0/targets"; +const PROPOSAL_TARGETS: &str = + "/actionInventory/actions/0/execution/proposal/permissions/0/targets"; + +#[test] +fn explain_access_lists_membership_entries_on_action_targets() { + let baseline = compile(&repeated_action_target_source()); + let candidate = compiled_with_target_membership(json!(baseline), ACTION_TARGETS); + let explanation = registry_breg::access::explain_access(&candidate); + let target = explanation + .row_reach + .iter() + .find(|reach| reach.surface == "action_target") + .unwrap(); + assert_eq!(target.rows, "claim_and_membership_bound"); + assert_eq!(target.membership_boundaries.len(), 1); + assert_eq!( + json!(target.membership_boundaries[0]), + json!({ + "field":"organization", "membershipRecordType":"membership", + "membershipKeyField":"organization","principalField":"principal","activeField":"active" + }) + ); +} + +#[test] +fn explain_access_lists_membership_entries_on_proposal_targets() { + let baseline = compile(&proposal_hooks_model::source(json!([]))); + let candidate = compiled_with_target_membership(json!(baseline), PROPOSAL_TARGETS); + let explanation = registry_breg::access::explain_access(&candidate); + let target = explanation + .row_reach + .iter() + .find(|reach| reach.surface == "proposal_target") + .unwrap(); + assert_eq!(target.rows, "membership_bound"); + assert_eq!(target.membership_boundaries.len(), 1); + assert_eq!( + json!(target.membership_boundaries[0]), + json!({ + "field":"organization", "membershipRecordType":"membership", + "membershipKeyField":"organization","principalField":"principal","activeField":"active" + }) + ); +} + +#[cfg(all(feature = "runtime", feature = "tooling"))] +#[test] +fn adding_a_membership_entry_to_an_action_target_reads_as_narrowing() { + use registry_breg::tooling::{classify_registry_diff, AccessChangeDirection}; + let baseline = compile(&repeated_action_target_source()); + let candidate = compiled_with_target_membership(json!(baseline), ACTION_TARGETS); + for (before, after, expected) in [ + (&baseline, &candidate, AccessChangeDirection::Narrowing), + (&candidate, &baseline, AccessChangeDirection::Widening), + ] { + let diff = classify_registry_diff(before, after, "baseline"); + let details = diff + .changes + .iter() + .flat_map(|change| &change.access_details); + assert_eq!( + details + .filter(|detail| detail.field == "membershipBoundaries") + .map(|detail| detail.direction) + .collect::>(), + [expected], + ); + } +} diff --git a/crates/registry-breg/tests/access_log.rs b/crates/registry-breg/tests/access_log.rs index bf4e9c4d4e..9a19dc5ccf 100644 --- a/crates/registry-breg/tests/access_log.rs +++ b/crates/registry-breg/tests/access_log.rs @@ -73,7 +73,7 @@ fn source() -> Value { }, "writer": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "person", "operations": ["create"], diff --git a/crates/registry-breg/tests/access_sentinels.rs b/crates/registry-breg/tests/access_sentinels.rs index db8a755649..6b8278e09b 100644 --- a/crates/registry-breg/tests/access_sentinels.rs +++ b/crates/registry-breg/tests/access_sentinels.rs @@ -41,7 +41,7 @@ fn every_row_reach() -> Value { "rowBoundaries":[boundary()]}], "actions":[{"action":"register","operations":["invoke"], "targets":[{"recordType":"entry","rowBoundaries":[boundary()]}]}], - "proposals":[{"action":"register","operations":["get"],"ownership":"caller", + "proposals":[{"action":"register","operations":["get"],"party":"owner", "targets":[{"recordType":"entry","rowBoundaries":[boundary()]}]}] }); value diff --git a/crates/registry-breg/tests/action_evidence_compiler.rs b/crates/registry-breg/tests/action_evidence_compiler.rs index 5de966b153..a55ab1900c 100644 --- a/crates/registry-breg/tests/action_evidence_compiler.rs +++ b/crates/registry-breg/tests/action_evidence_compiler.rs @@ -28,7 +28,7 @@ fn project() -> Value { {"id":"friend","target":{"recordType":"person"},"operation":"create","fields":["name","friend"]}, {"id":"existing","target":{"fromInput":"person"},"operation":"patch","fields":["name","friend"]} ]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} + "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} }) } @@ -159,7 +159,7 @@ fn proposal_apply_declares_commit_evidence_failure_but_submit_does_not() { .unwrap() .remove("results"); permissions["proposals"] = json!([{"action":"register-person","operations":["get","submit","apply"], - "ownership":"caller","readableInputs":["given-name","family-name","person"], + "party":"owner","readableInputs":["given-name","family-name","person"], "targets":[{"recordType":"person","rowBoundaries":"unrestricted"}]}]); let mut contract = contracts(); contract["definitions"][0]["subjects"][0]["selector"]["fields"] = diff --git a/crates/registry-breg/tests/action_handler_declaration.rs b/crates/registry-breg/tests/action_handler_declaration.rs index df2fbe4dd0..5bfdc51c42 100644 --- a/crates/registry-breg/tests/action_handler_declaration.rs +++ b/crates/registry-breg/tests/action_handler_declaration.rs @@ -18,7 +18,7 @@ fn project() -> Value { {"id":"unbound","type":"string","maximumLength":64,"classification":"restricted"}], "plan":{"type":"scripted","actionPlan":"person-plan","inputs":["code"], "writes":[{"id":"person","target":{"recordType":"person"},"operation":"create","fields":["code"]}]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person"]}]}}} }) } diff --git a/crates/registry-breg/tests/attachment_promotion_compiler.rs b/crates/registry-breg/tests/attachment_promotion_compiler.rs index c8472d5dc7..87c784d75d 100644 --- a/crates/registry-breg/tests/attachment_promotion_compiler.rs +++ b/crates/registry-breg/tests/attachment_promotion_compiler.rs @@ -45,7 +45,7 @@ fn source() -> Value { "actions":[{"action":"amend","operations":["start"],"targets":[ {"recordType":"application","rowBoundaries":"unrestricted"}]}], "proposals":[{"action":"amend","operations":["get","list","edit","submit","apply"], - "ownership":"caller","readableInputs":["target","name"],"readableAttachments":["document"], + "party":"owner","readableInputs":["target","name"],"readableAttachments":["document"], "writableAttachments":["document"],"targets":[ {"recordType":"application","rowBoundaries":"unrestricted"}]}]}}}}) } diff --git a/crates/registry-breg/tests/compiled_ddl_pins.rs b/crates/registry-breg/tests/compiled_ddl_pins.rs index 188d7d13b2..15b57df635 100644 --- a/crates/registry-breg/tests/compiled_ddl_pins.rs +++ b/crates/registry-breg/tests/compiled_ddl_pins.rs @@ -125,8 +125,8 @@ const FIXTURES: &[Fixture] = &[ "../../../products/breg/fixtures/organization-membership-access/registry.yaml" ), module: None, - ddl_sha256: "6d6431e3e4fb3eb254ef8f3b2e895aed2c09ed4ee7ca506627e1d063359f4578", - revision: "sha256:6ce101a4824207e4feaaca9c790de8580c07d280ca913937e6a643eb1ee48860", + ddl_sha256: include_str!("golden/membership-ddl.sha256"), + revision: include_str!("golden/membership-revision.txt"), }, Fixture { name: "asset-registration-actions", @@ -174,6 +174,10 @@ fn compile(fixture: &Fixture) -> CompiledRegistry { fn ddl_sha256(registry: &CompiledRegistry) -> String { let bytes = serde_json::to_vec(registry.ddl()).expect("DDL inventory serializes"); + sha256(&bytes) +} + +fn sha256(bytes: &[u8]) -> String { Sha256::digest(bytes) .iter() .map(|byte| format!("{byte:02x}")) @@ -186,7 +190,9 @@ fn fixtures_without_consent_keep_their_exact_ddl_and_revision() { for fixture in FIXTURES { let registry = compile(fixture); let ddl = ddl_sha256(®istry); - if ddl != fixture.ddl_sha256 || registry.revision() != fixture.revision { + if ddl != fixture.ddl_sha256.trim_end() + || registry.revision() != fixture.revision.trim_end() + { drift.push(format!( "{}: ddl_sha256 {ddl}, revision {}", fixture.name, @@ -222,3 +228,131 @@ const ACTION_FINGERPRINTS: &[&str] = &[ "facility-registry-actions/transfer-facility: sha256:5f346eabb7d4a8f9bf959432ae47de3aaecaa07962d6fec954452848a31e84d4", "household-contact-actions/register-household-contact: sha256:cb90f8518169dafc15d6d66ca467e9f1093b5d04afe68c970d91b966e7f7c905", ]; + +#[test] +fn membership_fixture_compiles_to_the_recorded_ddl_and_access_inventory() { + let fixture = FIXTURES + .iter() + .find(|fixture| fixture.name == "organization-membership-access") + .expect("membership fixture is listed"); + let registry = compile(fixture); + let ddl = serde_json::to_string_pretty(registry.ddl()).expect("DDL serializes") + "\n"; + let access = serde_json::to_string_pretty(registry.access()) + .expect("access inventory serializes") + + "\n"; + if std::env::var("REGISTRY_BREG_WRITE_DDL_GOLDEN").as_deref() == Ok("1") { + let golden = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/golden"); + for (name, contents) in [ + ("membership-ddl.json", ddl), + ( + "membership-ddl.sha256", + format!("{}\n", ddl_sha256(®istry)), + ), + ( + "membership-revision.txt", + format!("{}\n", registry.revision()), + ), + ] { + std::fs::write(golden.join(name), contents).expect("membership golden writes"); + } + } else { + assert_eq!(ddl, include_str!("golden/membership-ddl.json")); + } + assert_eq!(access, include_str!("golden/membership-access.json")); +} + +#[test] +fn a_record_type_without_membership_compiles_to_the_same_bytes() { + let fixture = &FIXTURES[1]; + let registry = compile(fixture); + assert_eq!(registry.revision(), fixture.revision); + for entity in registry.entities().values() { + assert!(serde_json::to_value(entity) + .unwrap() + .get("membership") + .is_none()); + } +} + +#[test] +fn targets_without_membership_entries_generate_the_same_policies() { + for fixture in &FIXTURES[1..] { + let registry = compile(fixture); + assert_eq!(registry.revision(), fixture.revision); + assert_eq!(ddl_sha256(®istry), fixture.ddl_sha256); + let actions = serde_json::to_value(registry.actions()).unwrap(); + assert!(!actions.to_string().contains("membershipBoundaries")); + } +} + +const MEMBERSHIP_INDEX_ID: &str = "entity.membership.membership.key-index"; + +#[test] +fn a_membership_record_type_generates_its_unique_live_appointment_index() { + let registry = compile(&FIXTURES[0]); + let index = registry + .ddl() + .statements + .iter() + .find(|statement| statement.id == MEMBERSHIP_INDEX_ID) + .unwrap(); + assert_eq!(index.sql, concat!( + "CREATE UNIQUE INDEX \"breg_membership_key_b9ee6c3037\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" ", + "(\"breg_f_membership_organization_bfa076d486640343\", \"breg_f_membership_principal_dbfb37e169be4783\") ", + "WHERE \"breg_f_membership_active_6e662651da1918d2\" IS TRUE AND record_lifecycle = 'active'" + )); + assert!(registry + .ddl() + .statements + .iter() + .any(|statement| statement.id == "entity.membership.index.reference:organization")); +} + +#[test] +fn a_record_type_without_membership_generates_no_membership_index() { + for fixture in &FIXTURES[1..] { + let registry = compile(fixture); + assert!(registry + .ddl() + .statements + .iter() + .all(|statement| !statement.id.ends_with(".membership.key-index"))); + } +} + +#[cfg(feature = "runtime")] +#[test] +fn an_unchanged_membership_declaration_acquires_its_index_over_a_pre_index_baseline() { + use registry_breg::package::{ + change_set_to_applicable_migration_plan, compiled_registry_change_set_from_baseline, + CompiledRegistryMigrationBaseline, + }; + let registry = compile(&FIXTURES[0]); + let mut baseline = CompiledRegistryMigrationBaseline::from_compiled("prior", ®istry); + let mut old_ddl = registry.ddl().clone(); + old_ddl + .statements + .retain(|statement| statement.id != MEMBERSHIP_INDEX_ID); + let old_digest = format!("sha256:{}", sha256(old_ddl.script().as_bytes())); + assert_eq!( + old_digest, + "sha256:88ce9380a31f7201ccda598870579c46fba1352db5598b0eb667bbb23bf68042" + ); + baseline.generated_ddl_sha256 = Some(old_digest); + let changes = compiled_registry_change_set_from_baseline(&baseline, ®istry, "prior"); + assert!(changes.changes.is_empty()); + let plan = change_set_to_applicable_migration_plan(&changes).unwrap(); + let statement = registry + .ddl() + .statements + .iter() + .find(|statement| statement.id == MEMBERSHIP_INDEX_ID) + .unwrap(); + assert!(plan.statements.contains(statement)); + let probe = plan + .statements + .iter() + .find(|statement| statement.id.starts_with("registry_context.membership_")) + .unwrap(); + assert!(probe.sql.starts_with("CREATE OR REPLACE FUNCTION")); +} diff --git a/crates/registry-breg/tests/compiler_contract.rs b/crates/registry-breg/tests/compiler_contract.rs index 1afb6353a9..fd9a828f17 100644 --- a/crates/registry-breg/tests/compiler_contract.rs +++ b/crates/registry-breg/tests/compiler_contract.rs @@ -2279,7 +2279,7 @@ fn batch_route_requires_explicit_bounds_and_compiles_bounded_openapi() { "recordTypes":{{"record":{{"primaryDataset":"test-dataset","route":"records","mutationMode":"mutable"{batch}, "fields":[{{"id":"label","type":"string","maximumLength":32,"required":true,"classification":"internal"}}] }}}}, - "accessProfiles":{{"writer":{{"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{{"records":[{{ + "accessProfiles":{{"writer":{{"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{{"records":[{{ "rowBoundaries": "unrestricted", "recordType":"record","operations":{operations}, "readableFields":["label"],"writableFields":["label"] }}]}} @@ -4024,7 +4024,7 @@ fn independent_additive_modules_are_order_independent() { "recordTypes":{"object": {"primaryDataset":"test-dataset","route":"objects","mutationMode":"mutable", "fields":[{"id":"code","type":"string","maximumLength":32,"required":true,"classification":"internal"}] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"object","operations":["create","get","list","patch"], "readableFields":["code"],"writableFields":["code"], "rowBoundaries": "unrestricted" @@ -4893,7 +4893,7 @@ fn generic_decimal_crs84_point_and_structured_fields_compile_to_deterministic_dd }} ] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"reading","operations":["create","get","list","patch"], "readableFields":["amount","location","payload"], "writableFields":["amount","location","payload"], @@ -5425,7 +5425,7 @@ fn action_decimal_bound_diagnostic_names_capacity_and_preserves_valid_bounds() { "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "create-entry", "operations": ["invoke"], @@ -6685,6 +6685,8 @@ fn generated_openapi_routes_and_physical_names_share_one_compiled_inventory() { "profile.not-authorized", "proposal.rejected", "proposal.review-result-mismatch", + "proposal.subject-changed", + "proposal.subject-not-caller", "proposal.submission-expired", "query.cursor-invalid", "query.filter-required", @@ -6863,7 +6865,7 @@ fn generated_openapi_separates_security_and_mutation_input_from_read_schema() { }]} },"business": { "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["business"], "permissions":{"records":[{ "recordType":"business-record", @@ -8030,7 +8032,7 @@ fn revision_schemas_declare_the_proposal_link_only_for_a_registry_with_proposal_ "inputs":[{"id":"target","type":"reference","target":"target","required":true,"classification":"internal"}, {"id":"value","type":"string","required":true,"maximumLength":64,"classification":"internal"}], "plan":{"type":"fixed","effects":[{"id":"name","target":{"fromInput":"target"},"operation":"patch","set":{"name":{"fromInput":"value"}}}]}}}, - "accessProfiles":{"historian": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"historian": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{ "records":[{"recordType":"target","operations":["get","revisions"],"revisionAccess":true, "readableFields":["name"],"rowBoundaries":"unrestricted"}], "actions":[{"action":"correct-name","operations":[operation],"targets":targets}], @@ -8041,7 +8043,7 @@ fn revision_schemas_declare_the_proposal_link_only_for_a_registry_with_proposal_ json!({"mode":"proposal","proposal":{"review":{"type":"none"}, "application":{"mode":"manual"},"retention":{"mode":"operator-erase"}}}), "start", - json!([{"action":"correct-name","operations":["get"],"ownership":"caller","targets":targets}]), + json!([{"action":"correct-name","operations":["get"],"party":"owner","targets":targets}]), ); let immediate = source(json!({"mode":"immediate"}), "invoke", json!([])); let revision_schemas = |source: &Value| { diff --git a/crates/registry-breg/tests/compiler_statistics.rs b/crates/registry-breg/tests/compiler_statistics.rs index 5251512561..5fa3898b22 100644 --- a/crates/registry-breg/tests/compiler_statistics.rs +++ b/crates/registry-breg/tests/compiler_statistics.rs @@ -819,17 +819,16 @@ fn statistical_disclosure_bounds_are_refused_when_the_project_is_read() { } #[test] -fn statistical_dataset_refuses_caller_dependent_publisher_authority() { - assert_refused( - |value| { - value["recordTypes"]["record"]["fields"] - .as_array_mut() - .unwrap() - .push(json!({ - "id":"organization","type":"reference","target":"organization", - "required":true,"classification":"internal" - })); - value["recordTypes"].as_object_mut().unwrap().extend([ +fn the_statistics_dependency_diagnostic_names_row_boundaries_for_a_membership_entry() { + let mut value = source(); + value["recordTypes"]["record"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({ + "id":"organization","type":"reference","target":"organization", + "required":true,"classification":"internal" + })); + value["recordTypes"].as_object_mut().unwrap().extend([ ("organization".to_owned(), json!({"primaryDataset":"statistics-test","route":"organizations", "mutationMode":"mutable","fields":[ {"id":"name","type":"string","maximumLength":80,"classification":"internal"} @@ -846,16 +845,25 @@ fn statistical_dataset_refuses_caller_dependent_publisher_authority() { "accessRequirements":{"requiredScopes":["membership:use"]} })) ]); - value["accessProfiles"]["publisher"]["requiredScopes"] = json!(["membership:use"]); - value["accessProfiles"]["publisher"]["permissions"]["records"][0] - ["membershipBoundaries"] = json!([{ - "field":"organization","membershipRecordType":"membership", - "membershipKeyField":"organization","principalField":"principal","activeField":"active" - }]); - }, - "breg.statistical-dataset.publisher-caller-dependent", + value["recordTypes"]["membership"]["membership"] = + json!({"key":"organization","principal":"principal","active":"active"}); + value["accessProfiles"]["publisher"]["requiredScopes"] = json!(["membership:use"]); + value["accessProfiles"]["publisher"]["permissions"]["records"][0]["rowBoundaries"] = + json!([{"field":"organization","membership":"membership"}]); + let refusal = compile(&value).unwrap_err(); + let diagnostic = refusal + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == "breg.statistical-dataset.publisher-caller-dependent") + .unwrap(); + assert!( + diagnostic.message.contains("rowBoundaries"), + "{diagnostic:?}" ); +} +#[test] +fn statistical_dataset_refuses_caller_dependent_publisher_authority() { assert_refused( |value| { let boundary = json!({"field":"category","claim":"categories","operator":"in"}); @@ -2046,6 +2054,7 @@ fn without_publisher_derived_read(value: &mut Value) { #[test] fn derived_dimension_records_entity_and_evaluation_date_dependencies() { let mut value = source(); + value["accessProfiles"][PUBLISHER]["requiredScopes"] = json!(["statistics:publish"]); value["recordTypes"]["record"]["derived"] = json!([{ "id":"statistics","sql":"sql/statistics.sql","key":"id", "fields":[{"id":"evaluated-category","type":"vocabulary-code","vocabulary":"category","values":["a","b"],"classification":"internal"}] diff --git a/crates/registry-breg/tests/data_operations.rs b/crates/registry-breg/tests/data_operations.rs index 68f2c07ebb..94daa7e7ff 100644 --- a/crates/registry-breg/tests/data_operations.rs +++ b/crates/registry-breg/tests/data_operations.rs @@ -50,7 +50,7 @@ fn compiled(allow_data_export: bool) -> registry_breg::CompiledRegistry { }}, "accessProfiles": {PROFILE: { "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": ENTITY, "operations": ["create", "patch", "batch", "list"], @@ -336,7 +336,7 @@ fn data_validate_and_chunk_plan_reuse_runtime_rules_and_compiled_batch_bounds() "batch":{"maximumItems":2,"maximumBytes":100}, "fields":[{"id":"code","type":"text","maximumLength":1000,"required":true, "classification":"internal"}]}}, - "accessProfiles":{PROFILE: {"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{PROFILE: {"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":ENTITY, "operations":["create","batch"],"readableFields":["code"], "writableFields":["code"], "rowBoundaries": "unrestricted"}]}}} @@ -385,7 +385,7 @@ fn data_lifecycle_uses_exact_compiled_api_names() { }}, "accessProfiles": {PROFILE: { "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": ENTITY, "operations": ["create", "patch", "batch", "list"], diff --git a/crates/registry-breg/tests/disclosure/fields.rs b/crates/registry-breg/tests/disclosure/fields.rs index 6f01d64af3..78e5ddc092 100644 --- a/crates/registry-breg/tests/disclosure/fields.rs +++ b/crates/registry-breg/tests/disclosure/fields.rs @@ -75,6 +75,7 @@ fn compile_writable_project(mut source: Value) -> registry_breg::CompiledRegistr .unwrap() .values_mut() { + profile["requiredScopes"] = json!(["records:write"]); let grant = &mut profile["permissions"]["records"][0]; assert_eq!(grant["recordType"], "person"); grant["operations"] = json!(["create", "get", "list", "patch", "batch"]); @@ -206,7 +207,7 @@ async fn send( let claims = VerifiedRequestClaims::authenticated( "registry_principal", "canary-principal", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, std::collections::BTreeMap::new(), ) diff --git a/crates/registry-breg/tests/disclosure/history.rs b/crates/registry-breg/tests/disclosure/history.rs index 8d319bc5b0..827eb15c02 100644 --- a/crates/registry-breg/tests/disclosure/history.rs +++ b/crates/registry-breg/tests/disclosure/history.rs @@ -79,7 +79,7 @@ fn history_source() -> Value { }; let person_target = json!([{"recordType": "person", "rowBoundaries": "unrestricted"}]); source["accessProfiles"][WRITER] = json!({ - "principalClaim": "registry_principal", "requiredScopes": "unrestricted", + "principalClaim": "registry_principal", "requiredScopes": ["records:write"], "permissions": { "records": [ writable("person", &PERSON_FIELDS), @@ -91,7 +91,7 @@ fn history_source() -> Value { {"action": "correct-person-name", "operations": ["start"], "targets": person_target.clone()}], "proposals": [ - {"action": "correct-person-name", "ownership": "caller", + {"action": "correct-person-name", "party": "owner", "operations": ["get", "list", "edit", "submit", "revise", "rebase", "retry", "cancel", "apply"], "targets": person_target}]}}); source["actions"] = json!({ @@ -131,7 +131,7 @@ fn claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated_with_actor_kind( "registry_principal", "history-principal", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::::new(), registry_platform_oidc::ActorKind::Human, diff --git a/crates/registry-breg/tests/disclosure/proposals.rs b/crates/registry-breg/tests/disclosure/proposals.rs index 285aa26542..1247cc76d5 100644 --- a/crates/registry-breg/tests/disclosure/proposals.rs +++ b/crates/registry-breg/tests/disclosure/proposals.rs @@ -38,7 +38,7 @@ fn claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated_with_actor_kind( "sub", "reviewer", - BTreeSet::new(), + BTreeSet::from(["proposals:write".to_owned()]), None, BTreeMap::new(), registry_platform_oidc::ActorKind::Human, @@ -50,7 +50,7 @@ fn action_grant(action: &str, record_type: &str, context: &[&str]) -> (Value, Va ( json!({"action": action, "operations": ["start"], "targets": [{"recordType": record_type, "rowBoundaries": "unrestricted"}]}), - json!({"action": action, "ownership": "caller", + json!({"action": action, "party": "owner", "operations": ["get", "list", "edit", "submit", "revise", "rebase", "retry", "cancel", "apply", "get-review-context"], "readableAttachments": [], "writableAttachments": [], @@ -111,6 +111,7 @@ fn proposal_project() -> Value { .values_mut() { profile["principalClaim"] = json!("sub"); + profile["requiredScopes"] = json!(["proposals:write"]); let records = profile["permissions"]["records"].as_array_mut().unwrap(); for grant in records.iter_mut() { let writable: &[&str] = match grant["recordType"].as_str().unwrap() { diff --git a/crates/registry-breg/tests/disclosure/writes.rs b/crates/registry-breg/tests/disclosure/writes.rs index b05d4341a3..16651105d4 100644 --- a/crates/registry-breg/tests/disclosure/writes.rs +++ b/crates/registry-breg/tests/disclosure/writes.rs @@ -51,6 +51,7 @@ fn writes_source() -> Value { let lifecycle = proposal_lifecycle(); for (id, profile) in source["accessProfiles"].as_object_mut().unwrap() { let writer = id == WRITER; + profile["requiredScopes"] = json!(["records:write"]); let permissions = &mut profile["permissions"]; if !writer { let grant = &mut permissions["records"][0]; @@ -83,9 +84,9 @@ fn writes_source() -> Value { json!({"action": "correct-person-email", "operations": ["start"], "targets": targets}), ]); permissions["proposals"].as_array_mut().unwrap().extend([ - json!({"action": "propose-person-email", "ownership": "caller", + json!({"action": "propose-person-email", "party": "owner", "operations": lifecycle, "targets": targets}), - json!({"action": "correct-person-email", "ownership": "caller", + json!({"action": "correct-person-email", "party": "owner", "operations": lifecycle, "targets": targets}), ]); } @@ -619,7 +620,7 @@ const ACTION_CLERK: &str = "action-clerk"; fn action_clerk_source(exempt: bool) -> Value { let mut source = writes_source(); source["accessProfiles"][ACTION_CLERK] = json!({ - "principalClaim": "registry_principal", "requiredScopes": "unrestricted", + "principalClaim": "registry_principal", "requiredScopes": ["records:write"], "permissions": {"actions": [ {"action": "set-person-email", "operations": ["invoke"], "targets": [{"recordType": "person", "rowBoundaries": "unrestricted"}]}]}}); @@ -1165,9 +1166,9 @@ fn residence_source() -> Value { "targets": targets}), ]); permissions["proposals"].as_array_mut().unwrap().extend([ - json!({"action": "propose-residence-protection", "ownership": "caller", + json!({"action": "propose-residence-protection", "party": "owner", "operations": proposal_lifecycle(), "targets": targets}), - json!({"action": "correct-residence-protection", "ownership": "caller", + json!({"action": "correct-residence-protection", "party": "owner", "operations": proposal_lifecycle(), "targets": targets}), ]); } diff --git a/crates/registry-breg/tests/disclosure_compile.rs b/crates/registry-breg/tests/disclosure_compile.rs index 6ea24a82e0..acda3dfc5c 100644 --- a/crates/registry-breg/tests/disclosure_compile.rs +++ b/crates/registry-breg/tests/disclosure_compile.rs @@ -313,9 +313,10 @@ fn workflow_source() -> Value { let targets = |record_type: &str| json!([{"recordType":record_type,"rowBoundaries":"unrestricted"}]); let clerk = |permissions: Value| { - json!({"principalClaim":"registry_principal","requiredScopes":"unrestricted", + json!({"principalClaim":"registry_principal","requiredScopes":["registry:workflow"], "permissions":permissions}) }; + value["accessProfiles"]["protection-officer"]["requiredScopes"] = json!(["registry:workflow"]); value["accessProfiles"]["protection-officer"]["permissions"]["actions"] = json!([ {"action":"propose-person-name","operations":["start"],"targets":targets("person")}]); let profiles = value["accessProfiles"].as_object_mut().unwrap(); @@ -327,7 +328,7 @@ fn workflow_source() -> Value { profiles.insert( "proposal-clerk".to_owned(), clerk(json!({"proposals":[ - {"action":"propose-person-name","ownership":"caller","operations":["get","list","apply"], + {"action":"propose-person-name","party":"owner","operations":["get","list","apply"], "targets":targets("person")}]})), ); profiles.insert( @@ -1597,8 +1598,7 @@ fn a_membership_boundary_on_a_derived_source_grant_is_a_finding() { value["recordTypes"]["facility"]["derived"] = json!([{"id":"inspection-state","sql":"sql/derived.sql","key":"id", "fields":[{"id":"has-passed-inspection","type":"boolean","classification":"internal"}]}]); let sql = "SELECT f.id AS id, (count(i.id) FILTER (WHERE i.passed IS TRUE) > 0) AS has_passed_inspection FROM registry_source.facility f LEFT JOIN registry_source.inspection i ON i.facility = f.id GROUP BY f.id"; - let membership = json!([{"field":"organization","membershipRecordType":"membership", - "membershipKeyField":"organization","principalField":"principal","activeField":"active"}]); + let membership = json!([{"field":"organization","membership":"membership"}]); let grant = |profile: &str, value: &mut Value, membership: Option<&Value>| { let records = value["accessProfiles"][profile]["permissions"]["records"] .as_array_mut() @@ -1614,7 +1614,7 @@ fn a_membership_boundary_on_a_derived_source_grant_is_a_finding() { let mut inspection = json!({"recordType":"inspection","operations":["get"], "rowBoundaries":"unrestricted","readableFields":["facility"]}); if let Some(membership) = membership { - inspection["membershipBoundaries"] = membership.clone(); + inspection["rowBoundaries"] = membership.clone(); } records.push(inspection); }; @@ -1623,13 +1623,53 @@ fn a_membership_boundary_on_a_derived_source_grant_is_a_finding() { grant("member", &mut member, None); assert!(withheld_source_rows(compile_with_sql(&member, sql)).is_empty()); + let mut missing = member.clone(); + missing["accessProfiles"]["member"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .pop(); + let unreadable = compile_with_sql(&missing, sql).unwrap_err(); + let message = &unreadable + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == UNREADABLE_SOURCE) + .unwrap() + .message; + assert!( + message.contains("requires membership through `membership`"), + "{message}" + ); + assert!(!message.contains("`unrestricted`"), "{message}"); + + let mut different = member.clone(); + different["recordTypes"]["inspection"]["fields"] + .as_array_mut() + .unwrap() + .push( + json!({"id":"region","type":"string","maximumLength":16,"classification":"internal"}), + ); + different["accessProfiles"]["member"]["permissions"]["records"][1]["rowBoundaries"] = + json!([{"field":"region","claim":"region","operator":"equals"}]); + let mismatch = compile_with_sql(&different, sql).unwrap_err(); + let message = &mismatch + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == SOURCE_BOUNDARY) + .unwrap() + .message; + assert!( + message.contains("retaining the required membership restrictions"), + "{message}" + ); + assert!(!message.contains("`unrestricted`"), "{message}"); + // The reader's grant on the facility carries the same membership. let mut member = value.clone(); grant("member", &mut member, Some(&membership)); let found = withheld_source_rows(compile_with_sql(&member, sql)); assert_eq!( finding_paths(&found), - ["recordTypes[id=inspection].accessProfiles[id=member].membershipBoundaries"] + ["recordTypes[id=inspection].accessProfiles[id=member].rowBoundaries"] ); for named in [ "`member`", @@ -1647,14 +1687,22 @@ fn a_membership_boundary_on_a_derived_source_grant_is_a_finding() { grant("member", &mut member, Some(&other_field)); assert_eq!( finding_paths(&withheld_source_rows(compile_with_sql(&member, sql))), - ["recordTypes[id=inspection].accessProfiles[id=member].membershipBoundaries"] + ["recordTypes[id=inspection].accessProfiles[id=member].rowBoundaries"] ); - // The steward's grant on the facility carries none. - grant("steward", &mut value, Some(&membership)); + // A profile whose own facility grant carries none. It cannot be the + // membership writer: a profile bounded through a source cannot also + // create that source's rows. + let mut auditor = value["accessProfiles"]["steward"].clone(); + auditor["permissions"]["records"] + .as_array_mut() + .unwrap() + .retain(|record| record["recordType"] != "membership"); + value["accessProfiles"]["auditor"] = auditor; + grant("auditor", &mut value, Some(&membership)); assert_eq!( finding_paths(&withheld_source_rows(compile_with_sql(&value, sql))), - ["recordTypes[id=inspection].accessProfiles[id=steward].membershipBoundaries"] + ["recordTypes[id=inspection].accessProfiles[id=auditor].rowBoundaries"] ); } diff --git a/crates/registry-breg/tests/disclosure_exposure.rs b/crates/registry-breg/tests/disclosure_exposure.rs index 79213fb0ce..d60f093c11 100644 --- a/crates/registry-breg/tests/disclosure_exposure.rs +++ b/crates/registry-breg/tests/disclosure_exposure.rs @@ -5,6 +5,7 @@ //! caller, but the author surfaces list the conditions in full. use registry_breg::access::explain_access; +#[cfg(all(feature = "runtime", feature = "tooling"))] use registry_breg::access_preview::{preview_access, AccessScenario}; use registry_breg::artifacts::inspect_registry; use registry_breg::odrl_export::export_odrl; @@ -67,6 +68,7 @@ fn author_inspection_lists_the_conditions_in_full() { ); } +#[cfg(all(feature = "runtime", feature = "tooling"))] fn scenario(profile: &str) -> AccessScenario { serde_json::from_value( json!({"recordType":"person","accessProfile":profile,"operation":"get", @@ -76,6 +78,7 @@ fn scenario(profile: &str) -> AccessScenario { .unwrap() } +#[cfg(all(feature = "runtime", feature = "tooling"))] #[test] fn the_access_preview_names_the_conditions_that_bind_the_profile() { let registry = compiled(); @@ -213,7 +216,7 @@ fn acting(bound_by: Option<&str>) -> Value { {"action": "set-person-phone", "operations": ["invoke"], "targets": targets}, {"action": "propose-person-phone", "operations": ["start"], "targets": targets}]); registrar["permissions"]["proposals"] = json!([ - {"action": "propose-person-phone", "ownership": "caller", + {"action": "propose-person-phone", "party": "owner", "operations": ["get", "list", "edit", "submit", "cancel", "apply"], "readableInputs": ["person", "phone"], "targets": targets}]); value diff --git a/crates/registry-breg/tests/explicit_row_authority.rs b/crates/registry-breg/tests/explicit_row_authority.rs index e57c8ecf39..9bb8095ef4 100644 --- a/crates/registry-breg/tests/explicit_row_authority.rs +++ b/crates/registry-breg/tests/explicit_row_authority.rs @@ -66,25 +66,23 @@ fn invocation_and_mandatory_requirements_do_not_invent_row_grants() { #[test] fn membership_preserves_explicit_row_declarations_and_round_trips() { - let boundaries = json!([{ - "field":"organization", "membershipRecordType":"membership", - "membershipKeyField":"organization", "principalField":"principal", - "activeField":"active" - }]); - let mut grant = json!({ - "recordType":"record", "operations":["get"], "membershipBoundaries": boundaries - }); + let entry = json!([{"field":"organization", "membership":"membership"}]); + let mut grant = json!({"recordType":"record", "operations":["get"]}); requires_explicit_rows::(grant.clone()); - grant["rowBoundaries"] = json!("unrestricted"); + grant["rowBoundaries"] = entry.clone(); + grant["readableFields"] = json!({"upToClassification":"restricted"}); + let readable_fields = grant["readableFields"].clone(); let parsed: EntityPermissionSource = serde_json::from_value(grant).unwrap(); - assert_eq!(parsed.membership_boundaries.len(), 1); - assert_eq!( - serde_json::to_value(parsed).unwrap()["membershipBoundaries"], - boundaries - ); + assert_eq!(parsed.membership_row_boundaries.len(), 1); + let written = serde_json::to_value(parsed).unwrap(); + assert_eq!(written["rowBoundaries"], entry); + assert_eq!(written["readableFields"], readable_fields); carries_compiled_rows::(json!({ "id":"member", "principalClaim":"sub", "operations":["get"], - "membershipBoundaries": boundaries + "membershipBoundaries": [{ + "field":"organization", "membershipRecordType":"membership", + "membershipKeyField":"organization", "principalField":"principal", "activeField":"active" + }] })); } diff --git a/crates/registry-breg/tests/field_encryption_contract.rs b/crates/registry-breg/tests/field_encryption_contract.rs index 149b03beb6..3f125171af 100644 --- a/crates/registry-breg/tests/field_encryption_contract.rs +++ b/crates/registry-breg/tests/field_encryption_contract.rs @@ -34,7 +34,7 @@ fn encrypted_project() -> Value { "lookup":{"normalization":["trim","uppercase"],"unique":true}} ] }}, - "accessProfiles":{"caseworker": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"caseworker": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"case","rowBoundaries":"unrestricted","operations":["get","list","create","patch"], "readableFields":["label","secret"],"writableFields":["label","secret"] }]}}} @@ -706,7 +706,7 @@ fn proposal_project() -> Value { .unwrap() .remove("writableFields"); permissions["actions"] = json!([{"action":"correct-case","operations":["start"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]); - permissions["proposals"] = json!([{"action":"correct-case","operations":["get","edit","submit","apply"],"ownership":"caller","readableInputs":["case","label"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]); + permissions["proposals"] = json!([{"action":"correct-case","operations":["get","edit","submit","apply"],"party":"owner","readableInputs":["case","label"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]); source } diff --git a/crates/registry-breg/tests/fixture_tooling.rs b/crates/registry-breg/tests/fixture_tooling.rs index c89d286d26..158a4e8f69 100644 --- a/crates/registry-breg/tests/fixture_tooling.rs +++ b/crates/registry-breg/tests/fixture_tooling.rs @@ -154,6 +154,7 @@ journeys: accessProfile: registrar claims: principal: fixture-registrar + scopes: [person:write] purpose: case-management directClaims: {{jurisdiction: {value}}} request: {{type: query, select: [personCode]}} @@ -227,8 +228,8 @@ journeys: ); let unknown_scope = journey("[zone-a, zone-b]").replace( - "purpose: case-management", - "purpose: case-management\n scopes: [registry:extra]", + "scopes: [person:write]", + "scopes: [person:write, registry:extra]", ); let error = validate_fixture_journeys(unknown_scope.as_bytes(), ®istry) .expect_err("sets do not permit undeclared scopes"); @@ -251,6 +252,7 @@ journeys: accessProfile: registrar claims: principal: fixture-registrar + scopes: [person:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -266,6 +268,7 @@ journeys: accessProfile: registrar claims: principal: fixture-registrar + scopes: [person:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: {type: query, select: [personCode, legalName], count: true} @@ -275,6 +278,7 @@ journeys: accessProfile: registrar claims: principal: fixture-registrar + scopes: [person:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -349,6 +353,7 @@ journeys: accessProfile: household-seed claims: principal: fixture-seed + scopes: [household:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -800,7 +805,7 @@ fn compiled_crud_alias_fixture() -> registry_breg::CompiledRegistry { ], "constraints":[{"type":"unique","fields":["person-code"]}] }}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","requiredPurposes":["case-management"], + "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":["person:write"],"requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"person","operations":["create","get","list","patch"], "readableFields":["jurisdiction","person-code","legal-name"], @@ -859,7 +864,7 @@ fn compiled_action_fixture() -> registry_breg::CompiledRegistry { "set":{"contact-person":{"fromEffect":"person"}}} ]} }}, - "accessProfiles":{"household-seed": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","requiredPurposes":["case-management"], + "accessProfiles":{"household-seed": {"default":true,"principalClaim":"registry_principal","requiredScopes":["household:write"],"requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"household","operations":["create","get"],"readableFields":["jurisdiction","household-code","contact-person"], "writableFields":["jurisdiction","household-code"],"rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] @@ -1013,7 +1018,7 @@ fn fixture_journey_reader_reports_every_unknown_removed_and_anchored_key_with_it (source.line, source.column) }) .collect::>(); - assert_eq!(positions, [(Some(8), Some(9)), (Some(16), Some(11))]); + assert_eq!(positions, [(Some(8), Some(9)), (Some(17), Some(11))]); assert!( !format!("{error:?}").contains("canary"), "the refusal carries no authored value: {error:?}" @@ -1500,6 +1505,7 @@ journeys: accessProfile: registrar claims: principal: private-principal-canary + scopes: [person:write] purpose: case-management directClaims: {direct_claims} request: {{type: list}} diff --git a/crates/registry-breg/tests/fixtures/absent-optional-action-inputs.yaml b/crates/registry-breg/tests/fixtures/absent-optional-action-inputs.yaml index f2534634fe..90d2461489 100644 --- a/crates/registry-breg/tests/fixtures/absent-optional-action-inputs.yaml +++ b/crates/registry-breg/tests/fixtures/absent-optional-action-inputs.yaml @@ -46,7 +46,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [registry:contact:register] permissions: actions: - action: create-entry diff --git a/crates/registry-breg/tests/fixtures/authority-mapping.yaml b/crates/registry-breg/tests/fixtures/authority-mapping.yaml index e6ea50048c..08c03711b3 100644 --- a/crates/registry-breg/tests/fixtures/authority-mapping.yaml +++ b/crates/registry-breg/tests/fixtures/authority-mapping.yaml @@ -52,7 +52,7 @@ accessProfiles: reviewer: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [proposals:write] permissions: actions: - action: correction @@ -63,7 +63,7 @@ accessProfiles: proposals: - action: correction operations: [get, edit, submit, apply] - ownership: caller + party: owner readableInputs: [asset, label] targets: - recordType: asset diff --git a/crates/registry-breg/tests/fixtures/event-record/shapes.yaml b/crates/registry-breg/tests/fixtures/event-record/shapes.yaml index 3a79eaba91..05fd27f1f2 100644 --- a/crates/registry-breg/tests/fixtures/event-record/shapes.yaml +++ b/crates/registry-breg/tests/fixtures/event-record/shapes.yaml @@ -196,7 +196,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [records:write] permissions: actions: - action: record-grant-pause @@ -216,5 +216,5 @@ accessProfiles: - action: correct-grant-number operations: [get, list, edit, submit, revise, rebase, retry, cancel, apply] readableInputs: [grant-ref, value] - ownership: caller + party: owner targets: [{recordType: grant, rowBoundaries: unrestricted}] diff --git a/crates/registry-breg/tests/fixtures/fixed-optional-action-input.yaml b/crates/registry-breg/tests/fixtures/fixed-optional-action-input.yaml index f8233e7a78..15cba4f6bb 100644 --- a/crates/registry-breg/tests/fixtures/fixed-optional-action-input.yaml +++ b/crates/registry-breg/tests/fixtures/fixed-optional-action-input.yaml @@ -25,7 +25,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [records:write] permissions: actions: - action: create-entry diff --git a/crates/registry-breg/tests/fixtures/fixture-tooling/journeys.yaml b/crates/registry-breg/tests/fixtures/fixture-tooling/journeys.yaml index 9e5302129b..918a59864a 100644 --- a/crates/registry-breg/tests/fixtures/fixture-tooling/journeys.yaml +++ b/crates/registry-breg/tests/fixtures/fixture-tooling/journeys.yaml @@ -8,6 +8,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -23,6 +24,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: {type: get, recordCapture: first-widget} @@ -35,6 +37,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: {type: list} @@ -50,6 +53,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -68,6 +72,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -81,6 +86,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] directClaims: {jurisdiction: zone-a} request: {type: get, recordCapture: revised-widget} expect: diff --git a/crates/registry-breg/tests/fixtures/fixture-tooling/project.yaml b/crates/registry-breg/tests/fixtures/fixture-tooling/project.yaml index 41ca3ca45f..f24f127afe 100644 --- a/crates/registry-breg/tests/fixtures/fixture-tooling/project.yaml +++ b/crates/registry-breg/tests/fixtures/fixture-tooling/project.yaml @@ -52,7 +52,7 @@ accessProfiles: operator: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [fixture:write] requiredPurposes: [case-management] permissions: records: diff --git a/crates/registry-breg/tests/fixtures/fixture-tooling/terminal-failure.yaml b/crates/registry-breg/tests/fixtures/fixture-tooling/terminal-failure.yaml index e3c1de6a7b..07dee6db7a 100644 --- a/crates/registry-breg/tests/fixtures/fixture-tooling/terminal-failure.yaml +++ b/crates/registry-breg/tests/fixtures/fixture-tooling/terminal-failure.yaml @@ -8,6 +8,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -22,6 +23,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: diff --git a/crates/registry-breg/tests/generated_identifier_compiler.rs b/crates/registry-breg/tests/generated_identifier_compiler.rs index 0764511d1c..51059389cb 100644 --- a/crates/registry-breg/tests/generated_identifier_compiler.rs +++ b/crates/registry-breg/tests/generated_identifier_compiler.rs @@ -62,7 +62,7 @@ fn project_value() -> Value { }}, "accessProfiles": {"editor": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "record", "operations": ["create", "get"], @@ -409,7 +409,7 @@ fn fixed_actions_cannot_supply_server_generated_identifiers() { project["accessProfiles"] = json!({"operator": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "create-record", "operations": ["invoke"], @@ -479,7 +479,7 @@ fn create_effect_bounds_include_server_generated_fields() { project["accessProfiles"] = json!({"operator": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "create-record", "operations": [operation], diff --git a/crates/registry-breg/tests/golden/membership-access.json b/crates/registry-breg/tests/golden/membership-access.json new file mode 100644 index 0000000000..11ba0cd603 --- /dev/null +++ b/crates/registry-breg/tests/golden/membership-access.json @@ -0,0 +1,113 @@ +{ + "entries": [ + { + "routeId": "records.facility.create", + "recordType": "facility", + "operation": "create", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.facility.get", + "recordType": "facility", + "operation": "get", + "profileIds": [ + "member", + "steward" + ], + "defaultProfileId": "member" + }, + { + "routeId": "records.facility.lookup", + "recordType": "facility", + "operation": "lookup", + "profileIds": [ + "member" + ], + "defaultProfileId": "member" + }, + { + "routeId": "records.facility.list", + "recordType": "facility", + "operation": "list", + "profileIds": [ + "member" + ], + "defaultProfileId": "member" + }, + { + "routeId": "records.facility.patch", + "recordType": "facility", + "operation": "patch", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.facility.revisions", + "recordType": "facility", + "operation": "revisions", + "profileIds": [ + "member" + ], + "defaultProfileId": "member" + }, + { + "routeId": "records.facility.snapshot", + "recordType": "facility", + "operation": "snapshot", + "profileIds": [ + "member" + ], + "defaultProfileId": "member" + }, + { + "routeId": "records.membership.create", + "recordType": "membership", + "operation": "create", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.membership.get", + "recordType": "membership", + "operation": "get", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.membership.patch", + "recordType": "membership", + "operation": "patch", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.organization.create", + "recordType": "organization", + "operation": "create", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + }, + { + "routeId": "records.organization.get", + "recordType": "organization", + "operation": "get", + "profileIds": [ + "steward" + ], + "defaultProfileId": "steward" + } + ] +} diff --git a/crates/registry-breg/tests/golden/membership-ddl.json b/crates/registry-breg/tests/golden/membership-ddl.json new file mode 100644 index 0000000000..d4aa0f2e17 --- /dev/null +++ b/crates/registry-breg/tests/golden/membership-ddl.json @@ -0,0 +1,334 @@ +{ + "requiresBtreeGist": false, + "statements": [ + { + "id": "schema.registry_data", + "kind": "schema", + "sql": "CREATE SCHEMA IF NOT EXISTS registry_data" + }, + { + "id": "schema.registry_source", + "kind": "schema", + "sql": "CREATE SCHEMA IF NOT EXISTS registry_source" + }, + { + "id": "schema.registry_derived", + "kind": "schema", + "sql": "CREATE SCHEMA IF NOT EXISTS registry_derived" + }, + { + "id": "schema.registry_context", + "kind": "schema", + "sql": "CREATE SCHEMA IF NOT EXISTS registry_context" + }, + { + "id": "function.registry_context.evaluation_date", + "kind": "function", + "sql": "CREATE OR REPLACE FUNCTION registry_context.evaluation_date()\n RETURNS date\n LANGUAGE sql\n STABLE\n SECURITY INVOKER\n AS $breg_function$\n SELECT NULLIF(current_setting('registry.evaluation_date', true), '')::date\n $breg_function$" + }, + { + "id": "entity.facility.table", + "kind": "table", + "sql": "CREATE TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_facility_label_49700f8f0b0d4a57\" varchar(80) COLLATE pg_catalog.pg_c_utf8 NOT NULL, \"breg_f_facility_organization_c72e96e6196479cc\" uuid NOT NULL)" + }, + { + "id": "entity.membership.table", + "kind": "table", + "sql": "CREATE TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_membership_active_6e662651da1918d2\" boolean NOT NULL, \"breg_f_membership_organization_bfa076d486640343\" uuid NOT NULL, \"breg_f_membership_principal_dbfb37e169be4783\" varchar(80) COLLATE pg_catalog.pg_c_utf8 NOT NULL, \"breg_f_membership_private_note_5a8d02ceb53dd0bd\" varchar(80) COLLATE pg_catalog.pg_c_utf8)" + }, + { + "id": "entity.organization.table", + "kind": "table", + "sql": "CREATE TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_organization_name_39e5047e3f964468\" varchar(80) COLLATE pg_catalog.pg_c_utf8)" + }, + { + "id": "entity.facility.reference-lifecycle.column", + "kind": "column", + "sql": "ALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" ADD COLUMN record_reference_lifecycle text COLLATE pg_catalog.pg_c_utf8\n GENERATED ALWAYS AS (CASE WHEN record_lifecycle = 'active' THEN 'active'::text ELSE NULL::text END) STORED" + }, + { + "id": "entity.membership.reference-lifecycle.column", + "kind": "column", + "sql": "ALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" ADD COLUMN record_reference_lifecycle text COLLATE pg_catalog.pg_c_utf8\n GENERATED ALWAYS AS (CASE WHEN record_lifecycle = 'active' THEN 'active'::text ELSE NULL::text END) STORED" + }, + { + "id": "entity.organization.reference-lifecycle.key", + "kind": "constraint", + "sql": "ALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" ADD CONSTRAINT \"breg_rk_organization_1a9958900e5456b0\" UNIQUE (record_id, record_lifecycle)" + }, + { + "id": "entity.facility.field.organization.reference", + "kind": "reference", + "sql": "ALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" ADD CONSTRAINT \"breg_r_facility_organization_d6e2e76fcb68e418\" FOREIGN KEY (\"breg_f_facility_organization_c72e96e6196479cc\") REFERENCES registry_data.\"breg_e_organization_6ccb51e3b2202a71\" (record_id) ON DELETE RESTRICT" + }, + { + "id": "entity.facility.field.organization.active-reference", + "kind": "reference", + "sql": "ALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" ADD CONSTRAINT \"breg_ar_facility_organization_c2ee3822a6f70011\" FOREIGN KEY (\"breg_f_facility_organization_c72e96e6196479cc\", record_reference_lifecycle) REFERENCES registry_data.\"breg_e_organization_6ccb51e3b2202a71\" (record_id, record_lifecycle) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT;\nALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" FORCE ROW LEVEL SECURITY" + }, + { + "id": "entity.facility.index.reference:organization", + "kind": "index", + "sql": "CREATE INDEX \"breg_ri_facility_organization_a21122438500a54c\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" (\"breg_f_facility_organization_c72e96e6196479cc\")" + }, + { + "id": "entity.membership.field.organization.reference", + "kind": "reference", + "sql": "ALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" ADD CONSTRAINT \"breg_r_membership_organization_faa70a2468df1cb1\" FOREIGN KEY (\"breg_f_membership_organization_bfa076d486640343\") REFERENCES registry_data.\"breg_e_organization_6ccb51e3b2202a71\" (record_id) ON DELETE RESTRICT" + }, + { + "id": "entity.membership.field.organization.active-reference", + "kind": "reference", + "sql": "ALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" ADD CONSTRAINT \"breg_ar_membership_organization_09291f896d3ebb10\" FOREIGN KEY (\"breg_f_membership_organization_bfa076d486640343\", record_reference_lifecycle) REFERENCES registry_data.\"breg_e_organization_6ccb51e3b2202a71\" (record_id, record_lifecycle) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT;\nALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" FORCE ROW LEVEL SECURITY" + }, + { + "id": "entity.membership.index.membership-principal-key", + "kind": "index", + "sql": "CREATE INDEX \"breg_i_membership_membership_principal_key_71354dc018b3a225\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" (\"breg_f_membership_principal_dbfb37e169be4783\", \"breg_f_membership_organization_bfa076d486640343\", \"breg_f_membership_active_6e662651da1918d2\", record_id)" + }, + { + "id": "entity.membership.index.reference:organization", + "kind": "index", + "sql": "CREATE INDEX \"breg_ri_membership_organization_d0fbd830aaf560b4\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" (\"breg_f_membership_organization_bfa076d486640343\")" + }, + { + "id": "entity.membership.membership.key-index", + "kind": "index", + "sql": "CREATE UNIQUE INDEX \"breg_membership_key_b9ee6c3037\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" (\"breg_f_membership_organization_bfa076d486640343\", \"breg_f_membership_principal_dbfb37e169be4783\") WHERE \"breg_f_membership_active_6e662651da1918d2\" IS TRUE AND record_lifecycle = 'active'" + }, + { + "id": "registry_context.membership_7b967b5ec89a5c63ab8056cd", + "kind": "function", + "sql": "CREATE FUNCTION registry_context.\"membership_7b967b5ec89a5c63ab8056cd\"(uuid) RETURNS boolean LANGUAGE plpgsql STABLE STRICT SECURITY INVOKER SET search_path = pg_catalog AS 'DECLARE prior_marker text := current_setting(''registry.membership_probe'', true); authorized boolean; BEGIN PERFORM set_config(''registry.membership_probe'', ''membership_7b967b5ec89a5c63ab8056cd'', true); SELECT EXISTS (SELECT 1 FROM registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" AS membership WHERE membership.record_lifecycle = ''active'' AND membership.\"breg_f_membership_principal_dbfb37e169be4783\" = NULLIF(current_setting(''registry.principal'', true), '''') AND membership.\"breg_f_membership_active_6e662651da1918d2\" IS TRUE AND membership.\"breg_f_membership_organization_bfa076d486640343\" = $1) INTO authorized; PERFORM set_config(''registry.membership_probe'', COALESCE(prior_marker, ''''), true); RETURN authorized; EXCEPTION WHEN OTHERS THEN RAISE; END'" + }, + { + "id": "entity.facility.rls.enable", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" ENABLE ROW LEVEL SECURITY" + }, + { + "id": "entity.facility.rls.force", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_facility_675cdbdae206c49c\" FORCE ROW LEVEL SECURITY" + }, + { + "id": "entity.facility.policy.registry_rls_select_b56c984fa34e60b58e32e7d3", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_select_b56c984fa34e60b58e32e7d3\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'member' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0 AND registry_context.\"membership_7b967b5ec89a5c63ab8056cd\"(\"breg_f_facility_organization_c72e96e6196479cc\")) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_b56c984fa34e60b58e32e7d3\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" IS 'breg/policy/v1/1ff0fa085876122e11f4c5a802c2e8e4e900a21cbc448d1624bf307fe49fae5f'" + }, + { + "id": "entity.facility.policy.registry_rls_select_bd688fd36cf3a53a01382a56", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_select_bd688fd36cf3a53a01382a56\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_bd688fd36cf3a53a01382a56\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" IS 'breg/policy/v1/c63db1bfd0fa09289779ea867bf5407db8ce9ae4d09bc56efa120a2aab40c367'" + }, + { + "id": "entity.facility.policy.registry_rls_insert_77687d5ac1f8badf901ee933", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_insert_77687d5ac1f8badf901ee933\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_insert_77687d5ac1f8badf901ee933\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" IS 'breg/policy/v1/e16b1d51effd9575d791229c843740a5bdbbb37c5697398cafa369f021e6539e'" + }, + { + "id": "entity.facility.policy.registry_rls_update_f6e327e7ea9457483f3eabeb", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_update_f6e327e7ea9457483f3eabeb\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" FOR UPDATE USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active') WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_update_f6e327e7ea9457483f3eabeb\" ON registry_data.\"breg_e_facility_675cdbdae206c49c\" IS 'breg/policy/v1/6202ed55d51b18cee0233559fbbab14f840ad223c4986048cb2e213d8c851643'" + }, + { + "id": "entity.membership.rls.enable", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" ENABLE ROW LEVEL SECURITY" + }, + { + "id": "entity.membership.rls.force", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" FORCE ROW LEVEL SECURITY" + }, + { + "id": "entity.membership.policy.registry_rls_select_2c193a25886b5ebec5bba2e5", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_select_2c193a25886b5ebec5bba2e5\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_2c193a25886b5ebec5bba2e5\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" IS 'breg/policy/v1/97e2451b6e98fd3dbebea85516fc4ad69ffcacddd4fe013feb4ca0f4afbe6e39'" + }, + { + "id": "entity.membership.policy.registry_rls_insert_edd73113291f3d42ac72c32f", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_insert_edd73113291f3d42ac72c32f\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_insert_edd73113291f3d42ac72c32f\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" IS 'breg/policy/v1/8a1b6e5748d1e2d6fb068e08a6a3bf0d3d2d00be5f52c15c632e11ae6067410c'" + }, + { + "id": "entity.membership.policy.registry_rls_update_f37197225c94dab6ad410cc1", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_update_f37197225c94dab6ad410cc1\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" FOR UPDATE USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active') WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_update_f37197225c94dab6ad410cc1\" ON registry_data.\"breg_e_membership_a36e7273b8ef4eb1\" IS 'breg/policy/v1/82cba119d6cb474654f121cd266efc52f8c8f1d75d40721fc25f8ca0876108ca'" + }, + { + "id": "entity.organization.rls.enable", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" ENABLE ROW LEVEL SECURITY" + }, + { + "id": "entity.organization.rls.force", + "kind": "row_security", + "sql": "ALTER TABLE registry_data.\"breg_e_organization_6ccb51e3b2202a71\" FORCE ROW LEVEL SECURITY" + }, + { + "id": "entity.organization.policy.registry_rls_select_fc68ada80db4374538d917df", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_select_fc68ada80db4374538d917df\" ON registry_data.\"breg_e_organization_6ccb51e3b2202a71\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_fc68ada80db4374538d917df\" ON registry_data.\"breg_e_organization_6ccb51e3b2202a71\" IS 'breg/policy/v1/ab8ebf2e79f6bd405b4c210d480892f7895ccf717411fb87bec5c0fd031a6e53'" + }, + { + "id": "entity.organization.policy.registry_rls_insert_de59d694cebbb215bd3f6b9b", + "kind": "policy", + "sql": "CREATE POLICY \"registry_rls_insert_de59d694cebbb215bd3f6b9b\" ON registry_data.\"breg_e_organization_6ccb51e3b2202a71\" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_insert_de59d694cebbb215bd3f6b9b\" ON registry_data.\"breg_e_organization_6ccb51e3b2202a71\" IS 'breg/policy/v1/62a79ddf5f7342a15d6ac20c38128d9ca52aae7bc7f215733a964bd0f3b7c9be'" + }, + { + "id": "entity.facility.source-view", + "kind": "view", + "sql": "CREATE VIEW registry_source.\"facility\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_facility_organization_c72e96e6196479cc\" AS \"organization\", \"breg_f_facility_label_49700f8f0b0d4a57\" AS \"label\"\n FROM registry_data.\"breg_e_facility_675cdbdae206c49c\"\n WHERE record_lifecycle = 'active'" + }, + { + "id": "entity.membership.source-view", + "kind": "view", + "sql": "CREATE VIEW registry_source.\"membership\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_membership_organization_bfa076d486640343\" AS \"organization\", \"breg_f_membership_principal_dbfb37e169be4783\" AS \"principal\", \"breg_f_membership_active_6e662651da1918d2\" AS \"active\", \"breg_f_membership_private_note_5a8d02ceb53dd0bd\" AS \"private_note\"\n FROM registry_data.\"breg_e_membership_a36e7273b8ef4eb1\"\n WHERE record_lifecycle = 'active'" + }, + { + "id": "entity.organization.source-view", + "kind": "view", + "sql": "CREATE VIEW registry_source.\"organization\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_organization_name_39e5047e3f964468\" AS \"name\"\n FROM registry_data.\"breg_e_organization_6ccb51e3b2202a71\"\n WHERE record_lifecycle = 'active'" + } + ], + "tables": [ + { + "entityId": "facility", + "physicalName": "breg_e_facility_675cdbdae206c49c", + "runtimePrivileges": [ + "select", + "insert", + "update" + ], + "policies": [ + { + "name": "registry_rls_select_b56c984fa34e60b58e32e7d3", + "command": "select", + "accessProfile": "member", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'member' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0 AND registry_context.\"membership_7b967b5ec89a5c63ab8056cd\"(\"breg_f_facility_organization_c72e96e6196479cc\")) AND (record_lifecycle = 'active')" + }, + { + "name": "registry_rls_select_bd688fd36cf3a53a01382a56", + "command": "select", + "accessProfile": "steward", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active')" + }, + { + "name": "registry_rls_insert_77687d5ac1f8badf901ee933", + "command": "insert", + "accessProfile": "steward", + "checkExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'" + }, + { + "name": "registry_rls_update_f6e327e7ea9457483f3eabeb", + "command": "update", + "accessProfile": "steward", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'", + "checkExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'" + } + ] + }, + { + "entityId": "membership", + "physicalName": "breg_e_membership_a36e7273b8ef4eb1", + "runtimePrivileges": [ + "select", + "insert", + "update" + ], + "policies": [ + { + "name": "registry_rls_select_2c193a25886b5ebec5bba2e5", + "command": "select", + "accessProfile": "steward", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active')" + }, + { + "name": "registry_rls_insert_edd73113291f3d42ac72c32f", + "command": "insert", + "accessProfile": "steward", + "checkExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'" + }, + { + "name": "registry_rls_update_f37197225c94dab6ad410cc1", + "command": "update", + "accessProfile": "steward", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'", + "checkExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'" + }, + { + "name": "registry_membership_7b967b5ec89a5c63ab8056cd", + "command": "select", + "accessProfile": "member", + "appliesTo": "runtime", + "usingExpression": "(NULLIF(current_setting('registry.membership_probe', true), '') = 'membership_7b967b5ec89a5c63ab8056cd' AND NULLIF(current_setting('registry.access_profile', true), '') = 'member') AND (\"breg_e_membership_a36e7273b8ef4eb1\".record_lifecycle = 'active' AND \"breg_e_membership_a36e7273b8ef4eb1\".\"breg_f_membership_principal_dbfb37e169be4783\" = NULLIF(current_setting('registry.principal', true), '') AND \"breg_e_membership_a36e7273b8ef4eb1\".\"breg_f_membership_active_6e662651da1918d2\" IS TRUE)" + } + ] + }, + { + "entityId": "organization", + "physicalName": "breg_e_organization_6ccb51e3b2202a71", + "runtimePrivileges": [ + "select", + "insert" + ], + "policies": [ + { + "name": "registry_rls_select_fc68ada80db4374538d917df", + "command": "select", + "accessProfile": "steward", + "usingExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active')" + }, + { + "name": "registry_rls_insert_de59d694cebbb215bd3f6b9b", + "command": "insert", + "accessProfile": "steward", + "checkExpression": "(NULLIF(current_setting('registry.access_profile', true), '') = 'steward' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'" + } + ] + } + ], + "views": [ + { + "id": "entity.facility.source", + "schema": "registry_source", + "name": "facility", + "runtimePrivileges": [ + "select" + ] + }, + { + "id": "entity.membership.source", + "schema": "registry_source", + "name": "membership", + "runtimePrivileges": [ + "select" + ] + }, + { + "id": "entity.organization.source", + "schema": "registry_source", + "name": "organization", + "runtimePrivileges": [ + "select" + ] + } + ], + "functions": [ + { + "id": "registry_context.evaluation_date", + "schema": "registry_context", + "name": "evaluation_date", + "arguments": "", + "runtimeExecute": true + }, + { + "id": "registry_context.membership_7b967b5ec89a5c63ab8056cd", + "schema": "registry_context", + "name": "membership_7b967b5ec89a5c63ab8056cd", + "arguments": "uuid", + "runtimeExecute": true + } + ] +} diff --git a/crates/registry-breg/tests/golden/membership-ddl.sha256 b/crates/registry-breg/tests/golden/membership-ddl.sha256 new file mode 100644 index 0000000000..a8869ac11e --- /dev/null +++ b/crates/registry-breg/tests/golden/membership-ddl.sha256 @@ -0,0 +1 @@ +25af323027e0ab299822ff5886642398997c8b5ad4b4bbee6f377ecbb800c735 diff --git a/crates/registry-breg/tests/golden/membership-revision.txt b/crates/registry-breg/tests/golden/membership-revision.txt new file mode 100644 index 0000000000..e95543f33c --- /dev/null +++ b/crates/registry-breg/tests/golden/membership-revision.txt @@ -0,0 +1 @@ +sha256:e3b01116bfd0a84ff1482f9db8f19befc314af06073cded1666853dba3b26891 diff --git a/crates/registry-breg/tests/golden/membership_refusals.json b/crates/registry-breg/tests/golden/membership_refusals.json new file mode 100644 index 0000000000..818142c647 --- /dev/null +++ b/crates/registry-breg/tests/golden/membership_refusals.json @@ -0,0 +1,336 @@ +{ + "development-availability": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "failedCheck": "membership", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "263", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "development-availability-claim": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "failedCheck": "row-boundary", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "265", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "development-availability-missing": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "failedCheck": "visibility", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "263", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "development-create-claim": { + "body": { + "code": "write.outside-boundary", + "detail": "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.", + "failedCheck": "row-boundary", + "status": 403, + "title": "Forbidden", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" + }, + "headers": { + "cache-control": "no-store", + "content-length": "347", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 403 + }, + "development-create-missing": { + "body": { + "code": "write.outside-boundary", + "detail": "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.", + "failedCheck": "membership", + "status": 403, + "title": "Forbidden", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" + }, + "headers": { + "cache-control": "no-store", + "content-length": "345", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 403 + }, + "development-generic-precondition": { + "body": { + "code": "precondition.failed", + "detail": "The mutation precondition failed.", + "status": 412, + "title": "Precondition Failed", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/precondition/failed" + }, + "headers": { + "cache-control": "no-store", + "content-length": "244", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 412 + }, + "development-observed-precondition": { + "body": { + "code": "precondition.failed", + "detail": "The mutation precondition failed.", + "status": 412, + "title": "Precondition Failed", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/precondition/failed" + }, + "headers": { + "cache-control": "no-store", + "content-length": "244", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "registry-posture": "development", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 412 + }, + "production-availability": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "236", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "production-availability-claim": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "236", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "production-availability-missing": { + "body": { + "code": "resource.not-found", + "detail": "The requested resource was not found.", + "status": 404, + "title": "Not Found", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/resource/not-found" + }, + "headers": { + "cache-control": "no-store", + "content-length": "236", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 404 + }, + "production-create-claim": { + "body": { + "code": "write.outside-boundary", + "detail": "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.", + "status": 403, + "title": "Forbidden", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" + }, + "headers": { + "cache-control": "no-store", + "content-length": "318", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 403 + }, + "production-create-missing": { + "body": { + "code": "write.outside-boundary", + "detail": "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.", + "status": 403, + "title": "Forbidden", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" + }, + "headers": { + "cache-control": "no-store", + "content-length": "318", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 403 + }, + "production-generic-precondition": { + "body": { + "code": "precondition.failed", + "detail": "The mutation precondition failed.", + "status": 412, + "title": "Precondition Failed", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/precondition/failed" + }, + "headers": { + "cache-control": "no-store", + "content-length": "244", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 412 + }, + "production-observed-precondition": { + "body": { + "code": "precondition.failed", + "detail": "The mutation precondition failed.", + "status": 412, + "title": "Precondition Failed", + "traceId": "00000000000000000000000000000000", + "type": "https://id.registrystack.org/problems/registry-breg/precondition/failed" + }, + "headers": { + "cache-control": "no-store", + "content-length": "244", + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'", + "content-type": "application/problem+json", + "cross-origin-opener-policy": "same-origin", + "permissions-policy": "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=63072000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-frame-options": "DENY" + }, + "status": 412 + } +} diff --git a/crates/registry-breg/tests/golden/metrics-scrape-sampled.txt b/crates/registry-breg/tests/golden/metrics-scrape-sampled.txt index b5ffbf23b0..c9173c9b19 100644 --- a/crates/registry-breg/tests/golden/metrics-scrape-sampled.txt +++ b/crates/registry-breg/tests/golden/metrics-scrape-sampled.txt @@ -180,6 +180,7 @@ breg_request_refusals_total{check="task-grant-scope"} 0 breg_request_refusals_total{check="task-grant-lifetime"} 0 breg_request_refusals_total{check="task-grant-status"} 0 breg_request_refusals_total{check="row-boundary"} 0 +breg_request_refusals_total{check="membership"} 0 breg_request_refusals_total{check="ownership"} 0 breg_request_refusals_total{check="visibility"} 0 breg_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-breg/tests/golden/metrics-scrape-unsampled.txt b/crates/registry-breg/tests/golden/metrics-scrape-unsampled.txt index f469ffcaa8..52863c3ce5 100644 --- a/crates/registry-breg/tests/golden/metrics-scrape-unsampled.txt +++ b/crates/registry-breg/tests/golden/metrics-scrape-unsampled.txt @@ -151,6 +151,7 @@ breg_request_refusals_total{check="task-grant-scope"} 0 breg_request_refusals_total{check="task-grant-lifetime"} 0 breg_request_refusals_total{check="task-grant-status"} 0 breg_request_refusals_total{check="row-boundary"} 0 +breg_request_refusals_total{check="membership"} 0 breg_request_refusals_total{check="ownership"} 0 breg_request_refusals_total{check="visibility"} 0 breg_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-breg/tests/http_auth.rs b/crates/registry-breg/tests/http_auth.rs index ea35c82ec7..76f5cbe083 100644 --- a/crates/registry-breg/tests/http_auth.rs +++ b/crates/registry-breg/tests/http_auth.rs @@ -3569,7 +3569,7 @@ async fn action_and_proposal_only_clients_are_checked_at_construction() { "proposals": [{ "action": "register-child", "operations": ["edit"], - "ownership": "caller", + "party": "owner", "targets": [ {"recordType": "parent", "rowBoundaries": "unrestricted"}, {"recordType": "child", "rowBoundaries": "unrestricted"} diff --git a/crates/registry-breg/tests/http_read_only.rs b/crates/registry-breg/tests/http_read_only.rs index 3121a4e34f..dcca4631c5 100644 --- a/crates/registry-breg/tests/http_read_only.rs +++ b/crates/registry-breg/tests/http_read_only.rs @@ -4108,7 +4108,16 @@ async fn runtime_openapi_contract_is_filtered_to_the_selected_acceptance_profile .send( Method::GET, "/openapi.json?accessProfile=site-planner", - Some(registry_principal_claims("site-planning")), + Some( + VerifiedRequestClaims::authenticated( + "registry_principal", + "registry-principal", + BTreeSet::from(["asset:plan".into()]), + Some("site-planning".into()), + BTreeMap::new(), + ) + .unwrap(), + ), ) .await, ) diff --git a/crates/registry-breg/tests/immediate_action_compiler.rs b/crates/registry-breg/tests/immediate_action_compiler.rs index 83b2a00891..e6f38b2160 100644 --- a/crates/registry-breg/tests/immediate_action_compiler.rs +++ b/crates/registry-breg/tests/immediate_action_compiler.rs @@ -559,7 +559,7 @@ fn create_effects_may_rely_entirely_on_server_generated_fields() { "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "register", "operations": [operation], @@ -721,7 +721,7 @@ fn action_effect_graph_rejects_invalid_sources_cycles_and_overlaps() { "set":{"label":{"fromInput":"label"},"alpha":{"fromEffect":"alpha"}} }]} }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{ "action":"make-cycle", "operations":["invoke"], "targets":[{"recordType":"alpha","rowBoundaries":"unrestricted"},{"recordType":"beta","rowBoundaries":"unrestricted"}] @@ -749,7 +749,7 @@ fn action_inputs_resolve_project_vocabulary_values_for_type_compatibility() { "inputs":[{"id":"kind","type":"vocabulary-code","vocabulary":"asset-type","required":true,"classification":"internal"}], "plan":{"type":"fixed","effects":[{"id":"asset","target":{"recordType":"asset"},"operation":"create","set":{"kind":{"fromInput":"kind"}}}]} }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{ "action":"create-asset", "operations":["invoke"], "targets":[{"recordType":"asset","rowBoundaries":"unrestricted"}], @@ -780,7 +780,7 @@ fn action_inputs_reject_unknown_project_vocabulary_references() { "inputs":[{"id":"kind","type":"vocabulary-code","vocabulary":"asset-type","required":true,"classification":"internal"}], "plan":{"type":"fixed","effects":[{"id":"asset","target":{"recordType":"asset"},"operation":"create","set":{"kind":{"fromInput":"kind"}}}]} }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{ "action":"create-asset", "operations":["invoke"], "targets":[{"recordType":"asset","rowBoundaries":"unrestricted"}] @@ -821,7 +821,7 @@ fn action_bounds_apply_before_runtime_target_work() { "recordTypes":{{"record":{{"primaryDataset":"test-dataset","route":"records","mutationMode":"mutable", "fields":[{{"id":"label","type":"string","maximumLength":32,"classification":"internal"}}]}}}}, "actions":{{"bulk-fix":{{"execution":{{"mode":"immediate"}},"inputs":[{}],"plan":{{"type":"fixed","effects":[{}]}}}}}}, - "accessProfiles":{{"operator":{{"default":true,"principalClaim":"principal","requiredScopes":"unrestricted", + "accessProfiles":{{"operator":{{"default":true,"principalClaim":"principal","requiredScopes":["records:write"], "permissions":{{"actions":[{{"action":"bulk-fix","operations":["invoke"],"targets":[{}]}}]}}}}}} }}"#, inputs.join(","), @@ -882,7 +882,7 @@ fn action_field_and_snapshot_ceilings_refuse_otherwise_valid_plans() { "operation": "create", "set": Value::Object(assignments) }]} }}, - "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", "requiredScopes": "unrestricted", + "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "create-bounded-record", "operations": ["invoke"], "targets": [{"recordType": "bounded-record", "rowBoundaries": "unrestricted"}] @@ -981,7 +981,7 @@ fn generated_create_fields_count_toward_the_proposal_snapshot_ceiling() { "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["proposals:write"], "permissions": {"actions": [{ "action": "create-bounded-record", "operations": ["start"], diff --git a/crates/registry-breg/tests/immediate_action_handler.rs b/crates/registry-breg/tests/immediate_action_handler.rs index fc4ab532ab..62eebae0d0 100644 --- a/crates/registry-breg/tests/immediate_action_handler.rs +++ b/crates/registry-breg/tests/immediate_action_handler.rs @@ -30,7 +30,7 @@ fn project() -> Value { {"id":"friend","target":{"recordType":"person"},"operation":"create","fields":["name","friend"]}, {"id":"existing","target":{"fromInput":"person"},"operation":"patch","fields":["name","friend"]} ],"refusals":[{"code":"blank-name","label":"A name is required."}]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} + "accessProfiles":{"registrar": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{"action":"register-person","operations":["invoke"],"targets":[{"recordType":"person","rowBoundaries":"unrestricted"}],"results":["person","friend","existing"]}]}}} }) } fn compile(source: Value, script: &str) -> Result { diff --git a/crates/registry-breg/tests/import_grant_admission.rs b/crates/registry-breg/tests/import_grant_admission.rs index 3d084db14d..998271273a 100644 --- a/crates/registry-breg/tests/import_grant_admission.rs +++ b/crates/registry-breg/tests/import_grant_admission.rs @@ -28,7 +28,7 @@ fn project(loader_operations: &[&str]) -> Value { "mutationPolicy":{"patch":"proposal-required"}, "fields":[{"id":"label","type":"string","maximumLength":32,"required":true,"classification":"internal"}] }}, - "accessProfiles":{"loader": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted", + "accessProfiles":{"loader": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"enrollment","operations":loader_operations,"readableFields":["label"],"writableFields":["label"], "rowBoundaries":"unrestricted" diff --git a/crates/registry-breg/tests/issuer_portability.rs b/crates/registry-breg/tests/issuer_portability.rs index d02f95344d..91e73c4358 100644 --- a/crates/registry-breg/tests/issuer_portability.rs +++ b/crates/registry-breg/tests/issuer_portability.rs @@ -325,7 +325,7 @@ async fn stock_to_keycloak_preserves_native_proposal_issuer_isolation() { "permissions":{"records":[{"recordType":"record","operations":["create","get"],"readableFields":["label","district"],"writableFields":["label","district"], "rowBoundaries":[{"field":"district","claim":"districts","operator":"equals"}]}], "actions":[{"action":"correct-label","operations":["start"],"targets":[{"recordType":"record","rowBoundaries":[{"field":"district","claim":"districts","operator":"equals"}]}]}], - "proposals":[{"action":"correct-label","operations":["get","submit","apply"],"ownership":"caller","targets":[{"recordType":"record","rowBoundaries":[{"field":"district","claim":"districts","operator":"equals"}]}]}]}}}}); + "proposals":[{"action":"correct-label","operations":["get","submit","apply"],"party":"owner","targets":[{"recordType":"record","rowBoundaries":[{"field":"district","claim":"districts","operator":"equals"}]}]}]}}}}); let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); let stock = authenticator(®istry, root, &journey.stock, &journey.audience); diff --git a/crates/registry-breg/tests/membership_access.rs b/crates/registry-breg/tests/membership_access.rs index d2b0213e1a..787f1ac464 100644 --- a/crates/registry-breg/tests/membership_access.rs +++ b/crates/registry-breg/tests/membership_access.rs @@ -55,37 +55,37 @@ fn membership_reference_uses_one_positioned_spelling() { let decoded = registry_breg::contract::read_project_yaml("registry.yaml", &bytes).unwrap(); let wire = serde_json::to_value(&decoded.value).unwrap(); assert_eq!( - wire.pointer( - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/membershipRecordType" - ), + wire.pointer("/accessProfiles/member/permissions/records/0/rowBoundaries/0/membership"), Some(&json!("membership")) ); - for value in [json!("membership"), json!(""), serde_json::Value::Null] { - let mut previous = source.clone(); - let boundary = previous - .pointer_mut("/accessProfiles/member/permissions/records/0/membershipBoundaries/0") - .unwrap() - .as_object_mut() - .unwrap(); - boundary.remove("membershipRecordType"); - boundary.insert("membershipEntity".to_owned(), value); - let report = registry_breg::contract::read_project_yaml( - "registry.yaml", - &serde_json::to_vec_pretty(&previous).unwrap(), - ) - .expect_err("previous reference is refused"); - let diagnostic = report - .diagnostics() - .iter() - .find(|diagnostic| diagnostic.code == "config.removed-key") - .expect("migration guidance is present"); - assert_eq!( - diagnostic.path, - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/membershipEntity" - ); - assert!(diagnostic.suggested_action.contains("membershipRecordType")); - assert!(diagnostic.source.as_ref().unwrap().line.is_some()); - } +} + +#[test] +fn membership_boundaries_is_refused_with_its_replacement_named() { + let mut source = source("facility"); + source["accessProfiles"]["member"]["permissions"]["records"][0]["membershipBoundaries"] = + json!([]); + let report = registry_breg::contract::read_project_yaml( + "registry.yaml", + &serde_json::to_vec_pretty(&source).unwrap(), + ) + .expect_err("removed member is refused"); + let diagnostic = report + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == "config.removed-key") + .unwrap(); + assert_eq!( + diagnostic.path, + "/accessProfiles/member/permissions/records/0/membershipBoundaries" + ); + assert!(diagnostic + .suggested_action + .contains("membership: {key, principal, active}")); + assert!(diagnostic + .suggested_action + .contains("rowBoundaries entry {field, membership}")); + assert!(diagnostic.source.as_ref().unwrap().line.is_some()); } #[test] @@ -93,8 +93,8 @@ fn membership_boundaries_refuse_unenforced_authority_paths() { for (path, value, code) in [ ( "/accessProfiles/member/permissions/records/0/operations", - json!(["get", "patch"]), - "breg.access.membership-read-only", + json!(["get", "import"]), + "breg.access.membership-import-unsupported", ), ( "/accessProfiles/member/requiredScopes", @@ -102,23 +102,23 @@ fn membership_boundaries_refuse_unenforced_authority_paths() { "breg.access.requirements-scope-missing", ), ( - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/field", + "/accessProfiles/member/permissions/records/0/rowBoundaries/0/field", json!("label"), "breg.access.membership-key-type", ), ( - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/principalField", + "/recordTypes/membership/membership/principal", json!("active"), "breg.access.membership-principal-type", ), ( - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/activeField", + "/recordTypes/membership/membership/active", json!("principal"), "breg.access.membership-active-type", ), ( - "/accessProfiles/member/permissions/records/0/membershipBoundaries/0/membershipRecordType", - json!("facility"), + "/accessProfiles/member/permissions/records/0/recordType", + json!("membership"), "breg.access.membership-source-recursive", ), ( @@ -156,7 +156,7 @@ fn membership_boundaries_refuse_unenforced_authority_paths() { let mut action = action_requirements::project(); action["accessProfiles"]["registrar"]["permissions"]["actions"][0]["membershipBoundaries"] = source("facility")["accessProfiles"]["member"]["permissions"]["records"][0] - ["membershipBoundaries"] + ["rowBoundaries"] .clone(); let failure = registry_breg::parse_project_yaml(&serde_json::to_vec(&action).unwrap()) .expect_err("an action grant must not silently ignore entity membership rules"); @@ -173,3 +173,76 @@ fn membership_boundaries_refuse_unenforced_authority_paths() { )] ); } + +#[test] +fn module_membership_boundaries_is_refused_with_its_replacement_named() { + for collection in ["recordTypes", "extendRecordTypes"] { + let module = json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1", + "kind":"BRegModule","id":"membership-core","version":"1", + collection: {"facility":{"accessProfiles":{"member":{"membershipBoundaries":[]}}}} + }); + let bytes = serde_json::to_vec_pretty(&module).unwrap(); + let report = registry_breg::contract::read_module_yaml("module.yaml", &bytes).unwrap_err(); + let code = report + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == "config.removed-key") + .unwrap(); + assert_eq!( + code.path, + format!("/{collection}/facility/accessProfiles/member/membershipBoundaries") + ); + assert!(code + .suggested_action + .contains("membership: {key, principal, active}")); + assert!(code + .suggested_action + .contains("rowBoundaries entry {field, membership}")); + } +} + +#[test] +fn a_project_record_profile_refuses_membership_boundaries_with_its_replacement_named() { + let mut source = source("facility"); + source["recordTypes"]["facility"]["accessProfiles"] = + json!({"member":{"membershipBoundaries":[]}}); + let report = registry_breg::contract::read_project_yaml( + "registry.yaml", + &serde_json::to_vec_pretty(&source).unwrap(), + ) + .unwrap_err(); + let diagnostic = report + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == "config.removed-key") + .unwrap(); + assert_eq!( + diagnostic.path, + "/recordTypes/facility/accessProfiles/member/membershipBoundaries" + ); + assert!(diagnostic + .suggested_action + .contains("membership: {key, principal, active}")); + assert!(diagnostic + .suggested_action + .contains("rowBoundaries entry {field, membership}")); +} + +#[test] +fn an_extension_cannot_declare_membership() { + let module = json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1", + "kind":"BRegModule","id":"membership-core","version":"1", + "extendRecordTypes":{"facility":{"membership":{"key":"organization","principal":"principal","active":"active"}}} + }); + let report = registry_breg::contract::read_module_yaml( + "module.yaml", + &serde_json::to_vec_pretty(&module).unwrap(), + ) + .unwrap_err(); + assert!(report.diagnostics().iter().any(|diagnostic| { + diagnostic.code == "config.unknown-key" + && diagnostic.path == "/extendRecordTypes/facility/membership" + })); +} diff --git a/crates/registry-breg/tests/membership_authoring.rs b/crates/registry-breg/tests/membership_authoring.rs new file mode 100644 index 0000000000..37f0b8a3eb --- /dev/null +++ b/crates/registry-breg/tests/membership_authoring.rs @@ -0,0 +1,619 @@ +// SPDX-License-Identifier: Apache-2.0 + +use registry_breg::compiler::{compile_project, CompileProfile}; +use registry_breg::diagnostics::CompileFailure; +use registry_breg::{parse_project_yaml, CompiledRegistry}; +use serde_json::{json, Value}; + +const PROJECT: &[u8] = + include_bytes!("../../../products/breg/fixtures/organization-membership-access/registry.yaml"); +const ROWS: &str = "/accessProfiles/member/permissions/records/0/rowBoundaries"; +const DECLARATION: &str = "/recordTypes/membership/membership"; + +fn project() -> Value { + serde_json::from_slice(PROJECT).unwrap() +} + +fn compile(project: &Value) -> Result { + let source = parse_project_yaml(&serde_json::to_vec_pretty(project).unwrap())?; + compile_project(&source, &[], CompileProfile::Authoring) +} + +fn compile_production(project: &Value) -> Result { + let mut project = project.clone(); + project["package"] = json!({"sourceRevision":"membership-authoring-test"}); + let source = parse_project_yaml(&serde_json::to_vec_pretty(&project).unwrap())?; + compile_project(&source, &[], CompileProfile::Production) +} + +fn assert_production_refusal(project: &Value, code: &str, path: &str) { + let failure = compile_production(project).expect_err("Production refuses this grant"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code && diagnostic.path == path), + "wanted {code} at {path}: {failure:?}" + ); +} + +fn assert_refusal(project: &Value, code: &str, path: &str) { + let failure = compile(project).expect_err("project must be refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code && diagnostic.path == path), + "wanted {code} at {path}: {failure:?}" + ); +} + +#[test] +fn a_membership_declaration_compiles_into_the_record_type() { + let project = project(); + let registry = compile(&project).unwrap(); + let entity = serde_json::to_value(®istry.entities()["membership"]).unwrap(); + assert_eq!(entity["membership"], *project.pointer(DECLARATION).unwrap()); +} + +#[test] +fn a_membership_declaration_naming_a_missing_field_is_refused_without_panicking() { + for (field, code) in [ + ("key", "breg.access.membership-key-type"), + ("principal", "breg.access.membership-principal-type"), + ("active", "breg.access.membership-active-type"), + ] { + let mut project = project(); + project.pointer_mut(DECLARATION).unwrap()[field] = json!("missing"); + assert_refusal(&project, code, "recordTypes[id=membership].membership"); + } +} + +#[test] +fn a_record_grant_with_a_membership_entry_compiles_like_the_base_membership_boundary() { + let registry = compile(&project()).unwrap(); + let entry = ®istry.entities()["facility"].membership_boundaries["member"][0]; + assert_eq!(entry.field, "organization"); + assert_eq!(entry.membership_entity, "membership"); + let source = ®istry.entities()["membership"]; + assert_eq!(entry.membership_table, source.physical_table); + assert_eq!( + entry.membership_key_column, + source.fields["organization"].physical_name + ); + assert_eq!( + entry.principal_column, + source.fields["principal"].physical_name + ); + assert_eq!(entry.active_column, source.fields["active"].physical_name); +} + +#[test] +fn claim_and_membership_entries_share_one_row_boundaries_list() { + let mut project = project(); + project + .pointer_mut(ROWS) + .unwrap() + .as_array_mut() + .unwrap() + .push(json!({"field": "label", "claim": "facility-label", "operator": "equals"})); + let registry = compile(&project).unwrap(); + let entity = ®istry.entities()["facility"]; + assert_eq!(entity.access_profiles["member"].row_boundaries.len(), 1); + assert_eq!(entity.membership_boundaries["member"].len(), 1); +} + +#[test] +fn a_membership_only_grant_never_serializes_as_unrestricted() { + let project = project(); + let source = parse_project_yaml(&serde_json::to_vec_pretty(&project).unwrap()).unwrap(); + let serialized = serde_json::to_value(source).unwrap(); + assert_eq!(serialized.pointer(ROWS), project.pointer(ROWS)); +} + +#[test] +fn a_row_boundary_set_with_a_membership_entry_expands_like_the_inline_form() { + let inline = project(); + let mut named = inline.clone(); + named["rowBoundarySets"] = json!({"facility-membership": inline.pointer(ROWS).unwrap()}); + *named.pointer_mut(ROWS).unwrap() = json!({"rowBoundarySet": "facility-membership"}); + let inline = compile(&inline).unwrap(); + let named = compile(&named).unwrap(); + assert_eq!(named.access(), inline.access()); + assert_eq!(named.ddl(), inline.ddl()); +} + +fn shape_is_refused(entry: Value) { + let mut project = project(); + *project.pointer_mut(ROWS).unwrap() = json!([entry]); + let failure = compile(&project).expect_err("invalid boundary shape is refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| { + diagnostic.message.contains("claim entry") + && diagnostic.message.contains("membership entry") + }), + "{failure:?}" + ); +} + +#[test] +fn an_entry_with_both_claim_and_membership_is_refused() { + shape_is_refused( + json!({"field": "organization", "claim": "sub", "operator": "equals", "membership": "membership"}), + ); +} + +#[test] +fn an_entry_with_neither_is_refused() { + shape_is_refused(json!({"field": "organization"})); +} + +#[test] +fn a_membership_entry_naming_a_type_without_membership_is_refused() { + let mut project = project(); + project.pointer_mut(ROWS).unwrap()[0]["membership"] = json!("organization"); + assert_refusal(&project, "breg.access.membership-entity-unknown", + "recordTypes[id=facility].accessProfiles[id=member].rowBoundaries[membership=organization:field=organization]"); +} + +#[test] +fn a_membership_entry_in_access_requirements_is_refused() { + for use_set in [false, true] { + let mut project = project(); + let entries = json!([{"field":"organization","membership":"membership"}]); + let rows = if use_set { + project["rowBoundarySets"] = json!({"member": entries}); + json!({"rowBoundarySet":"member"}) + } else { + entries + }; + project["recordTypes"]["facility"]["accessRequirements"] = json!({"rowBoundaries": rows}); + let failure = compile(&project).expect_err("requirements accept claim entries only"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code + == "breg.access.membership-access-requirement-unsupported"), + "{failure:?}" + ); + } +} + +const MEMBER_ROW: &str = "recordTypes[id=facility].accessProfiles[id=member].rowBoundaries"; + +#[test] +fn import_grants_refuse_membership_entries() { + let mut project = project(); + project["accessProfiles"]["member"]["permissions"]["records"][0]["operations"] = + json!(["import"]); + assert_production_refusal( + &project, + "breg.access.membership-import-unsupported", + MEMBER_ROW, + ); +} + +#[test] +fn open_record_writes_require_a_principal_boundary() { + let mut project = project(); + project["accessProfiles"]["steward"]["requiredScopes"] = json!("unrestricted"); + assert_refusal( + &project, + "breg.access.open-write-without-principal-boundary", + "recordTypes[id=facility].accessProfiles[id=steward].rowBoundaries", + ); +} + +#[test] +fn a_scopeless_profile_with_requester_clients_cannot_write_membership_records() { + let mut project = project(); + project["accessProfiles"]["steward"]["requiredScopes"] = json!("unrestricted"); + project["accessProfiles"]["steward"]["requesterClients"] = json!(["bounded-client"]); + assert_refusal( + &project, + "breg.access.scopeless-membership-source-write", + "recordTypes[id=membership].accessProfiles[id=steward].rowBoundaries", + ); +} + +#[test] +fn open_profiles_with_membership_must_use_sub() { + let mut project = project(); + project["accessProfiles"]["member"]["requiredScopes"] = json!("unrestricted"); + assert_refusal( + &project, + "breg.access.open-membership-principal-not-sub", + MEMBER_ROW, + ); +} + +#[test] +fn production_admits_and_documents_member_bounded_open_writes() { + let mut project = project(); + project["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + let member = &mut project["accessProfiles"]["member"]; + member["requiredScopes"] = json!("unrestricted"); + member["principalClaim"] = json!("sub"); + member["permissions"]["records"][0]["operations"] = json!([ + "get", + "list", + "lookup", + "create", + "patch", + "tombstone", + "batch" + ]); + member["permissions"]["records"][0]["writableFields"] = json!(["organization", "label"]); + project["recordTypes"]["facility"]["tombstone"] = json!(true); + project["recordTypes"]["facility"]["batch"] = json!({"maximumItems":4,"maximumBytes":8192}); + let registry = compile_production(&project).expect("Production admits the bounded writes"); + assert_eq!( + registry.entities()["facility"].membership_boundaries["member"].len(), + 1 + ); + let api: Value = + serde_json::from_slice(®istry.artifacts().entries()["generated/openapi.json"].bytes) + .unwrap(); + for (record_path, method) in [ + ("/v1/records/facilities", "post"), + ("/v1/records/facilities/{record_id}", "patch"), + ("/v1/records/facilities:batch", "post"), + ] { + assert_eq!( + api["paths"][record_path][method]["responses"]["403"]["content"] + ["application/problem+json"]["examples"]["write.outside-boundary"]["value"]["code"], + "write.outside-boundary", + "{method} {record_path}" + ); + } +} + +#[test] +fn membership_entries_are_limited_and_unique_after_set_expansion() { + let mut project = project(); + let entry = project.pointer(ROWS).unwrap()[0].clone(); + project["rowBoundarySets"] = json!({"many": vec![entry; 9]}); + *project.pointer_mut(ROWS).unwrap() = json!({"rowBoundarySet":"many"}); + assert_refusal(&project, "breg.access.membership-limit", MEMBER_ROW); + assert_refusal(&project, "breg.access.membership-duplicate", + "recordTypes[id=facility].accessProfiles[id=member].rowBoundaries[membership=membership:field=organization]"); +} + +#[path = "support/action_requirements.rs"] +mod action_requirements; +#[allow(dead_code)] +#[path = "support/proposal_hooks_model.rs"] +mod proposal_hooks_model; + +fn action_project() -> Value { + let mut project = action_requirements::project(); + let records = project["recordTypes"].as_object_mut().unwrap(); + let membership = self::project()["recordTypes"]["membership"].clone(); + let mut membership = membership; + membership["primaryDataset"] = json!("test-dataset"); + membership["fields"][0]["target"] = json!("parent"); + membership + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + records.insert("membership".into(), membership); + project +} + +#[test] +fn production_admits_a_membership_bound_immediate_action_target() { + let mut project = action_project(); + project["accessProfiles"]["registrar"]["permissions"]["actions"][0]["targets"][1] + ["rowBoundaries"] = json!([{"field":"parent","membership":"membership"}]); + project["recordTypes"]["child"]["hooks"][0]["handler"] = + json!({"type":"url","destinationId":"record-events"}); + let registry = compile_production(&project).expect("Production admits the bounded Invoke"); + assert!(registry.actions().actions[0].permissions[0] + .targets + .iter() + .any(|target| target.entity_id == "child" && target.membership_boundaries.len() == 1)); +} + +#[test] +fn a_hook_cannot_use_an_action_grant_with_membership() { + let mut project = action_project(); + project["recordTypes"]["child"]["hooks"][0]["principal"] = json!("registrar"); + project["accessProfiles"]["registrar"]["permissions"]["actions"][0]["targets"][1] + ["rowBoundaries"] = json!([{"field":"parent","membership":"membership"}]); + assert_refusal(&project, "breg.access.membership-hook-unsupported", + "accessProfiles[id=registrar].permissions.actions[action=register-child].targets[recordType=child].rowBoundaries"); +} + +#[test] +fn a_timer_cannot_use_an_action_grant_with_membership() { + let mut project = action_project(); + project["recordTypes"]["child"]["timers"] = json!([{ + "id":"invoke","at":"label","invoke":"register-child","input":{} + }]); + project["accessProfiles"]["registrar"]["permissions"]["actions"][0]["targets"][1] + ["rowBoundaries"] = json!([{"field":"parent","membership":"membership"}]); + assert_refusal(&project, "breg.access.membership-timer-unsupported", + "accessProfiles[id=registrar].permissions.actions[action=register-child].targets[recordType=child].rowBoundaries"); +} + +#[test] +fn production_admits_membership_on_proposal_start_and_lifecycle_targets() { + let mut project = proposal_hooks_model::source(json!([])); + let fixture = self::project(); + for id in ["membership", "organization"] { + project["recordTypes"][id] = fixture["recordTypes"][id].clone(); + project["recordTypes"][id]["primaryDataset"] = json!("directory"); + } + project["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + project["recordTypes"]["target"]["fields"].as_array_mut().unwrap().push( + json!({"id":"organization","type":"reference","target":"organization","classification":"internal"}), + ); + for permission in ["actions", "proposals"] { + let mut candidate = project.clone(); + candidate["accessProfiles"]["clerk"]["permissions"][permission][0]["targets"][0] + ["rowBoundaries"] = json!([{"field":"organization","membership":"membership"}]); + let registry = + compile_production(&candidate).expect("Production admits the Proposal target"); + let action = ®istry.actions().actions[0]; + if permission == "actions" { + assert!(action.permissions[0] + .targets + .iter() + .all(|target| target.membership_boundaries.len() == 1)); + } else { + let registry_breg::model::CompiledActionExecution::Proposal { proposal } = + &action.execution + else { + panic!("expected a Proposal"); + }; + assert_eq!( + proposal.permissions[0].targets[0] + .membership_boundaries + .len(), + 1 + ); + } + } + // A source bounded by itself stays refused; one level over a different + // leaf is admitted (see steward_authoring.rs). + project["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["targets"][0] + ["rowBoundaries"] = json!([{"field":"organization","membership":"target"}]); + let target = &mut project["recordTypes"]["target"]; + target["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"active","type":"boolean","classification":"internal"})); + target["membership"] = json!({"key":"organization","principal":"name","active":"active"}); + assert_refusal( + &project, + "breg.access.membership-source-recursive", + "recordTypes[id=target].membership", + ); +} + +#[test] +fn an_encrypted_membership_principal_is_refused_at_its_declaration() { + let mut project = project(); + project["recordTypes"]["membership"]["fields"][1]["encrypted"] = json!(true); + assert_refusal( + &project, + "breg.access.membership-principal-encrypted", + "recordTypes[id=membership].membership", + ); +} + +#[test] +fn a_membership_source_with_an_incoming_read_path_is_refused_at_its_declaration() { + let mut project = project(); + project["recordTypes"]["organization"]["readPaths"] = + json!([{"id":"links","through":"membership","to":"facility","route":"links"}]); + assert_refusal( + &project, + "breg.access.membership-source-recursive", + "recordTypes[id=membership].membership", + ); +} + +#[test] +fn a_membership_source_with_a_row_requirement_is_refused_at_its_declaration() { + let mut project = project(); + project["recordTypes"]["membership"]["accessRequirements"]["rowBoundaries"] = + json!([{"field":"principal","claim":"sub","operator":"equals"}]); + assert_refusal( + &project, + "breg.access.membership-source-row-requirement", + "recordTypes[id=membership].membership", + ); +} + +#[test] +fn membership_entries_are_incompatible_with_spatial_queries() { + let mut project = project(); + project["accessProfiles"]["member"]["permissions"]["records"][0]["spatialQueries"] = + json!({"bbox": {"maximumLongitudeSpanDegrees": 5, "maximumLatitudeSpanDegrees": 5}}); + assert_refusal( + &project, + "breg.access.membership-spatial-unsupported", + MEMBER_ROW, + ); +} + +#[test] +fn a_module_defines_membership_and_its_profile_round_trips() { + use registry_breg::compiler::module_digest; + use registry_breg::contract::parse_module_yaml; + + let mut project = project(); + let grant = project["accessProfiles"]["member"]["permissions"]["records"][0].clone(); + let mut profile = grant.as_object().unwrap().clone(); + profile.remove("recordType"); + profile.insert( + "requiredScopes".into(), + json!(["records:read", "membership:use"]), + ); + profile.insert("principalClaim".into(), json!("principal")); + profile.insert("default".into(), json!(true)); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("member"); + let records = project["recordTypes"].as_object_mut().unwrap(); + let mut facility = records.remove("facility").unwrap(); + facility["accessProfiles"] = json!({"member":profile}); + let module = json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule", + "id":"membership-core","version":"1", + "recordTypes":{"facility":facility,"membership":records.remove("membership").unwrap()} + }); + let module = parse_module_yaml(&serde_json::to_vec(&module).unwrap()).unwrap(); + let serialized = serde_json::to_value(&module).unwrap(); + assert_eq!( + serialized.pointer("/recordTypes/facility/accessProfiles/member/rowBoundaries"), + grant.get("rowBoundaries") + ); + project["modules"] = json!({"membership-core":{"version":"1","digest":module_digest(&module)}}); + let project = parse_project_yaml(&serde_json::to_vec(&project).unwrap()).unwrap(); + let registry = compile_project(&project, &[module], CompileProfile::Authoring).unwrap(); + assert_eq!( + registry.entities()["facility"].membership_boundaries["member"].len(), + 1 + ); + assert!(registry.entities()["membership"].membership.is_some()); +} + +#[test] +fn an_open_membership_target_requires_sub_even_for_immediate_invoke() { + let mut project = action_project(); + let profile = &mut project["accessProfiles"]["registrar"]; + profile["requiredScopes"] = json!("unrestricted"); + profile["principalClaim"] = json!("email"); + profile["permissions"]["actions"][0]["targets"][1]["rowBoundaries"] = + json!([{"field":"parent","membership":"membership"}]); + let failure = compile(&project).unwrap_err(); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == "breg.access.open-membership-principal-not-sub"), + "{failure:?}" + ); + assert!( + failure + .diagnostics() + .iter() + .all(|diagnostic| diagnostic.code != "breg.access.membership-read-only"), + "{failure:?}" + ); +} + +#[test] +fn membership_ids_are_checked_without_repeating_invalid_values() { + let canary = "CANARY SECRET VALUE"; + for path in [ + "/recordTypes/membership/membership/key", + "/recordTypes/membership/membership/principal", + "/recordTypes/membership/membership/active", + "/accessProfiles/member/permissions/records/0/rowBoundaries/0/membership", + "/accessProfiles/member/permissions/records/0/rowBoundaries/0/field", + ] { + let mut project = project(); + *project.pointer_mut(path).unwrap() = json!(canary); + let report = registry_breg::contract::read_project_yaml( + "registry.yaml", + &serde_json::to_vec(&project).unwrap(), + ) + .unwrap_err(); + assert!(!format!("{report:?}").contains(canary)); + } +} + +#[test] +fn membership_requirements_do_not_hide_removed_keys() { + let mut project = project(); + project["recordTypes"]["facility"]["accessRequirements"] = + json!({"rowBoundaries":[{"field":"organization","membership":"membership"}]}); + project["accessProfiles"]["member"]["permissions"]["records"][0]["membershipBoundaries"] = + json!([]); + let report = registry_breg::contract::read_project_yaml( + "registry.yaml", + &serde_json::to_vec(&project).unwrap(), + ) + .unwrap_err(); + for code in [ + "breg.access.membership-access-requirement-unsupported", + "config.removed-key", + ] { + assert!( + report + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code), + "{report:?}" + ); + } +} + +#[test] +fn a_membership_source_cannot_bound_its_own_action_target() { + let mut project = action_project(); + let child = &mut project["recordTypes"]["child"]; + child["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"active", "type":"boolean", "classification":"internal"})); + child["membership"] = json!({"key":"parent","principal":"label","active":"active"}); + project["accessProfiles"]["registrar"]["permissions"]["actions"][0]["targets"][1] + ["rowBoundaries"] = json!([{"field":"parent","membership":"child"}]); + assert_refusal( + &project, + "breg.access.membership-source-recursive", + "recordTypes[id=child].membership", + ); +} + +#[test] +fn answer_and_cancel_are_proposal_writes_for_admission() { + for operation in ["answer", "cancel"] { + let mut project = proposal_hooks_model::source(json!([])); + project["recordTypes"]["organization"] = + self::project()["recordTypes"]["organization"].clone(); + project["recordTypes"]["organization"]["primaryDataset"] = json!("directory"); + let target = &mut project["recordTypes"]["target"]; + target["fields"].as_array_mut().unwrap().extend([ + json!({"id":"organization","type":"reference","target":"organization","classification":"internal"}), + json!({"id":"active","type":"boolean","classification":"internal"}), + ]); + target["membership"] = json!({"key":"organization","principal":"name","active":"active"}); + project["accessProfiles"]["clerk"]["requiredScopes"] = json!("unrestricted"); + project["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["operations"] = + json!(["get", operation]); + let location = "accessProfiles[id=clerk].permissions.proposals[action=correct-name].targets[recordType=target].rowBoundaries"; + assert_refusal( + &project, + "breg.access.open-write-without-principal-boundary", + location, + ); + assert_refusal( + &project, + "breg.access.scopeless-membership-source-write", + location, + ); + } +} + +#[test] +fn admission_diagnostics_do_not_render_malformed_target_references() { + let mut project = action_project(); + let profile = &mut project["accessProfiles"]["registrar"]; + profile["requiredScopes"] = json!("unrestricted"); + profile["permissions"]["actions"][0]["targets"][1]["recordType"] = json!("CANARY SECRET VALUE"); + let failure = compile(&project).unwrap_err(); + assert!(!format!("{failure:?}").contains("CANARY SECRET VALUE")); +} diff --git a/crates/registry-breg/tests/migration_plan.rs b/crates/registry-breg/tests/migration_plan.rs index 1013211da9..e44c4051e8 100644 --- a/crates/registry-breg/tests/migration_plan.rs +++ b/crates/registry-breg/tests/migration_plan.rs @@ -40,7 +40,7 @@ journeys: - id: list-assets recordType: asset accessProfile: reader - claims: {principal: package-reader} + claims: {principal: package-reader, scopes: [assets:write]} request: {type: list} expect: {outcome: success, status: 200, count: 0} "#; @@ -2691,7 +2691,7 @@ fn module_bytes(variant: Variant) -> Vec { _ => "", }; format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"create-only","fields":[{fields}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}},"site":{{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}{site_secret}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"create-only","fields":[{fields}],"accessProfiles":{{"reader":{{"requiredScopes":["assets:write"],"rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}},"site":{{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}{site_secret}],"accessProfiles":{{"reader":{{"requiredScopes":["assets:write"],"rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# ) .into_bytes() } diff --git a/crates/registry-breg/tests/migration_review_permission_order.rs b/crates/registry-breg/tests/migration_review_permission_order.rs index c8a4c06fd0..6c7af8147e 100644 --- a/crates/registry-breg/tests/migration_review_permission_order.rs +++ b/crates/registry-breg/tests/migration_review_permission_order.rs @@ -15,7 +15,7 @@ fn proposal_grant(operations: Value, client: &str) -> Value { "requesterClients":[client], "permissions":{"records":[ {"recordType":"case","operations":["get","list"],"readableFields":["label"],"rowBoundaries":"unrestricted"}], - "proposals":[{"action":"correct-case","operations":operations,"ownership":"caller", + "proposals":[{"action":"correct-case","operations":operations,"party":"owner", "targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]} }) } diff --git a/crates/registry-breg/tests/native_plan_security.rs b/crates/registry-breg/tests/native_plan_security.rs index fac5d30fa6..1571bd2ff4 100644 --- a/crates/registry-breg/tests/native_plan_security.rs +++ b/crates/registry-breg/tests/native_plan_security.rs @@ -19,7 +19,7 @@ fn source() -> Value { {"id":"unbound","type":"string","maximumLength":64,"classification":"restricted"}], "plan":{"type":"scripted","actionPlan":"calculate","inputs":["label"], "writes":[{"id":"item","target":{"recordType":"item"},"operation":"create","fields":["label"]}]}}}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"actions":[{"action":"register-item","operations":["invoke"],"targets":[{"recordType":"item","rowBoundaries":"unrestricted"}],"results":["item"]}]}}}}) } fn compile(script: &str) -> Result { diff --git a/crates/registry-breg/tests/odrl_export.rs b/crates/registry-breg/tests/odrl_export.rs index e4788c9d97..b1af7928ef 100644 --- a/crates/registry-breg/tests/odrl_export.rs +++ b/crates/registry-breg/tests/odrl_export.rs @@ -338,28 +338,6 @@ fn row_membership_and_consent_restrictions_omit_the_complete_read_grant() { json!([]) ); - let membership = compile_project( - &parse_project_yaml(MEMBERSHIP).unwrap(), - &[], - CompileProfile::Authoring, - ) - .unwrap(); - let membership_export = export_odrl(&membership, Some("member")).unwrap(); - let membership_reads = membership_export.coverage["grants"] - .as_array() - .unwrap() - .iter() - .filter(|grant| grant["operation"] == "get" || grant["operation"] == "list") - .collect::>(); - assert_eq!(membership_reads.len(), 2); - assert!(membership_reads.iter().all(|grant| { - grant["status"] == "omitted" - && grant["reasons"] - .as_array() - .unwrap() - .contains(&json!("membership-boundaries")) - })); - let consent = compile_with_modules(CONSENT, &[CONSENT_PERSON, CONSENT_CORE]); let consent_export = export_odrl(&consent, Some("food-targeting")).unwrap(); assert!(consent_export.coverage["grants"] @@ -691,3 +669,32 @@ fn profile_declares_every_emitted_extension_and_adopts_read() { "one collection and thirteen term definitions" ); } + +#[test] +fn a_membership_only_read_grant_is_omitted_from_the_odrl_export() { + let membership = compile_project( + &parse_project_yaml(MEMBERSHIP).unwrap(), + &[], + CompileProfile::Authoring, + ) + .unwrap(); + let membership_export = export_odrl(&membership, Some("member")).unwrap(); + let membership_reads = membership_export.coverage["grants"] + .as_array() + .unwrap() + .iter() + .filter(|grant| grant["operation"] == "get" || grant["operation"] == "list") + .collect::>(); + assert_eq!(membership_reads.len(), 2); + assert!(membership_reads.iter().all(|grant| { + grant["status"] == "omitted" + && grant["reasons"] + .as_array() + .unwrap() + .contains(&json!("membership-boundaries")) + })); + assert_eq!( + document(&membership_export, "generated/odrl/policies.jsonld")["@graph"], + json!([]) + ); +} diff --git a/crates/registry-breg/tests/ordered_plan_contract.rs b/crates/registry-breg/tests/ordered_plan_contract.rs index d834cd4936..5330ae499c 100644 --- a/crates/registry-breg/tests/ordered_plan_contract.rs +++ b/crates/registry-breg/tests/ordered_plan_contract.rs @@ -16,7 +16,7 @@ fn project() -> Value { {"id":"parent","type":"reference","target":"entry","classification":"internal"}]}}, "actions":{"create-pair": {"execution":{"mode":"immediate"},"inputs":[{"id":"name","type":"string","maximumLength":32,"required":true,"classification":"internal"}], "plan":{"type":"fixed","effects":[{"id":"z-result","target":{"recordType":"entry"},"operation":"create","set":{"name":{"fromInput":"name"}}},{"id":"a-result","target":{"recordType":"entry"},"operation":"create","set":{"name":{"fromInput":"name"}}}]}}}, - "accessProfiles":{"creator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"actions":[{"action":"create-pair","operations":["invoke"],"targets":[{"recordType":"entry","rowBoundaries":"unrestricted"}],"results":["z-result","a-result"]}]}}} + "accessProfiles":{"creator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"actions":[{"action":"create-pair","operations":["invoke"],"targets":[{"recordType":"entry","rowBoundaries":"unrestricted"}],"results":["z-result","a-result"]}]}}} }) } fn compile( diff --git a/crates/registry-breg/tests/package_change_plan.rs b/crates/registry-breg/tests/package_change_plan.rs index 2be5fc3237..354faf057d 100644 --- a/crates/registry-breg/tests/package_change_plan.rs +++ b/crates/registry-breg/tests/package_change_plan.rs @@ -1025,10 +1025,10 @@ fn metadata_only_access_or_disclosure_changes_create_empty_applicable_plans() { fn complete_extension_surface_modules_are_order_independent() { let field_module = parse_module_yaml(br#"{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"field-extension","version":"1","extendRecordTypes":{"asset": {"fields":[{"id":"status","type":"string","maximumLength":16,"classification":"internal"}],"constraints":[{"type":"unique","id":"status-unique","fields":["status"]}],"indexes":[{"id":"status-idx","fields":["status"]}]}}}"#) .expect("field extension parses"); - let event_module = parse_module_yaml(br#"{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"event-extension","version":"1","extendRecordTypes":{"asset": {"accessProfiles":{"auditor": {"principalClaim":"principal","operations":["get","list"],"readableFields":["code","status"],"writableFields":[], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}},"hooks":[{"phase":"after","id":"asset-created","trigger":"created","projection":["code","status"],"handler":{"type":"url","destinationId":"package-change-events"}}]}},"recordTypes":{"site": {"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}}}"#) + let event_module = parse_module_yaml(br#"{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"event-extension","version":"1","extendRecordTypes":{"asset": {"accessProfiles":{"auditor": {"principalClaim":"principal","operations":["get","list"],"readableFields":["code","status"],"writableFields":[], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}},"hooks":[{"phase":"after","id":"asset-created","trigger":"created","projection":["code","status"],"handler":{"type":"url","destinationId":"package-change-events"}}]}},"recordTypes":{"site": {"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"], "requiredScopes":"unrestricted","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}]}}}}}"#) .expect("event extension parses"); let project_bytes = format!( - r#"{{"datasets":{{"neutral-registry": {{}}}},"apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject","project":{{"id":"neutral-registry","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://package.example.test"}},"package":{{"sourceRevision":"{SOURCE_REVISION}"}},"manifestProjection":{{"accessProfile":"reader","classificationCeiling":"internal","catalog":{{"baseUrl":"https://package.example.test","title":"Neutral Registry Catalog","publisher":{{"id":"neutral-registry-authority","name":"Package Test Publisher"}}}},"authorities":[{{"id":"neutral-registry-authority","name":"Package Test Publisher"}}],"publicServices":[{{"id":"neutral-registry-service","title":"Neutral Registry Catalog","competentAuthority":"neutral-registry-authority"}}],"datasets":[{{"id":"neutral-registry","title":"Neutral Registry Dataset","owner":"Package Test Publisher","status":"active"}}],"dataServices":[{{"id":"neutral-registry-data-service","title":"Neutral Registry Catalog","endpointUrl":"https://package.example.test","servesDatasets":["neutral-registry"]}}]}},"recordTypes":{{"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}]}}}},"accessProfiles":{{"reader":{{"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{{"records":[{{"rowBoundaries": "unrestricted", "recordType":"asset","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}]}}}}}},"modules":{{"field-extension":{{"version":"1","digest":"{}"}},"event-extension":{{"version":"1","digest":"{}"}}}}}}"#, + r#"{{"datasets":{{"neutral-registry": {{}}}},"apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject","project":{{"id":"neutral-registry","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://package.example.test"}},"package":{{"sourceRevision":"{SOURCE_REVISION}"}},"manifestProjection":{{"accessProfile":"reader","classificationCeiling":"internal","catalog":{{"baseUrl":"https://package.example.test","title":"Neutral Registry Catalog","publisher":{{"id":"neutral-registry-authority","name":"Package Test Publisher"}}}},"authorities":[{{"id":"neutral-registry-authority","name":"Package Test Publisher"}}],"publicServices":[{{"id":"neutral-registry-service","title":"Neutral Registry Catalog","competentAuthority":"neutral-registry-authority"}}],"datasets":[{{"id":"neutral-registry","title":"Neutral Registry Dataset","owner":"Package Test Publisher","status":"active"}}],"dataServices":[{{"id":"neutral-registry-data-service","title":"Neutral Registry Catalog","endpointUrl":"https://package.example.test","servesDatasets":["neutral-registry"]}}]}},"recordTypes":{{"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}},{{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}}]}}}},"accessProfiles":{{"reader":{{"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{{"records":[{{"rowBoundaries": [{{"field":"owner","claim":"principal","operator":"equals"}}], "recordType":"asset","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]}}]}}}}}},"modules":{{"field-extension":{{"version":"1","digest":"{}"}},"event-extension":{{"version":"1","digest":"{}"}}}}}}"#, module_digest(&field_module), module_digest(&event_module) ); @@ -2242,7 +2242,8 @@ fn vocabulary_registry(vocabulary: &str, values: &[&str]) -> CompiledRegistry { "vocabulary": vocabulary, "required": true, "classification": "internal" - } + }, + {"id": "owner", "type": "string", "maximumLength": 255, "classification": "internal"} ] }}, "accessProfiles": {"writer": { @@ -2253,8 +2254,8 @@ fn vocabulary_registry(vocabulary: &str, values: &[&str]) -> CompiledRegistry { "recordType": "entry", "operations": ["create", "get", "list", "patch"], "readableFields": ["status"], - "writableFields": ["status"], - "rowBoundaries": "unrestricted" + "writableFields": ["status", "owner"], + "rowBoundaries": [{"field": "owner", "claim": "registry_principal", "operator": "equals"}] }]} }} }); @@ -2311,7 +2312,7 @@ fn field_registry(field: serde_json::Value) -> CompiledRegistry { "primaryDataset": "test-dataset", "route": "entries", "mutationMode": "mutable", - "fields": [field] + "fields": [field, {"id": "owner", "type": "string", "maximumLength": 255, "classification": "internal"}] }}, "accessProfiles": {"writer": { "default": true, @@ -2321,8 +2322,8 @@ fn field_registry(field: serde_json::Value) -> CompiledRegistry { "recordType": "entry", "operations": ["create", "get", "list", "patch"], "readableFields": ["note"], - "writableFields": ["note"], - "rowBoundaries": "unrestricted" + "writableFields": ["note", "owner"], + "rowBoundaries": [{"field": "owner", "claim": "registry_principal", "operator": "equals"}] }]} }} }); @@ -2417,6 +2418,7 @@ fn geojson_source(binding: Option<&str>) -> SourceFixture { serde_json::from_slice(&module_bytes(Variant::Base)).unwrap(); let entity = &mut module["recordTypes"]["asset"]; let fields = entity["fields"].as_array_mut().unwrap(); + fields.retain(|field| field["id"] != "owner"); for id in ["location", "alternate"] { fields.push(serde_json::json!({ "id": id, "type": "crs84-point", "precision": 9, "classification": "internal" @@ -2424,6 +2426,7 @@ fn geojson_source(binding: Option<&str>) -> SourceFixture { } entity["accessProfiles"]["reader"]["operations"] = serde_json::json!(["get"]); entity["accessProfiles"]["reader"]["writableFields"] = serde_json::json!([]); + entity["accessProfiles"]["reader"]["rowBoundaries"] = serde_json::json!("unrestricted"); entity["accessProfiles"]["reader"]["readableFields"] = serde_json::json!(["code", "location", "alternate"]); if let Some(binding) = binding { @@ -2526,7 +2529,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::OptionalField => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"color","type":"string","maximumLength":16,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2534,7 +2537,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::RequiredField => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"batch","type":"string","maximumLength":16,"required":true,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2542,7 +2545,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::RequiredAndOptionalFields => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"batch","type":"string","maximumLength":16,"required":true,"classification":"internal"},{"id":"color","type":"string","maximumLength":16,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2550,7 +2553,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::ReferenceConstraintIndex => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"site","type":"reference","target":"site","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, r#","constraints":[{"type":"unique","id":"code-unique","fields":["code"]}]"#, r#","indexes":[{"id":"code-idx","fields":["code"]}]"#, "", @@ -2558,7 +2561,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::ReferenceConstraintIndexReordered => asset_entity( r#"{"id":"site","type":"reference","target":"site","classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"code","type":"string","maximumLength":8,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["list","get","create"],"writableFields":["code"],"readableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["list","get","create"],"writableFields":["code","owner"],"readableFields":["code"]"#, r#","constraints":[{"fields":["code"],"id":"code-unique","type":"unique"}]"#, r#","indexes":[{"fields":["code"],"id":"code-idx"}]"#, "", @@ -2566,7 +2569,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::FieldRemoved => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2574,7 +2577,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::TypeChanged => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"string","maximumLength":8,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2582,7 +2585,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::PlaintextSecret => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"secret","type":"string","maximumLength":64,"classification":"restricted"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2590,7 +2593,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::EncryptedStructuredSecret => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"secret","type":"structured","maximumBytes":1024,"schema":{"type":"object","additionalProperties":false},"classification":"restricted","encrypted":true}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2598,7 +2601,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::RouteChanged => asset_entity( base_asset_fields(), r#""route":"equipment""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2606,7 +2609,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::EntityClassificationChanged => asset_entity( base_asset_fields(), r#""route":"assets","classification":"restricted""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2614,7 +2617,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::ClassificationChanged => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"restricted"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2622,7 +2625,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::AuthorizationChanged => asset_entity( base_asset_fields(), r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"subject","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"subject","rowBoundaries":[{"field":"owner","claim":"subject","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2631,7 +2634,7 @@ fn module_bytes(variant: Variant) -> Vec { base_asset_fields(), r#""route":"assets""#, "mutable", - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2639,7 +2642,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::TemporalChanged => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"required":true,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"valid-from","type":"date","required":true,"classification":"internal"},{"id":"valid-to","type":"date","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to","owner"]"#, r#","constraints":[{"type":"temporal-non-overlap","id":"code-time","scopeFields":["code"],"startField":"valid-from","endField":"valid-to"}]"#, "", r#","temporal":{"startField":"valid-from","endField":"valid-to"}"#, @@ -2647,7 +2650,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::TemporalRoleBase => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"valid-from","type":"date","required":true,"classification":"internal"},{"id":"valid-to","type":"date","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to","owner"]"#, "", "", "", @@ -2655,7 +2658,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::TemporalRoleChanged => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"valid-from","type":"date","required":true,"classification":"internal","validTimeRole":"valid-from"},{"id":"valid-to","type":"date","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to","owner"]"#, "", "", "", @@ -2663,7 +2666,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::RankRequired => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","required":true,"classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2671,7 +2674,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::ReferenceTargetBase => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"home-site","type":"reference","target":"site","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2679,7 +2682,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::ReferenceTargetChanged => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"home-site","type":"reference","target":"location","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2687,7 +2690,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::MetadataOnlyBase => asset_entity( r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"internal"},{"id":"valid-from","type":"date","required":true,"classification":"internal"},{"id":"valid-to","type":"date","classification":"internal"}"#, r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to","owner"]"#, "", "", r#","hooks":[{"phase":"after","id":"asset-created","trigger":"created","projection":["code"],"handler":{"type":"url","destinationId":"package-change-events"}}]"#, @@ -2696,7 +2699,7 @@ fn module_bytes(variant: Variant) -> Vec { r#"{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"rank","type":"int64","classification":"restricted"},{"id":"valid-from","type":"date","required":true,"classification":"internal","validTimeRole":"valid-from"},{"id":"valid-to","type":"date","classification":"internal"}"#, r#""route":"equipment","classification":"restricted","accessRequirements":{"requiredScopes":["asset:read"]}"#, "mutable", - r#""principalClaim":"subject","requiredScopes":["asset:read"],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to"]"#, + r#""principalClaim":"subject","rowBoundaries":[{"field":"owner","claim":"subject","operator":"equals"}],"requiredScopes":["asset:read"],"operations":["create","get","list"],"readableFields":["code","valid-from","valid-to"],"writableFields":["code","valid-from","valid-to","owner"]"#, "", "", r#","hooks":[{"phase":"after","id":"asset-created","trigger":"created","projection":["code","rank"],"handler":{"type":"url","destinationId":"package-change-events"}}]"#, @@ -2704,7 +2707,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::Base | Variant::NewEntity => asset_entity( base_asset_fields(), r#""route":"assets""#, - r#""requiredScopes":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]"#, + r#""requiredScopes":"unrestricted","principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"]"#, "", "", "", @@ -2763,20 +2766,20 @@ fn asset_entity_with_mode( temporal: &str, ) -> String { format!( - r#""asset":{{"primaryDataset":"neutral-registry",{route},"mutationMode":"{mutation_mode}","fields":[{fields}]{constraints}{indexes},"accessProfiles":{{"reader":{{"rowBoundaries":"unrestricted",{access}}}}}{temporal}}}"# + r#""asset":{{"primaryDataset":"neutral-registry",{route},"mutationMode":"{mutation_mode}","fields":[{fields},{{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}}]{constraints}{indexes},"accessProfiles":{{"reader":{{{access}}}}}{temporal}}}"# ) } fn site_entity() -> &'static str { - r#""site":{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}"# + r#""site":{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"], "requiredScopes":"unrestricted"}}}"# } fn location_entity() -> &'static str { - r#""location":{"primaryDataset":"neutral-registry","route":"locations","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}"# + r#""location":{"primaryDataset":"neutral-registry","route":"locations","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"},{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["code"],"writableFields":["code","owner"], "requiredScopes":"unrestricted"}}}"# } fn placement_entity() -> &'static str { - r#""placement":{"primaryDataset":"neutral-registry","route":"placements","mutationMode":"create-only","fields":[{"id":"asset","type":"reference","target":"asset","required":true,"classification":"internal"},{"id":"site","type":"reference","target":"site","required":true,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","operations":["create","get","list"],"readableFields":["asset","site"],"writableFields":["asset","site"], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}"# + r#""placement":{"primaryDataset":"neutral-registry","route":"placements","mutationMode":"create-only","fields":[{"id":"asset","type":"reference","target":"asset","required":true,"classification":"internal"},{"id":"site","type":"reference","target":"site","required":true,"classification":"internal"},{"id":"owner","type":"string","maximumLength":255,"classification":"internal"}],"accessProfiles":{"reader": {"principalClaim":"principal","rowBoundaries":[{"field":"owner","claim":"principal","operator":"equals"}],"operations":["create","get","list"],"readableFields":["asset","site"],"writableFields":["asset","site","owner"], "requiredScopes":"unrestricted"}}}"# } fn build_request( diff --git a/crates/registry-breg/tests/postgres_access_log.rs b/crates/registry-breg/tests/postgres_access_log.rs index 526e842389..c41c65470b 100644 --- a/crates/registry-breg/tests/postgres_access_log.rs +++ b/crates/registry-breg/tests/postgres_access_log.rs @@ -354,6 +354,10 @@ fn token(idp: &MockIdp, client: &str, subject: &str) -> String { idp.mint_token(json!({"aud":AUDIENCE,"sub":subject,"client_id":client,"scope":"registry.read","registry_actor_kind":"service","registry_purpose":PURPOSE})) } +fn writer_token(idp: &MockIdp, client: &str, subject: &str) -> String { + idp.mint_token(json!({"aud":AUDIENCE,"sub":subject,"client_id":client,"scope":"registry.read records:write","registry_actor_kind":"service","registry_purpose":PURPOSE})) +} + async fn send( app: &Router, token: &str, @@ -973,7 +977,7 @@ fn compiled_with_history() -> CompiledRegistry { "revisionAccess":true,"rowBoundaries":"unrestricted"} ] }}, - "steward": {"principalClaim":"sub","requiredScopes":"unrestricted","requiredPurposes":[PURPOSE],"permissions":{ + "steward": {"principalClaim":"sub","requiredScopes":["records:write"],"requiredPurposes":[PURPOSE],"permissions":{ "records":[ {"recordType":"entry","operations":["create"],"readableFields":["subject","label"], "writableFields":["subject","label"],"rowBoundaries":"unrestricted"} @@ -1136,7 +1140,7 @@ async fn logged_operations(db: &TestDatabase, record: &str) -> Vec { #[tokio::test] async fn snapshot_and_revision_reads_write_subject_access_log_entries() { let (db, app, idp, registry) = setup_with_history().await; - let steward = token(&idp, "agency", "steward"); + let steward = writer_token(&idp, "agency", "steward"); let reader = token(&idp, "agency", "officer"); let request = Request::builder() .method(Method::POST) @@ -1311,7 +1315,7 @@ async fn head_on_subject_access_log_reads_is_refused_without_a_journaled_read() #[tokio::test] async fn head_on_history_reads_is_refused_without_a_journaled_read() { let (db, app, idp, _) = setup_with_history().await; - let steward = token(&idp, "agency", "steward"); + let steward = writer_token(&idp, "agency", "steward"); let reader = token(&idp, "agency", "officer"); let request = Request::builder() .method(Method::POST) @@ -1729,7 +1733,7 @@ fn compiled_with_writes() -> CompiledRegistry { }; let entry_writes = json!(["get", "create", "patch", "batch", "tombstone"]); let profile = |reason: bool, records: Value| { - json!({"principalClaim":"sub","requiredScopes":"unrestricted", + json!({"principalClaim":"sub","requiredScopes":["records:write"], "requiredPurposes":[PURPOSE],"requireAccessReason":reason, "permissions":{"records":records}}) }; @@ -1854,7 +1858,7 @@ async fn logged_entries(db: &TestDatabase) -> Vec<(String, String, String, Optio #[tokio::test] async fn each_direct_write_under_a_reasoned_profile_logs_one_write_entry_with_its_reason() { let (db, app, idp, registry) = setup_with_mutations(compiled_with_writes(), None).await; - let clerk = token(&idp, "agency", "clerk"); + let clerk = writer_token(&idp, "agency", "clerk"); let (first, etag) = create_entry(&app, &clerk, "clerk", Some("create reason")).await; let (status, body, etag) = write_as( @@ -1959,7 +1963,7 @@ async fn each_direct_write_under_a_reasoned_profile_logs_one_write_entry_with_it #[tokio::test] async fn a_write_under_a_profile_without_the_flag_logs_no_write_entry() { let (db, app, idp, _) = setup_with_mutations(compiled_with_writes(), None).await; - let steward = token(&idp, "agency", "steward"); + let steward = writer_token(&idp, "agency", "steward"); let (record, etag) = create_entry(&app, &steward, "steward", None).await; let (status, body, _) = write_as( &app, @@ -1985,7 +1989,7 @@ async fn a_write_under_a_profile_without_the_flag_logs_no_write_entry() { #[tokio::test] async fn a_type_without_an_access_log_requires_the_reason_and_stores_nothing() { let (db, app, idp, _) = setup_with_mutations(compiled_with_writes(), None).await; - let clerk = token(&idp, "agency", "clerk"); + let clerk = writer_token(&idp, "agency", "clerk"); let note = || { Some(( "application/json", @@ -2030,7 +2034,7 @@ async fn a_rolled_back_write_leaves_no_write_entry() { Some(MutationFaultPoint::BeforeCommit), ) .await; - let clerk = token(&idp, "agency", "clerk"); + let clerk = writer_token(&idp, "agency", "clerk"); let (status, body, _) = write_as( &app, &clerk, @@ -2055,7 +2059,7 @@ async fn a_rolled_back_write_leaves_no_write_entry() { #[tokio::test] async fn a_write_entry_raises_no_read_alert() { let (db, app, idp, _) = setup_with_mutations(compiled_with_writes(), None).await; - let clerk = token(&idp, "agency", "clerk"); + let clerk = writer_token(&idp, "agency", "clerk"); let (record, _) = create_entry(&app, &clerk, "clerk", Some("create reason")).await; assert_eq!(logged_entries(&db).await.len(), 1); assert_eq!(read_alerts(&db).await, []); @@ -2079,8 +2083,8 @@ async fn a_write_entry_raises_no_read_alert() { #[tokio::test] async fn write_entries_keep_the_retention_and_exemption_delay_of_read_entries() { let (db, app, idp, _) = setup_with_mutations(compiled_with_writes(), None).await; - let clerk = token(&idp, "agency", "clerk"); - let investigator = token(&idp, "agency", "investigator"); + let clerk = writer_token(&idp, "agency", "clerk"); + let investigator = writer_token(&idp, "agency", "investigator"); let (prompt, _) = create_entry(&app, &clerk, "clerk", Some("create reason")).await; let (delayed, _) = create_entry(&app, &investigator, "investigator", Some("investigation")).await; diff --git a/crates/registry-breg/tests/postgres_action_handlers.rs b/crates/registry-breg/tests/postgres_action_handlers.rs index 5422bf3d99..c139d5bbf2 100644 --- a/crates/registry-breg/tests/postgres_action_handlers.rs +++ b/crates/registry-breg/tests/postgres_action_handlers.rs @@ -1072,7 +1072,7 @@ async fn absent_optional_copy_has_the_same_safe_failure_at_invoke_and_submit() { proposal["execution"] = json!({"mode":"proposal","proposal":{"review":{"type":"none"},"application":{"mode":"manual"},"retention":{"mode":"operator-erase"}}}); source["actions"]["invalid-proposal"] = proposal; source["accessProfiles"]["author"]["permissions"]["actions"].as_array_mut().unwrap().push(json!({"action":"invalid-proposal","operations":["start"],"targets":[{"recordType":"entry","rowBoundaries":"unrestricted"}]})); - source["accessProfiles"]["author"]["permissions"]["proposals"] = json!([{"action":"invalid-proposal","operations":["get","edit","submit","cancel"],"ownership":"caller","readableInputs":["note","private-data"],"writableInputs":["note","private-data"],"targets":[{"recordType":"entry","rowBoundaries":"unrestricted"}]}]); + source["accessProfiles"]["author"]["permissions"]["proposals"] = json!([{"action":"invalid-proposal","operations":["get","edit","submit","cancel"],"party":"owner","readableInputs":["note","private-data"],"writableInputs":["note","private-data"],"targets":[{"recordType":"entry","rowBoundaries":"unrestricted"}]}]); let project = registry_breg::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); let assets = [ @@ -1106,7 +1106,7 @@ async fn absent_optional_copy_has_the_same_safe_failure_at_invoke_and_submit() { let claims = VerifiedRequestClaims::authenticated_with_actor_kind( "sub", "author", - BTreeSet::new(), + BTreeSet::from(["entries:write".to_owned()]), None, BTreeMap::new(), registry_platform_oidc::ActorKind::Human, diff --git a/crates/registry-breg/tests/postgres_batch.rs b/crates/registry-breg/tests/postgres_batch.rs index 40b4d1b2ad..6e092b3eb3 100644 --- a/crates/registry-breg/tests/postgres_batch.rs +++ b/crates/registry-breg/tests/postgres_batch.rs @@ -957,7 +957,7 @@ fn compiled_timer_batch_registry() -> registry_breg::CompiledRegistry { .remove("service-editor") .expect("the future-activation example has a service-editor profile"); source["accessProfiles"]["operator"] = renamed; - source["accessProfiles"]["operator"]["requiredScopes"] = json!("unrestricted"); + source["accessProfiles"]["operator"]["requiredScopes"] = json!(["records:write"]); source["accessProfiles"]["operator"]["permissions"]["records"][0]["operations"] = json!(["create", "get", "list", "patch", "tombstone", "batch"]); let bytes = serde_json::to_vec(&source).expect("timer batch fixture serializes"); @@ -1074,7 +1074,7 @@ fn compiled_registry_with_create_policy( {"phase":"after","id":"widget-patched","trigger":"patched","projection":["label","quantity"]} ] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management","case-review"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","patch","batch"], @@ -1082,7 +1082,7 @@ fn compiled_registry_with_create_policy( "writableFields":["jurisdiction","label","secret","quantity"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"batch-creator": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"batch-creator": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","batch"], @@ -1090,7 +1090,7 @@ fn compiled_registry_with_create_policy( "writableFields":["jurisdiction","label","secret","quantity"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"operator-minimal": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"operator-minimal": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","patch","batch"], @@ -1173,7 +1173,7 @@ fn claims(principal: &str, purpose: &str, jurisdiction: &str) -> VerifiedRequest VerifiedRequestClaims::authenticated( "registry_principal", principal, - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some(purpose.to_owned()), BTreeMap::from([( "jurisdiction".to_owned(), diff --git a/crates/registry-breg/tests/postgres_client_capabilities.rs b/crates/registry-breg/tests/postgres_client_capabilities.rs index b2e39d203f..b41184770f 100644 --- a/crates/registry-breg/tests/postgres_client_capabilities.rs +++ b/crates/registry-breg/tests/postgres_client_capabilities.rs @@ -44,7 +44,7 @@ fn registry() -> registry_breg::CompiledRegistry { "temporal":{"startField":"valid-from","endField":"valid-to"}, "constraints":[{"type":"temporal-non-overlap","scopeFields":["code"],"startField":"valid-from","endField":"valid-to"}] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{"recordType":"entry","operations":["create","get","list","patch","batch","tombstone","revisions","snapshot"], "readableFields":["code","label","valid-from","valid-to"],"writableFields":["code","label","valid-from","valid-to"], @@ -61,7 +61,7 @@ fn claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "registry_principal", "sdk-fixture-operator", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-management".into()), BTreeMap::new(), ) diff --git a/crates/registry-breg/tests/postgres_compiled_schema.rs b/crates/registry-breg/tests/postgres_compiled_schema.rs index 605d6d50c9..20573b4e05 100644 --- a/crates/registry-breg/tests/postgres_compiled_schema.rs +++ b/crates/registry-breg/tests/postgres_compiled_schema.rs @@ -2213,7 +2213,7 @@ fn additive_catalog_registry(variant: AdditiveCatalogVariant) -> registry_breg:: "accessProfiles": {"writer": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "entry", "operations": ["create", "get", "list", "patch"], @@ -2253,7 +2253,7 @@ fn length_catalog_registry(max_length: u32) -> registry_breg::CompiledRegistry { "accessProfiles": {"writer": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "entry", "operations": ["create", "get", "list", "patch"], @@ -2290,7 +2290,7 @@ fn string_length_catalog_registry(min_length: u32) -> registry_breg::CompiledReg "accessProfiles": {"writer": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "entry", "operations": ["create", "get", "list", "patch"], @@ -2339,7 +2339,7 @@ fn vocabulary_catalog_registry_with_constraints( "accessProfiles": {"writer": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": "entry", "operations": ["create", "get", "list", "patch"], @@ -2377,7 +2377,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { } }, "accessProfiles":{ - "writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["operations"], "permissions":{ "records":[ @@ -2471,7 +2471,7 @@ fn compiled_action_registry() -> registry_breg::CompiledRegistry { "accessProfiles": {"operator": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": { "actions": [{ "action": "relabel-entry", @@ -2507,7 +2507,7 @@ fn derived_registry() -> registry_breg::CompiledRegistry { ] }] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"household","operations":["create","get","list"], "readableFields":["tenant","size","child-count","observed-on"], "writableFields":["tenant","size"], diff --git a/crates/registry-breg/tests/postgres_consent_access.rs b/crates/registry-breg/tests/postgres_consent_access.rs index 47721fe357..521953d1bd 100644 --- a/crates/registry-breg/tests/postgres_consent_access.rs +++ b/crates/registry-breg/tests/postgres_consent_access.rs @@ -1639,7 +1639,7 @@ async fn frozen_review_changes_require_current_consent_for_each_snapshot_subject "action":"reassign-enrolment","operations":["start"],"targets":targets })); steward["permissions"]["proposals"] = json!([{ - "action":"reassign-enrolment","operations":["get","submit"],"ownership":"caller","targets":targets + "action":"reassign-enrolment","operations":["get","submit"],"party":"owner","targets":targets }]); let reviewer = &mut source["accessProfiles"][SCOPE]; reviewer["permissions"]["proposals"] = json!([{ diff --git a/crates/registry-breg/tests/postgres_constraint_races.rs b/crates/registry-breg/tests/postgres_constraint_races.rs index 19a0463c6c..3a33386b3f 100644 --- a/crates/registry-breg/tests/postgres_constraint_races.rs +++ b/crates/registry-breg/tests/postgres_constraint_races.rs @@ -491,7 +491,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "startField":"valid-from","endField":"valid-to" }] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["operations"], + "accessProfiles":{"operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"parent","operations":["create","get"],"readableFields":["name"],"writableFields":["name"], "rowBoundaries": "unrestricted" diff --git a/crates/registry-breg/tests/postgres_data_export.rs b/crates/registry-breg/tests/postgres_data_export.rs index c1c09023a8..2ebf791d9f 100644 --- a/crates/registry-breg/tests/postgres_data_export.rs +++ b/crates/registry-breg/tests/postgres_data_export.rs @@ -74,6 +74,7 @@ async fn real_postgres_export_is_authenticated_projected_audited_and_resumable() "aud":AUDIENCE, "registry_actor_kind":"service", "registry_principal":PRINCIPAL_CANARY, + "scope":"records:write", "purpose":"data-export", "jurisdictions":["north"] })); @@ -81,6 +82,7 @@ async fn real_postgres_export_is_authenticated_projected_audited_and_resumable() "aud":AUDIENCE, "registry_actor_kind":"service", "registry_principal":PRINCIPAL_CANARY, + "scope":"records:write", "purpose":"other-purpose", "jurisdictions":["north"] })); @@ -380,7 +382,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "constraints":[{"type":"unique","fields":["code"]}], "hooks":[{"phase":"after","id":"entry-created","trigger":"created","projection":["code"]}] }}, - "accessProfiles":{PROFILE: { "principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{PROFILE: { "principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["data-export"], "permissions":{"records":[{ "recordType":"entry", diff --git a/crates/registry-breg/tests/postgres_data_facility.rs b/crates/registry-breg/tests/postgres_data_facility.rs index fdd03075c6..4f47b82343 100644 --- a/crates/registry-breg/tests/postgres_data_facility.rs +++ b/crates/registry-breg/tests/postgres_data_facility.rs @@ -21,13 +21,15 @@ const PROFILE: &str = "facility-operator"; #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn real_postgres_facility_import_is_authenticated_chunked_resumable_and_race_safe() { let harness = PilotHarness::start("facility").await; - let north_token = harness.token( + let north_token = harness.token_with_scopes( "facility-registry", &[("administrative_boundaries", json!(["north-district"]))], + &["registry:facility:operate"], ); - let south_token = harness.token( + let south_token = harness.token_with_scopes( "facility-registry", &[("administrative_boundaries", json!(["south-district"]))], + &["registry:facility:operate"], ); let facility_id = create( &harness, diff --git a/crates/registry-breg/tests/postgres_derived_values.rs b/crates/registry-breg/tests/postgres_derived_values.rs index c9af919b93..f132f784ea 100644 --- a/crates/registry-breg/tests/postgres_derived_values.rs +++ b/crates/registry-breg/tests/postgres_derived_values.rs @@ -291,7 +291,7 @@ async fn real_postgres_derived_values_enforce_declared_contracts() { VerifiedRequestClaims::authenticated( "registry_principal", "test-principal", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::new(), ) @@ -343,7 +343,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { ] }] }}, - "accessProfiles":{"reader": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"reader": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"entry","operations":["create","get","list"], "readableFields":["scenario","short-code","description","amount","count","state"], diff --git a/crates/registry-breg/tests/postgres_event_record_examples.rs b/crates/registry-breg/tests/postgres_event_record_examples.rs index ce4822e954..7504d44615 100644 --- a/crates/registry-breg/tests/postgres_event_record_examples.rs +++ b/crates/registry-breg/tests/postgres_event_record_examples.rs @@ -277,7 +277,7 @@ fn claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "registry_principal", "registrar-principal", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::::new(), ) diff --git a/crates/registry-breg/tests/postgres_event_record_reader.rs b/crates/registry-breg/tests/postgres_event_record_reader.rs index 2c92ba18cb..507846ea0f 100644 --- a/crates/registry-breg/tests/postgres_event_record_reader.rs +++ b/crates/registry-breg/tests/postgres_event_record_reader.rs @@ -92,7 +92,7 @@ fn record_permissions() -> String { fn compile_reader(declarations: &str, other_permissions: &str) -> registry_breg::CompiledRegistry { let project = format!( "{declarations}\naccessProfiles:\n reader:\n default: true\n \ - principalClaim: registry_principal\n requiredScopes: unrestricted\n \ + principalClaim: registry_principal\n requiredScopes: [records:write]\n \ permissions:\n{other_permissions} records:\n{}", record_permissions() ); @@ -128,7 +128,7 @@ fn claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "registry_principal", "event-record-reader-fixture", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::new(), ) diff --git a/crates/registry-breg/tests/postgres_field_encryption.rs b/crates/registry-breg/tests/postgres_field_encryption.rs index f9a058f48c..9f0d11e452 100644 --- a/crates/registry-breg/tests/postgres_field_encryption.rs +++ b/crates/registry-breg/tests/postgres_field_encryption.rs @@ -139,7 +139,7 @@ accessProfiles: operator: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [registry:field-encryption:operate] requiredPurposes: [case-management] permissions: records: diff --git a/crates/registry-breg/tests/postgres_fixture_journeys.rs b/crates/registry-breg/tests/postgres_fixture_journeys.rs index c3d038eced..e3033f6012 100644 --- a/crates/registry-breg/tests/postgres_fixture_journeys.rs +++ b/crates/registry-breg/tests/postgres_fixture_journeys.rs @@ -89,6 +89,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -101,6 +102,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: {type: list} @@ -112,6 +114,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -131,6 +134,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -142,6 +146,7 @@ journeys: accessProfile: operator claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -154,6 +159,7 @@ journeys: accessProfile: write-only-end claims: principal: fixture-operator + scopes: [fixture:write] purpose: case-management directClaims: {jurisdiction: zone-a} request: @@ -1638,6 +1644,7 @@ fn operator_token(idp: &MockIdp, purpose: bool) -> String { "registry_actor_kind": "service", "registry_principal": "fixture-operator", "jurisdiction": "zone-a", + "scope": "fixture:write", }); if purpose { claims["purpose"] = json!("case-management"); @@ -1847,7 +1854,7 @@ fn compiled_compare_constraint_fixture() -> (registry_breg::CompiledRegistry, Ve 1, ); let write_only_end = format!( - " write-only-end:\n principalClaim: registry_principal\n requiredScopes: unrestricted\n requiredPurposes: [case-management]\n permissions:\n records:\n - recordType: widget\n operations: [create]\n readableFields: [{fields}, valid-from]\n writableFields: [{fields}, valid-from, valid-to]\n rowBoundaries:\n - {{field: jurisdiction, claim: jurisdiction, operator: equals}}\n" + " write-only-end:\n principalClaim: registry_principal\n requiredScopes: [fixture:write]\n requiredPurposes: [case-management]\n permissions:\n records:\n - recordType: widget\n operations: [create]\n readableFields: [{fields}, valid-from]\n writableFields: [{fields}, valid-from, valid-to]\n rowBoundaries:\n - {{field: jurisdiction, claim: jurisdiction, operator: equals}}\n" ); assert!( project_source.contains("right: valid-to}") diff --git a/crates/registry-breg/tests/postgres_generated_identifier_batch_import.rs b/crates/registry-breg/tests/postgres_generated_identifier_batch_import.rs index e2f7de7a34..03a5f7510f 100644 --- a/crates/registry-breg/tests/postgres_generated_identifier_batch_import.rs +++ b/crates/registry-breg/tests/postgres_generated_identifier_batch_import.rs @@ -156,7 +156,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "generate":{"type":"sequence","prefix":"REG-","minimumDigits":4,"scope":["jurisdiction"]}} ] }}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"entry","operations":["create","get","batch"], @@ -232,7 +232,7 @@ fn writer_claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "registry_principal", "generated-identifier-writer", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-management".to_owned()), BTreeMap::from([( "jurisdiction".to_owned(), diff --git a/crates/registry-breg/tests/postgres_generated_identifiers.rs b/crates/registry-breg/tests/postgres_generated_identifiers.rs index 04919a98db..867b8714b7 100644 --- a/crates/registry-breg/tests/postgres_generated_identifiers.rs +++ b/crates/registry-breg/tests/postgres_generated_identifiers.rs @@ -49,7 +49,7 @@ fn registry_with_limits( "generate":{"type":"random","prefix":"R-","length":12}} ] }}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"sub","requiredScopes":"unrestricted", + "accessProfiles":{"writer": {"default":true,"principalClaim":"sub","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"entry","operations":["create","get"], "readableFields":["jurisdiction","issued-at","public-id","daily-id","receipt-code"], diff --git a/crates/registry-breg/tests/postgres_history_commit.rs b/crates/registry-breg/tests/postgres_history_commit.rs index 7202ae41ba..26d05fabb5 100644 --- a/crates/registry-breg/tests/postgres_history_commit.rs +++ b/crates/registry-breg/tests/postgres_history_commit.rs @@ -710,7 +710,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "accessProfiles":{"writer": { "default":true, "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"membership", diff --git a/crates/registry-breg/tests/postgres_history_erasure.rs b/crates/registry-breg/tests/postgres_history_erasure.rs index 3b5498ea4e..9fe237d6f8 100644 --- a/crates/registry-breg/tests/postgres_history_erasure.rs +++ b/crates/registry-breg/tests/postgres_history_erasure.rs @@ -2652,7 +2652,7 @@ async fn snapshot_client_http( let claims = registry_breg::api::VerifiedRequestClaims::authenticated( "registry_principal", "history-erasure-sdk-reader", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("operations".to_owned()), BTreeMap::new(), ) @@ -2692,7 +2692,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "accessProfiles":{"writer": { "default":true, "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"membership", diff --git a/crates/registry-breg/tests/postgres_history_migration.rs b/crates/registry-breg/tests/postgres_history_migration.rs index 2540a504f8..bb6c483b0b 100644 --- a/crates/registry-breg/tests/postgres_history_migration.rs +++ b/crates/registry-breg/tests/postgres_history_migration.rs @@ -987,7 +987,7 @@ fn module_bytes(variant: Variant) -> Vec { Variant::StatusRestricted => "restricted", }; format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"history-migration-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","required":true,"maximumLength":8,"classification":"internal"}},{{"id":"status","type":"string","required":true,"maximumLength":16,"classification":"{status_classification}"}}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list","revisions"],"revisionAccess":true,"readableFields":["code"],"writableFields":["code","status"]}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"history-migration-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","required":true,"maximumLength":8,"classification":"internal"}},{{"id":"status","type":"string","required":true,"maximumLength":16,"classification":"{status_classification}"}}],"accessProfiles":{{"reader":{{"requiredScopes":["records:write"],"rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list","revisions"],"revisionAccess":true,"readableFields":["code"],"writableFields":["code","status"]}}}}}}}}}}"# ) .into_bytes() } @@ -1209,7 +1209,7 @@ fn history_claims() -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "principal", "package-reader", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-review".to_owned()), BTreeMap::new(), ) diff --git a/crates/registry-breg/tests/postgres_history_rebaseline.rs b/crates/registry-breg/tests/postgres_history_rebaseline.rs index d8383e9089..0e6898302b 100644 --- a/crates/registry-breg/tests/postgres_history_rebaseline.rs +++ b/crates/registry-breg/tests/postgres_history_rebaseline.rs @@ -1339,7 +1339,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "accessProfiles":{"writer": { "default":true, "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"membership", diff --git a/crates/registry-breg/tests/postgres_hook_changes.rs b/crates/registry-breg/tests/postgres_hook_changes.rs index 3c8e4a11c4..b5d3a9b33e 100644 --- a/crates/registry-breg/tests/postgres_hook_changes.rs +++ b/crates/registry-breg/tests/postgres_hook_changes.rs @@ -175,7 +175,7 @@ fn hook_project_json( }} }}}}, "accessProfiles":{{"operator":{{ - "default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{{"records":[{{ "recordType":"case","operations":["create","get","list"], @@ -184,7 +184,7 @@ fn hook_project_json( "rowBoundaries":[{{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}}] }}]}} }},"case-hook":{{ - "principalClaim":"registry_principal","requiredScopes":"unrestricted", + "principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{{"actions":[{{ "action":"open-followup","operations":["invoke"], "targets":[{{"recordType":"followup","rowBoundaries":"unrestricted"}}], @@ -2466,6 +2466,90 @@ async fn real_postgres_a_hook_without_a_principal_compiles_and_delivers() { receiver.stop().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn real_postgres_hook_proposal_refuses_a_claim_bounded_action_target() { + let receiver = HttpsReceiver::start().await; + let hooks = format!( + "[{}]", + hook_json("case-created", true, PROPOSING_RHAI_HANDLER) + ); + let mut project_json: Value = serde_json::from_str(&hook_project_json( + &hooks, + "[]", + r#""results":["followup"]"#, + "", + )) + .expect("hook proposal fixture is JSON"); + + for bounded in [false, true] { + let target = &mut project_json["accessProfiles"]["case-hook"]["permissions"]["actions"][0] + ["targets"][0]; + assert_eq!(target["rowBoundaries"], json!("unrestricted")); + if bounded { + target["rowBoundaries"] = + json!([{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]); + } + let project = parse_project_json( + &serde_json::to_vec(&project_json).expect("hook proposal fixture serializes"), + ) + .expect("hook proposal fixture parses"); + let registry = compile_project_with_assets( + &project, + &[], + &[ + rhai_asset("scripts/open-followup.rhai", ACTION_HANDLER_SCRIPT), + rhai_asset("hooks/propose.rhai", PROPOSAL_HOOK_SCRIPT), + ], + CompileProfile::Authoring, + ) + .expect("hook proposal fixture compiles"); + + let setup = setup(registry, &receiver, false).await; + let mut mutation_client = setup + .pool + .get_for_test() + .await + .expect("runtime mutation connection is available"); + let event = create_case(&setup, &mut mutation_client, "boundary-control").await; + let delivery_id = single_delivery(&event).to_owned(); + drop(mutation_client); + + assert_eq!( + setup.service.deliver_once().await, + Ok(HookWorkOutcome::Delivered) + ); + let row = delivery_row(&setup, event.event_id, &delivery_id).await; + assert_eq!(row.state, "delivered"); + assert_eq!(row.attempt, 1); + assert_eq!( + row.message_digest.as_deref(), + Some(proposal_message_digest().as_slice()) + ); + if bounded { + assert_eq!(row.disposition.as_deref(), Some("refused")); + assert_eq!( + row.code.as_deref(), + Some("hook.proposal.boundaries-unsatisfiable") + ); + assert_eq!( + row.summary.as_deref(), + Some( + "The declared principal's grant carries row boundaries a hook holds no claims to satisfy." + ) + ); + assert_eq!(row.resulting_revision, None); + assert_eq!(record_count(&setup, "followup").await, 0); + } else { + assert_eq!(row.disposition.as_deref(), Some("applied")); + assert_eq!(row.code, None); + assert_eq!(row.resulting_revision, Some(1)); + assert_eq!(record_count(&setup, "followup").await, 1); + } + setup.teardown().await; + } + receiver.stop().await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn real_postgres_a_proposal_without_a_declared_principal_is_dead_lettered_readable() { let receiver = HttpsReceiver::start().await; diff --git a/crates/registry-breg/tests/postgres_immediate_actions.rs b/crates/registry-breg/tests/postgres_immediate_actions.rs index a0192c43a6..1cf907b3e4 100644 --- a/crates/registry-breg/tests/postgres_immediate_actions.rs +++ b/crates/registry-breg/tests/postgres_immediate_actions.rs @@ -3764,7 +3764,7 @@ const ACTION_PROJECT: &[u8] = br#"{ }, "household-seed-writer": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": { "records": [ { diff --git a/crates/registry-breg/tests/postgres_import_authority.rs b/crates/registry-breg/tests/postgres_import_authority.rs index 01c92288cf..8252b6010f 100644 --- a/crates/registry-breg/tests/postgres_import_authority.rs +++ b/crates/registry-breg/tests/postgres_import_authority.rs @@ -84,7 +84,7 @@ const FIXTURE: &str = r#"{ {"id":"label","type":"string","maximumLength":128,"required":true,"classification":"public"} ] }}, - "accessProfiles":{"loader": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"loader": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"widget","operations":["import"], "readableFields":["jurisdiction","label"],"writableFields":["jurisdiction","label"], @@ -98,7 +98,7 @@ const FIXTURE: &str = r#"{ "readableFields":["jurisdiction","label"],"writableFields":["jurisdiction","label"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"second-loader": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"second-loader": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"widget","operations":["import"], "readableFields":["jurisdiction","label"],"writableFields":["jurisdiction","label"], @@ -824,7 +824,7 @@ fn claims_for(principal: &str, jurisdiction: &str) -> VerifiedRequestClaims { VerifiedRequestClaims::authenticated( "registry_principal", principal, - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::from([( "jurisdiction".to_owned(), diff --git a/crates/registry-breg/tests/postgres_ingestion_contract.rs b/crates/registry-breg/tests/postgres_ingestion_contract.rs index fec00a774c..42c0fc68a8 100644 --- a/crates/registry-breg/tests/postgres_ingestion_contract.rs +++ b/crates/registry-breg/tests/postgres_ingestion_contract.rs @@ -520,7 +520,7 @@ fn claims_with( VerifiedRequestClaims::authenticated( "registry_principal", principal, - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-management".to_owned()), claims, ) @@ -555,7 +555,7 @@ fn fixture_registry(batch_maximum_bytes: u32) -> Arc VerifiedRequestClaims VerifiedRequestClaims::authenticated( "registry_principal", principal, - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-management".to_owned()), BTreeMap::from([( "jurisdiction".to_owned(), diff --git a/crates/registry-breg/tests/postgres_ingestion_runs.rs b/crates/registry-breg/tests/postgres_ingestion_runs.rs index ece016f939..cb188f06d0 100644 --- a/crates/registry-breg/tests/postgres_ingestion_runs.rs +++ b/crates/registry-breg/tests/postgres_ingestion_runs.rs @@ -3021,7 +3021,7 @@ fn timer_ingestion_registry_with_operations( .remove("service-editor") .expect("the future-activation example has a service-editor profile"); source["accessProfiles"]["operator"] = renamed; - source["accessProfiles"]["operator"]["requiredScopes"] = json!("unrestricted"); + source["accessProfiles"]["operator"]["requiredScopes"] = json!(["records:write"]); source["accessProfiles"]["operator"]["requiredPurposes"] = json!(["case-management"]); source["accessProfiles"]["operator"]["permissions"]["records"][0]["operations"] = json!(operations); @@ -5327,7 +5327,7 @@ fn operator_claims(principal: &str, jurisdiction: &str) -> VerifiedRequestClaims VerifiedRequestClaims::authenticated( "registry_principal", principal, - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), Some("case-management".to_owned()), BTreeMap::from([( "jurisdiction".to_owned(), @@ -5373,7 +5373,7 @@ const FIXTURE_HEAD: &str = r#"{ }},"#; const FIXTURE_TAIL: &str = r#" - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management","case-review"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","patch","batch"], @@ -5381,7 +5381,7 @@ const FIXTURE_TAIL: &str = r#" "writableFields":["jurisdiction","label","quantity"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"operator-minimal": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"operator-minimal": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","patch","batch"], @@ -5473,7 +5473,7 @@ fn patch_only_registry() -> Arc { {"id":"label","type":"string","maximumLength":128,"required":true,"classification":"public"} ] }}, - "accessProfiles":{"patcher": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"patcher": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{ "records":[ diff --git a/crates/registry-breg/tests/postgres_kernel.rs b/crates/registry-breg/tests/postgres_kernel.rs index fa28daf96f..48fe5db34b 100644 --- a/crates/registry-breg/tests/postgres_kernel.rs +++ b/crates/registry-breg/tests/postgres_kernel.rs @@ -790,7 +790,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "constraints":[{"type":"temporal-non-overlap","scopeFields":["authority"]}] }}, "accessProfiles":{"operator": {"default":true,"principalClaim":"principal", - "requiredScopes":"unrestricted","requiredPurposes":["registry-administration"], + "requiredScopes":["records:write"],"requiredPurposes":["registry-administration"], "permissions":{"records":[{"recordType":"entry","operations":["create","get","list","patch"], "readableFields":["authority","payload","valid-from","valid-to"], "writableFields":["authority","payload","valid-from","valid-to"], diff --git a/crates/registry-breg/tests/postgres_membership_access.rs b/crates/registry-breg/tests/postgres_membership_access.rs index 90dbadc100..23b65d599a 100644 --- a/crates/registry-breg/tests/postgres_membership_access.rs +++ b/crates/registry-breg/tests/postgres_membership_access.rs @@ -7,6 +7,27 @@ mod membership_fixture; #[allow(dead_code)] mod postgres_harness; +#[cfg(feature = "tooling")] +use registry_breg as breg_fixture_crate; +#[cfg(feature = "tooling")] +#[path = "support/membership_targets.rs"] +mod membership_targets; +#[cfg(feature = "tooling")] +#[path = "support/membership_write_journeys.rs"] +mod membership_write_journeys; +#[cfg(feature = "tooling")] +#[path = "support/membership_write_project.rs"] +mod membership_write_project; +#[cfg(feature = "tooling")] +#[path = "support/postgres_membership_writes.rs"] +mod postgres_membership_writes; +#[cfg(feature = "tooling")] +use registry_breg as breg; +#[cfg(feature = "tooling")] +#[path = "support/action_evidence_provider.rs"] +#[allow(dead_code)] +mod action_evidence_provider; + use axum::body::{to_bytes, Body}; use axum::http::{Method, Request, StatusCode}; use registry_breg::api::{ @@ -494,8 +515,12 @@ async fn real_postgres_membership_successors_match_fresh_install_when_added_chan managed_schema_fingerprint, reconcile_compiled_runtime_acl_for_test, }; let mut base = membership_fixture::source("facility"); - base["accessProfiles"]["member"]["permissions"]["records"][0]["membershipBoundaries"] = - json!([]); + base["accessProfiles"]["member"]["permissions"]["records"][0]["rowBoundaries"] = + json!("unrestricted"); + base["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("membership"); let mut previous = membership_fixture::compile(&base).unwrap(); let upgraded = postgres_harness::TestDatabase::create(1).await; let (migration, task) = upgraded.connect_migration().await; @@ -504,17 +529,25 @@ async fn real_postgres_membership_successors_match_fresh_install_when_added_chan .unwrap(); let guarded = membership_fixture::source("facility"); let mut changed = guarded.clone(); - changed["accessProfiles"]["member"]["permissions"]["records"][0]["membershipBoundaries"][0] - ["principalField"] = json!("private-note"); + changed["recordTypes"]["membership"]["membership"]["principal"] = json!("private-note"); for (stage, source) in [("added", guarded), ("changed", changed), ("removed", base)] { let candidate = membership_fixture::compile(&source).unwrap(); let changes = compiled_registry_change_set(&previous, &candidate, "prior-membership-package"); let plan = change_set_to_applicable_migration_plan(&changes) .expect("membership access changes produce compiler-owned successor DDL"); - assert!( - !plan.statements.is_empty(), - "{stage} helper change needs successor DDL" + let index_id = "entity.membership.membership.key-index"; + assert_eq!( + plan.statements + .iter() + .any(|statement| statement.id == index_id), + stage != "removed" + ); + assert_eq!( + plan.statements + .iter() + .any(|statement| statement.id == format!("{index_id}.drop")), + stage != "added" ); for statement in &plan.statements { migration @@ -553,3 +586,139 @@ async fn real_postgres_membership_successors_match_fresh_install_when_added_chan task.abort(); upgraded.cleanup().await; } + +#[tokio::test] +async fn real_postgres_pre_index_membership_successor_matches_fresh_catalog() { + use registry_breg::package::{ + change_set_to_applicable_migration_plan, compiled_registry_change_set_from_baseline, + CompiledRegistryMigrationBaseline, + }; + use registry_breg::postgres::{ + managed_schema_fingerprint, reconcile_compiled_runtime_acl_for_test, + }; + let candidate = membership_fixture::compile(&membership_fixture::source("facility")).unwrap(); + let mut baseline = CompiledRegistryMigrationBaseline::from_compiled("prior", &candidate); + baseline.generated_ddl_sha256 = + Some("sha256:88ce9380a31f7201ccda598870579c46fba1352db5598b0eb667bbb23bf68042".to_owned()); + let changes = compiled_registry_change_set_from_baseline(&baseline, &candidate, "prior"); + assert!(changes.changes.is_empty()); + let plan = change_set_to_applicable_migration_plan(&changes).unwrap(); + let upgraded = postgres_harness::TestDatabase::create(1).await; + let (migration, task) = upgraded.connect_migration().await; + install_compiled_schema(&migration, &candidate, &upgraded.runtime_role) + .await + .unwrap(); + // Model the pre-index installation precisely: retained helpers and policy + // definitions are already present in the predecessor, only the index is absent. + migration + .batch_execute("DROP INDEX registry_data.breg_membership_key_b9ee6c3037") + .await + .unwrap(); + for statement in &plan.statements { + migration + .batch_execute(&statement.sql) + .await + .unwrap_or_else(|error| { + panic!("compiler successor statement {}: {error}", statement.id) + }); + } + reconcile_compiled_runtime_acl_for_test(&migration, &candidate, &upgraded.runtime_role) + .await + .unwrap(); + let catalog = ExpectedManagedCatalog::compiled(&candidate); + let upgraded_fingerprint = + managed_schema_fingerprint(&migration, &upgraded.runtime_role, &catalog) + .await + .unwrap(); + let fresh = postgres_harness::TestDatabase::create(1).await; + let (fresh_migration, fresh_task) = fresh.connect_migration().await; + install_compiled_schema(&fresh_migration, &candidate, &fresh.runtime_role) + .await + .unwrap(); + let fresh_fingerprint = + managed_schema_fingerprint(&fresh_migration, &fresh.runtime_role, &catalog) + .await + .unwrap(); + assert_eq!(upgraded_fingerprint, fresh_fingerprint); + fresh_task.abort(); + fresh.cleanup().await; + task.abort(); + upgraded.cleanup().await; +} + +#[tokio::test] +async fn real_postgres_non_unique_membership_index_upgrades_to_the_unique_one() { + use registry_breg::package::{ + change_set_to_applicable_migration_plan, compiled_registry_change_set_from_baseline, + CompiledRegistryMigrationBaseline, + }; + use registry_breg::postgres::{ + managed_schema_fingerprint, reconcile_compiled_runtime_acl_for_test, + }; + let candidate = membership_fixture::compile(&membership_fixture::source("facility")).unwrap(); + let index = candidate + .ddl() + .statements + .iter() + .find(|statement| statement.id == "entity.membership.membership.key-index") + .unwrap(); + // A package from before the index was unique, compiled by an earlier + // compiler: its baseline carries a different generated DDL digest. + let mut baseline = CompiledRegistryMigrationBaseline::from_compiled("prior", &candidate); + baseline.generated_ddl_sha256 = + Some("sha256:88ce9380a31f7201ccda598870579c46fba1352db5598b0eb667bbb23bf68042".to_owned()); + let changes = compiled_registry_change_set_from_baseline(&baseline, &candidate, "prior"); + let plan = change_set_to_applicable_migration_plan(&changes).unwrap(); + let upgraded = postgres_harness::TestDatabase::create(1).await; + let (migration, task) = upgraded.connect_migration().await; + install_compiled_schema(&migration, &candidate, &upgraded.runtime_role) + .await + .unwrap(); + // Replace the unique index with the earlier non-unique one of the same + // name, as the predecessor installed it. + let earlier = index.sql.replacen("CREATE UNIQUE INDEX", "CREATE INDEX", 1); + assert_ne!(earlier, index.sql); + migration + .batch_execute(&format!( + "DROP INDEX registry_data.breg_membership_key_b9ee6c3037; {earlier}" + )) + .await + .unwrap(); + for statement in &plan.statements { + migration + .batch_execute(&statement.sql) + .await + .unwrap_or_else(|error| panic!("successor statement {}: {error}", statement.id)); + } + reconcile_compiled_runtime_acl_for_test(&migration, &candidate, &upgraded.runtime_role) + .await + .unwrap(); + let unique: bool = migration + .query_one( + "SELECT indisunique FROM pg_index WHERE indexrelid = 'registry_data.breg_membership_key_b9ee6c3037'::regclass", + &[], + ) + .await + .unwrap() + .get(0); + assert!(unique, "the successor rebuilds the index as unique"); + let catalog = ExpectedManagedCatalog::compiled(&candidate); + let upgraded_fingerprint = + managed_schema_fingerprint(&migration, &upgraded.runtime_role, &catalog) + .await + .unwrap(); + let fresh = postgres_harness::TestDatabase::create(1).await; + let (fresh_migration, fresh_task) = fresh.connect_migration().await; + install_compiled_schema(&fresh_migration, &candidate, &fresh.runtime_role) + .await + .unwrap(); + let fresh_fingerprint = + managed_schema_fingerprint(&fresh_migration, &fresh.runtime_role, &catalog) + .await + .unwrap(); + assert_eq!(upgraded_fingerprint, fresh_fingerprint); + fresh_task.abort(); + fresh.cleanup().await; + task.abort(); + upgraded.cleanup().await; +} diff --git a/crates/registry-breg/tests/postgres_migration.rs b/crates/registry-breg/tests/postgres_migration.rs index 81691101f7..ef99d7ed9d 100644 --- a/crates/registry-breg/tests/postgres_migration.rs +++ b/crates/registry-breg/tests/postgres_migration.rs @@ -179,6 +179,84 @@ async fn subject_access_log_storage_survives_disabled_collection() { database.cleanup().await; } +/// A database a release before the Proposal subject wrote has no +/// `subject_reference` column. Applying a successor package installs it in +/// place and keeps every existing Proposal, with no subject bound. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn a_successor_adds_the_proposal_subject_column_in_place() { + let database = TestDatabase::create(1).await; + let (prior, fingerprint, active, _initial) = + activate_without_access_log_collection(&database).await; + let existing = Uuid::new_v4(); + database + .admin + .execute( + "INSERT INTO registry_internal.registry_proposal_state + (action_id, proposal_id, owner_reference, state, submission_version, workflow_revision) + VALUES ('earlier-action', $1, 'earlier-owner', 'cancelled', 1, 1)", + &[&existing], + ) + .await + .unwrap(); + database + .admin + .batch_execute( + "DROP INDEX registry_internal.registry_proposal_subject; + ALTER TABLE registry_internal.registry_proposal_state DROP COLUMN subject_reference;", + ) + .await + .unwrap(); + + let successor = publish_and_load( + prepare_package(build_request( + Variant::SubjectWithLog, + Some(&active.package_digest), + &fingerprint, + PackageMigrationPlanInput::Successor { + prior_registry: Box::new(prior), + }, + )) + .unwrap(), + local_context(), + ); + let upgraded = apply( + &database, + &successor, + ApplyPrecondition::Successor { current: &active }, + ) + .await + .expect("a successor installs the subject column over an earlier catalog"); + assert_ready_target(&database, &upgraded).await; + let row = database + .admin + .query_one( + "SELECT subject_reference, to_regclass('registry_internal.registry_proposal_subject') IS NOT NULL + FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&existing], + ) + .await + .unwrap(); + assert_eq!(row.get::<_, Option>(0), None); + assert!( + row.get::<_, bool>(1), + "the partial subject index is installed" + ); + let constrained: bool = database + .admin + .query_one( + "SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_constraint + WHERE conrelid = 'registry_internal.registry_proposal_state'::regclass + AND contype = 'c' + AND pg_get_constraintdef(oid) LIKE '%subject_reference%')", + &[], + ) + .await + .unwrap() + .get(0); + assert!(constrained, "an empty subject reference is refused"); + database.cleanup().await; +} + /// Every activation installs the subject access-log storage, so a catalog /// without it is not one an activation left behind. The catalog check refuses /// it for a Registry that collects no log exactly as for one that does, and @@ -5314,6 +5392,11 @@ enum Variant { EncryptedSharedLookup, /// `EncryptedSharedLookup` with `nfc` added to its list. EncryptedSharedNfcLookup, + /// A `link` Record type shaped like a membership source, without the + /// declaration. + MembershipFields, + /// `MembershipFields` declaring `link` as a membership source. + MembershipDeclared, } #[derive(Clone, Copy)] @@ -5650,6 +5733,29 @@ fn project_bytes(digest: &str) -> Vec { } fn module_bytes(variant: Variant) -> Vec { + if matches!( + variant, + Variant::MembershipFields | Variant::MembershipDeclared + ) { + let mut source: serde_json::Value = + serde_json::from_slice(&module_bytes(Variant::Base)).unwrap(); + let mut link = serde_json::json!({ + "primaryDataset":"migration-registry","route":"links","mutationMode":"mutable", + "fields":[ + {"id":"asset","type":"reference","target":"asset","classification":"internal"}, + {"id":"principal","type":"string","maximumLength":32,"classification":"internal"}, + {"id":"active","type":"boolean","classification":"internal"} + ], + "accessProfiles":{"reader":{"requiredScopes":["records:write"],"rowBoundaries":"unrestricted", + "principalClaim":"principal","operations":["get"],"readableFields":["asset"]}} + }); + if matches!(variant, Variant::MembershipDeclared) { + link["membership"] = + serde_json::json!({"key":"asset","principal":"principal","active":"active"}); + } + source["recordTypes"]["link"] = link; + return serde_json::to_vec(&source).unwrap(); + } if matches!( variant, Variant::SubjectWithoutLog | Variant::SubjectWithLog @@ -5731,7 +5837,7 @@ fn module_bytes(variant: Variant) -> Vec { _ => "", }; format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"migration-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}},{{"id":"rank","type":"int64","classification":"internal"{rank_required}}}{legacy}{batch}{secret}{alias}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"asset":{{"primaryDataset":"migration-registry","route":"assets","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}},{{"id":"rank","type":"int64","classification":"internal"{rank_required}}}{legacy}{batch}{secret}{alias}],"accessProfiles":{{"reader":{{"requiredScopes":["records:write"],"rowBoundaries":"unrestricted","principalClaim":"principal","operations":["create","get","list"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# ) .into_bytes() } @@ -9462,3 +9568,103 @@ async fn assert_digests_follow_successor(scenario: &ReindexScenario, secrets: &[ .collect::>(); assert_eq!(distinct.len(), secrets.iter().flatten().count()); } + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn duplicate_live_membership_rows_refuse_the_unique_index_by_name_until_repaired() { + let database = TestDatabase::create(1).await; + let fields = compile_variant(Variant::MembershipFields); + let declared = compile_variant(Variant::MembershipDeclared); + let fields_fp = initial_fingerprint(&database, &fields).await; + let declared_fp = initial_fingerprint(&database, &declared).await; + let initial = prepare_and_load_initial_variant(Variant::MembershipFields, &fields, &fields_fp); + let active = apply(&database, &initial, ApplyPrecondition::InitialActivation) + .await + .unwrap(); + let assets = quote(&fields.entities()["asset"].physical_table); + let link = &fields.entities()["link"]; + let table = quote(&link.physical_table); + let column = |field: &str| quote(&link.fields[field].physical_name); + let asset = Uuid::from_u128(71); + database + .admin + .execute( + &format!("INSERT INTO registry_data.{assets} (record_id, active_package_revision) VALUES ($1, $2)"), + &[&asset, &active.activation_id], + ) + .await + .unwrap(); + // Two live rows for one key and principal, written before the source was + // declared, and a third that is inactive. + for (id, live) in [(72_u128, true), (73, true), (74, false)] { + database + .admin + .execute( + &format!( + "INSERT INTO registry_data.{table} (record_id, {}, {}, {}, active_package_revision) VALUES ($1, $2, $3, $4, $5)", + column("asset"), column("principal"), column("active") + ), + &[&Uuid::from_u128(id), &asset, &"person-a", &live, &active.activation_id], + ) + .await + .unwrap(); + } + let prepared = prepare_package(build_request( + Variant::MembershipDeclared, + Some(&active.package_digest), + &declared_fp, + PackageMigrationPlanInput::Successor { + prior_registry: Box::new(fields.clone()), + }, + )) + .unwrap(); + let successor = publish_and_load(prepared, local_context()); + assert_value_free( + apply( + &database, + &successor, + ApplyPrecondition::Successor { current: &active }, + ) + .await + .err(), + MigrationError::MembershipDuplicateLiveRows { + entity_id: "link".to_owned(), + }, + ); + assert_non_ready_target(&database, &active, &successor, "failed").await; + database + .admin + .execute( + &format!( + "UPDATE registry_data.{table} SET {} = false WHERE record_id = $1", + column("active") + ), + &[&Uuid::from_u128(73)], + ) + .await + .unwrap(); + let active = apply( + &database, + &successor, + ApplyPrecondition::Successor { current: &active }, + ) + .await + .expect("repaired rows admit the exact pinned successor"); + assert_ready_target(&database, &active).await; + // The index now refuses a second live row for the same key and principal. + let error = database + .admin + .execute( + &format!( + "UPDATE registry_data.{table} SET {} = true WHERE record_id = $1", + column("active") + ), + &[&Uuid::from_u128(74)], + ) + .await + .unwrap_err(); + assert_eq!( + error.code(), + Some(&tokio_postgres::error::SqlState::UNIQUE_VIOLATION) + ); + database.cleanup().await; +} diff --git a/crates/registry-breg/tests/postgres_mutation.rs b/crates/registry-breg/tests/postgres_mutation.rs index 4e33efb16f..1c860ce21e 100644 --- a/crates/registry-breg/tests/postgres_mutation.rs +++ b/crates/registry-breg/tests/postgres_mutation.rs @@ -1813,7 +1813,7 @@ async fn real_postgres_row_local_constraint_problems_name_only_readable_declarat {"id":"valid-to","type":"date","validTimeRole":"valid-to","classification":"public"} ] }}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","requiredPurposes":["case-management"], + "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"],"requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"window","operations":["create","get","patch","batch"], "readableFields":["jurisdiction","label","valid-from","valid-to","score","status"], @@ -1825,7 +1825,7 @@ async fn real_postgres_row_local_constraint_problems_name_only_readable_declarat "writableFields":["jurisdiction","scope","valid-from","valid-to"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"write-only-end": {"principalClaim":"registry_principal","requiredScopes":"unrestricted","requiredPurposes":["case-management"], + },"write-only-end": {"principalClaim":"registry_principal","requiredScopes":["records:write"],"requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"window","operations":["create"], "readableFields":["jurisdiction","label","valid-from","score","status"], @@ -2230,7 +2230,10 @@ async fn real_postgres_http_mutations_are_guarded_and_exactly_replayable() { BREG_SEC_13_PRINCIPAL_CANARY, "case-management", Some(BREG_SEC_13_ZONE_CANARY), - BTreeSet::from(["breg-sec-13-scope-canary".to_owned()]), + BTreeSet::from([ + "records:write".to_owned(), + "breg-sec-13-scope-canary".to_owned(), + ]), ); let operator_openapi = body_json( @@ -3888,7 +3891,7 @@ fn row_boundary_batch_registry() -> registry_breg::CompiledRegistry { {"id":"quantity","type":"int64","required":true,"classification":"public"} ] }}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","list","patch","batch"], @@ -3920,7 +3923,7 @@ fn located_refusal_registry() -> registry_breg::CompiledRegistry { {"id":"secret","type":"string","maximumLength":128,"required":false,"classification":"public"} ] }}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"writer": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","list","patch","batch"], @@ -3930,7 +3933,7 @@ fn located_refusal_registry() -> registry_breg::CompiledRegistry { "sortableFields":["label"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"keeper": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"keeper": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-review"], "permissions":{"records":[{ "recordType":"widget","operations":["get","list","patch"], @@ -3940,7 +3943,7 @@ fn located_refusal_registry() -> registry_breg::CompiledRegistry { "sortableFields":["secret"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"drafter": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"drafter": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-drafting"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get"], @@ -4726,7 +4729,12 @@ fn header_string(headers: &axum::http::HeaderMap, name: &str) -> String { } fn api_claims(purpose: &str, zone: Option<&str>) -> VerifiedRequestClaims { - api_claims_with_principal_and_scopes(PRINCIPAL_CANARY, purpose, zone, BTreeSet::new()) + api_claims_with_principal_and_scopes( + PRINCIPAL_CANARY, + purpose, + zone, + BTreeSet::from(["records:write".to_owned()]), + ) } fn api_claims_with_principal_and_scopes( @@ -4782,7 +4790,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { {"id":"name","type":"string","maximumLength":128,"required":true,"classification":"public"} ] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management","case-review"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","list","patch","tombstone"], @@ -4790,7 +4798,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "writableFields":["jurisdiction","label","note","quantity"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"review-operator": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"review-operator": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["create","get","list","patch","tombstone"], @@ -4804,7 +4812,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "readableFields":["label"], "rowBoundaries": "unrestricted" }]} - },"label-editor": {"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"label-editor": {"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"widget","operations":["get","patch"], @@ -4812,7 +4820,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "writableFields":["label"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"case-operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + },"case-operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"log","operations":["create","get","list"], @@ -6167,7 +6175,7 @@ fn linked_registry() -> registry_breg::CompiledRegistry { "externalViews":{"local-with-subject": {"recordType":"local-record", "links":[{"id":"subject","projection":"approved-subjects","fromField":"subjectkey"}] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["local-consultation"], "permissions":{"records":[{ "recordType":"local-record","operations":["create","get","list","patch"], diff --git a/crates/registry-breg/tests/postgres_mutation_logical_names.rs b/crates/registry-breg/tests/postgres_mutation_logical_names.rs index 1b38090d4b..8f6f4385fc 100644 --- a/crates/registry-breg/tests/postgres_mutation_logical_names.rs +++ b/crates/registry-breg/tests/postgres_mutation_logical_names.rs @@ -15,7 +15,7 @@ use serde_json::{json, Value}; #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn real_postgres_mutations_use_only_governed_api_field_names() { let harness = PilotHarness::start("asset-site-placement").await; - let token = harness.token("asset-management", &[]); + let token = harness.token_with_scopes("asset-management", &[], &["asset:manage"]); let created = harness .send_json( diff --git a/crates/registry-breg/tests/postgres_native_retention.rs b/crates/registry-breg/tests/postgres_native_retention.rs index 7d3de18076..ae1d7e05e0 100644 --- a/crates/registry-breg/tests/postgres_native_retention.rs +++ b/crates/registry-breg/tests/postgres_native_retention.rs @@ -80,7 +80,7 @@ fn registry_source(automatic: bool) -> Value { "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], "proposals":[{"action":"correct-name","operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", + "party":"owner","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}); source } diff --git a/crates/registry-breg/tests/postgres_package.rs b/crates/registry-breg/tests/postgres_package.rs index 0f8ca3c5fe..0344099d50 100644 --- a/crates/registry-breg/tests/postgres_package.rs +++ b/crates/registry-breg/tests/postgres_package.rs @@ -3657,7 +3657,7 @@ fn module_bytes(plan: PlanChoice) -> Vec { plan, PlanChoice::SecondTable | PlanChoice::ThirdTable | PlanChoice::HookSecondTable ) { - r#","second-record":{"primaryDataset":"neutral-registry","route":"second-records","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"}],"accessProfiles":{"writer": {"principalClaim":"principal","operations":["get","create"],"readableFields":["code"],"writableFields":["code"], "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}"# + r#","second-record":{"primaryDataset":"neutral-registry","route":"second-records","mutationMode":"create-only","fields":[{"id":"code","type":"string","maximumLength":8,"classification":"internal"}],"accessProfiles":{"writer": {"principalClaim":"principal","operations":["get","create"],"readableFields":["code"],"writableFields":["code"], "requiredScopes":["records:write"],"rowBoundaries":"unrestricted"}}}"# } else { "" }; diff --git a/crates/registry-breg/tests/postgres_package/compiler_upgrade.rs b/crates/registry-breg/tests/postgres_package/compiler_upgrade.rs index b2423b1968..c277e4f9e9 100644 --- a/crates/registry-breg/tests/postgres_package/compiler_upgrade.rs +++ b/crates/registry-breg/tests/postgres_package/compiler_upgrade.rs @@ -601,7 +601,7 @@ fn indexed_module_bytes(other: OtherEntity) -> Vec { OtherEntity::Unchanged | OtherEntity::GainsAField => "second-records", }; format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"neutral-record":{{"primaryDataset":"neutral-registry","route":"neutral-records","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}],"indexes":[{{"id":"code-idx","fields":["code"]}}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["get","list"],"readableFields":["code"]}}}}}},"second-record":{{"primaryDataset":"neutral-registry","route":"{route}","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}{added}],"accessProfiles":{{"writer":{{"principalClaim":"principal","operations":["get","create"],"readableFields":["code"],"writableFields":["code"],"requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"neutral-record":{{"primaryDataset":"neutral-registry","route":"neutral-records","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}],"indexes":[{{"id":"code-idx","fields":["code"]}}],"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["get","list"],"readableFields":["code"]}}}}}},"second-record":{{"primaryDataset":"neutral-registry","route":"{route}","mutationMode":"create-only","fields":[{{"id":"code","type":"string","maximumLength":8,"classification":"internal"}}{added}],"accessProfiles":{{"writer":{{"principalClaim":"principal","operations":["get","create"],"readableFields":["code"],"writableFields":["code"],"requiredScopes":["records:write"],"rowBoundaries":"unrestricted"}}}}}}}}}}"# ) .into_bytes() } diff --git a/crates/registry-breg/tests/postgres_package/migration_capacity.rs b/crates/registry-breg/tests/postgres_package/migration_capacity.rs index dcc543c86f..199798ec32 100644 --- a/crates/registry-breg/tests/postgres_package/migration_capacity.rs +++ b/crates/registry-breg/tests/postgres_package/migration_capacity.rs @@ -98,7 +98,7 @@ fn reviewed_flow_project(profile_count: usize, proposal_operations: &[&str]) -> json!({ "action": format!("review-flow-{flow}"), "operations": proposal_operations, - "ownership": "caller", + "party": "owner", "readableInputs": readable_inputs, "targets": targets }) diff --git a/crates/registry-breg/tests/postgres_package/policy_upgrade.rs b/crates/registry-breg/tests/postgres_package/policy_upgrade.rs index 9bcb6df60b..a7dd783bab 100644 --- a/crates/registry-breg/tests/postgres_package/policy_upgrade.rs +++ b/crates/registry-breg/tests/postgres_package/policy_upgrade.rs @@ -19,7 +19,7 @@ async fn ordinary_profile_removal_applies_and_matches_fresh_catalog() { async fn ordinary_profile_operation_narrowing_applies_and_matches_fresh_catalog() { assert_profile_successor( Some(json!({ - "principalClaim": "principal", "requiredScopes":"unrestricted","rowBoundaries":"unrestricted", + "principalClaim": "principal", "requiredScopes":["records:write"],"rowBoundaries":"unrestricted", "operations": ["create"], "writableFields": ["code", "note"] })), ProfileSuccessor::Compiler, @@ -31,7 +31,7 @@ async fn ordinary_profile_operation_narrowing_applies_and_matches_fresh_catalog( async fn ordinary_profile_create_revocation_applies_and_matches_fresh_catalog() { assert_profile_successor( Some(json!({ - "principalClaim": "principal", "requiredScopes":"unrestricted","rowBoundaries":"unrestricted", + "principalClaim": "principal", "requiredScopes":["records:write"],"rowBoundaries":"unrestricted", "operations": ["get", "list"], "readableFields": ["code", "note"] })), ProfileSuccessor::Compiler, @@ -43,7 +43,7 @@ async fn ordinary_profile_create_revocation_applies_and_matches_fresh_catalog() async fn ordinary_profile_field_narrowing_applies_and_matches_fresh_catalog() { assert_profile_successor( Some(json!({ - "principalClaim": "principal", "requiredScopes":"unrestricted","rowBoundaries":"unrestricted", + "principalClaim": "principal", "requiredScopes":["records:write"],"rowBoundaries":"unrestricted", "operations": ["create", "get", "list"], "writableFields": ["code", "note"], "readableFields": ["code"] })), @@ -294,14 +294,14 @@ fn proposal_policy_sources(add_submitter: bool, add_optional_field: bool) -> (Ve json!({"casework-main": {"protocol": "id.registrystack.org/protocols/review/v1"}}); let profile = |id: &str, default: bool| { json!({ - id: {"default": default, "principalClaim": "principal", "requiredScopes": "unrestricted", + id: {"default": default, "principalClaim": "principal", "requiredScopes": ["proposals:write"], "permissions": { "records": [{"recordType": "asset", "operations": ["get", "list"], "readableFields": ["label"], "rowBoundaries": "unrestricted"}], "actions": [{"action": "correct-label", "operations": ["start"], "targets": [{"recordType": "asset", "rowBoundaries": "unrestricted"}]}], "proposals": [{"action": "correct-label", "operations": ["get", "list", "submit"], - "readableInputs": ["asset", "label"], "ownership": "caller", + "readableInputs": ["asset", "label"], "party": "owner", "targets": [{"recordType": "asset", "rowBoundaries": "unrestricted"}]}] }} }) @@ -391,7 +391,7 @@ pub(super) async fn fresh_fingerprint(registry: ®istry_breg::model::CompiledR async fn assert_profile_successor(auditor: Option, kind: ProfileSuccessor) { let baseline_bytes = profile_module(Some(json!({ - "principalClaim": "principal", "requiredScopes":"unrestricted","rowBoundaries":"unrestricted", + "principalClaim": "principal", "requiredScopes":["records:write"],"rowBoundaries":"unrestricted", "operations": ["create", "get", "list"], "writableFields": ["code", "note"], "readableFields": ["code", "note"] }))); diff --git a/crates/registry-breg/tests/postgres_package/reference_upgrade.rs b/crates/registry-breg/tests/postgres_package/reference_upgrade.rs index 53b1b09f3e..702d2f6bcd 100644 --- a/crates/registry-breg/tests/postgres_package/reference_upgrade.rs +++ b/crates/registry-breg/tests/postgres_package/reference_upgrade.rs @@ -970,7 +970,7 @@ fn reference_module_bytes(target: Option<&str>) -> Vec { ) }); format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"site":{{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":"unrestricted","rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}},"location":{{"primaryDataset":"neutral-registry","route":"locations","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":"unrestricted","rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}},"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}{reference_field}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":"unrestricted","rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"site":{{"primaryDataset":"neutral-registry","route":"sites","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":["records:write"],"rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}},"location":{{"primaryDataset":"neutral-registry","route":"locations","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":["records:write"],"rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}},"asset":{{"primaryDataset":"neutral-registry","route":"assets","mutationMode":"mutable","fields":[{{"id":"code","type":"string","maximumLength":16,"classification":"internal"}}{reference_field}],"accessProfiles":{{"reader":{{"principalClaim":"principal","requiredScopes":["records:write"],"rowBoundaries":"unrestricted","operations":["create","get","list","patch"],"readableFields":["code"],"writableFields":["code"]}}}}}}}}}}"# ) .into_bytes() } diff --git a/crates/registry-breg/tests/postgres_pilot_acceptance.rs b/crates/registry-breg/tests/postgres_pilot_acceptance.rs index 2fd37ea10a..c39a19ec01 100644 --- a/crates/registry-breg/tests/postgres_pilot_acceptance.rs +++ b/crates/registry-breg/tests/postgres_pilot_acceptance.rs @@ -38,9 +38,9 @@ async fn real_postgres_five_domain_pilot_is_configured_production_closed_and_sou } async fn asset_site_placement_journey(harness: &PilotHarness) { - let token = harness.token("asset-management", &[]); + let token = harness.token_with_scopes("asset-management", &[], &["asset:manage"]); assert_fixture_surface(harness, "asset-operator", &token, "asset").await; - let planner_token = harness.token("site-planning", &[]); + let planner_token = harness.token_with_scopes("site-planning", &[], &["asset:plan"]); let planner_openapi = assert_fixture_surface(harness, "site-planner", &planner_token, "asset").await; assert!(planner_openapi["paths"] @@ -414,7 +414,7 @@ async fn establishments_journey(harness: &PilotHarness) { } async fn inspection_journey(harness: &PilotHarness) { - let token = harness.token("facility-inspection", &[]); + let token = harness.token_with_scopes("facility-inspection", &[], &["inspection:manage"]); let openapi = assert_fixture_surface(harness, "inspection-inspector", &token, "inspection").await; assert_eq!( @@ -592,13 +592,15 @@ async fn inspection_journey(harness: &PilotHarness) { } async fn facility_journey(harness: &PilotHarness) { - let north_token = harness.token( + let north_token = harness.token_with_scopes( "facility-registry", &[("administrative_boundaries", json!(["north-district"]))], + &["registry:facility:operate"], ); - let south_token = harness.token( + let south_token = harness.token_with_scopes( "facility-registry", &[("administrative_boundaries", json!(["south-district"]))], + &["registry:facility:operate"], ); let openapi = assert_fixture_surface(harness, "facility-operator", &north_token, "facility").await; @@ -851,7 +853,7 @@ async fn facility_journey(harness: &PilotHarness) { } async fn business_journey(harness: &PilotHarness) { - let token = harness.token("business-registry", &[]); + let token = harness.token_with_scopes("business-registry", &[], &["business:register"]); assert_fixture_surface(harness, "business-registrar", &token, "business").await; let legal_entity = create_record( harness, diff --git a/crates/registry-breg/tests/postgres_proposal.rs b/crates/registry-breg/tests/postgres_proposal.rs index e1efb0d9d8..c24c9f9594 100644 --- a/crates/registry-breg/tests/postgres_proposal.rs +++ b/crates/registry-breg/tests/postgres_proposal.rs @@ -4,6 +4,10 @@ #[path = "support/client_http.rs"] #[allow(dead_code)] mod client_http; +#[path = "support/membership_fixture.rs"] +mod membership_fixture; +#[path = "support/membership_write_project.rs"] +mod membership_write_project; #[path = "support/postgres_harness.rs"] #[allow(dead_code)] mod postgres_harness; @@ -134,7 +138,7 @@ fn registry_source(automatic: bool) -> Value { "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], "proposals":[{"action":"correct-name","operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", + "party":"owner","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}); source } @@ -638,7 +642,7 @@ async fn proposal_list_scans_hidden_rows_without_exposing_their_continuation() { source["accessProfiles"]["clerk"]["permissions"]["proposals"][0] .as_object_mut() .unwrap() - .remove("ownership"); + .remove("party"); let fixture = client_http::ClientFixture::start(compile(source), claims("author", "zone-a")).await; let mut drafts = Vec::new(); @@ -2597,6 +2601,223 @@ async fn proposal_list_audit_counts_only_each_actions_returned_items() { fixture.finish().await; } +#[tokio::test] +async fn proposal_list_correlates_membership_filtered_page_with_its_journal() { + let registry = membership_fixture::compile(&membership_write_project::proposal_project()) + .unwrap_or_else(|_| panic!("the maintained membership Proposal fixture must compile")); + let human = |principal, scopes| { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + principal, + scopes, + None, + BTreeMap::from([( + "sub".into(), + VerifiedClaimValue::direct_string(principal).unwrap(), + )]), + registry_platform_oidc::ActorKind::Human, + ) + .expect("fixture claims are valid") + }; + let fixture = + client_http::ClientFixture::start(registry, human("member", BTreeSet::new())).await; + let steward = fixture + .client_for(human( + "steward", + BTreeSet::from(["records:manage".into(), "membership:use".into()]), + )) + .await; + let member = &fixture.http.client; + let metadata = member + .registry_contract(Some("member")) + .await + .unwrap_or_else(|_| panic!("member metadata must be available")); + let action = metadata + .value + .select_action("propose-facility", "member") + .expect("member can start a facility Proposal"); + + let http = reqwest::Client::new(); + let create = async |route: &str, body: Value, idempotency_key: String| { + let response = http + .post(format!( + "{}/v1/records/{route}?accessProfile=steward", + steward.base_url + )) + .header("idempotency-key", idempotency_key) + .json(&body) + .send() + .await + .unwrap_or_else(|_| panic!("steward create request failed")); + assert!(response.status() == reqwest::StatusCode::CREATED); + let etag = response.headers().get("etag").cloned(); + let body: Value = response + .json() + .await + .unwrap_or_else(|_| panic!("steward create response must be JSON")); + let id = body["data"]["recordId"] + .as_str() + .expect("steward create returns a Record identifier") + .to_owned(); + (id, etag) + }; + let mut submitted = Vec::new(); + for index in 0..3 { + let (organization, _) = create( + "organizations", + json!({"data":{"name":format!("List organization {index}"),"owner":"member"}}), + format!("list-organization-{index}"), + ) + .await; + let (membership, etag) = create( + "memberships", + json!({"data":{"organization":organization,"principal":"member","active":true}}), + format!("list-membership-{index}"), + ) + .await; + let input = BRegActionInvocationRequest::new( + &action, + map(json!({"organization":organization,"label":format!("List facility {index}")})), + None, + ) + .unwrap_or_else(|_| panic!("fixture inputs must match the Action")); + let draft = member + .start_proposal(&action, &input, &key(&format!("list-start-{index}"))) + .await + .unwrap_or_else(|_| panic!("member must be able to start with active membership")) + .value; + let submit = member + .prepare_proposal( + &draft, + "submit", + json!({}), + &key(&format!("list-submit-{index}")), + ) + .unwrap_or_else(|_| panic!("member must be able to prepare submission")); + let proposal = member + .execute_proposal(&submit) + .await + .unwrap_or_else(|_| panic!("member must be able to submit with active membership")) + .value; + submitted.push((proposal.id().to_owned(), membership, etag)); + } + // The omitted candidate must sort between the returned item and the visible + // lookahead, so one bounded request necessarily scans all three candidates. + submitted.sort_by(|left, right| left.0.cmp(&right.0)); + let (first, _, _) = &submitted[0]; + let (_, membership, etag) = &submitted[1]; + let response = http + .patch(format!( + "{}/v1/records/memberships/{membership}?accessProfile=steward", + steward.base_url + )) + .header("content-type", "application/json-patch+json") + .header( + "if-match", + etag.clone().expect("membership create returns an ETag"), + ) + .header("idempotency-key", "list-withdraw-membership") + .json(&json!([{"op":"replace","path":"/data/active","value":false}])) + .send() + .await + .unwrap_or_else(|_| panic!("steward membership update request failed")); + assert!(response.status() == reqwest::StatusCode::OK); + + let before = fixture.audit_capture.entries().len(); + let response = http + .get(format!( + "{}/v1/proposals?accessProfile=member&limit=1", + fixture.http.base_url + )) + .send() + .await + .unwrap_or_else(|_| panic!("member list request failed")); + assert!(response.status() == reqwest::StatusCode::OK); + let trace_id = response + .headers() + .get("traceparent") + .and_then(|header| header.to_str().ok()) + .and_then(|header| header.split('-').nth(1)) + .expect("successful list returns a trace ID") + .to_owned(); + let page: Value = response + .json() + .await + .unwrap_or_else(|_| panic!("successful list response must be JSON")); + let items = page["items"].as_array().expect("list has an items array"); + assert_eq!(items.len(), 1); + assert!(items[0]["id"].as_str() == Some(first.as_str())); + let cursor = page["nextCursor"].as_str().expect("list has a next cursor"); + assert_eq!(cursor, first.as_str()); + + let entries = fixture.audit_capture.entries(); + let list_entries = &entries[before..]; + assert_eq!( + list_entries.len(), + 4, + "two attempts and two terminal records" + ); + let request_id = list_entries[0]["correlation"] + .as_str() + .expect("list attempt has a request correlation"); + assert!(uuid::Uuid::parse_str(request_id).is_ok()); + for entry in list_entries { + let record = &entry["record"]; + assert!(entry["correlation"].as_str() == Some(request_id)); + assert!(record["requestId"].as_str() == Some(request_id)); + assert!(record["traceId"].as_str() == Some(trace_id.as_str())); + } + for (action, count, outcome) in [ + ("propose-facility", 1, "returned"), + ("propose-move", 0, "empty"), + ] { + let operation = format!("proposals.{action}.list"); + for (phase, envelope_phase) in [("attempt", "request"), ("terminal", "response")] { + let matching = list_entries + .iter() + .filter(|entry| { + let record = &entry["record"]; + entry["phase"] == envelope_phase + && record["phase"] == phase + && record["method"] == "GET" + && record["operationId"].as_str() == Some(operation.as_str()) + && record["actionId"] == action + && (phase == "attempt" + || (record["resultCount"].as_u64() == Some(count) + && record["outcome"] == outcome)) + }) + .count(); + assert_eq!(matching, 1, "one {phase} journal record for {action}"); + } + } + + let response = http + .get(format!( + "{}/v1/proposals?accessProfile=member&limit=1&cursor={cursor}", + fixture.http.base_url + )) + .send() + .await + .unwrap_or_else(|_| panic!("member continuation request failed")); + assert_eq!(response.status(), reqwest::StatusCode::OK); + let page: Value = response + .json() + .await + .unwrap_or_else(|_| panic!("successful continuation response must be JSON")); + let items = page["items"] + .as_array() + .expect("continuation has an items array"); + assert_eq!(items.len(), 1); + assert_eq!(items[0]["id"].as_str(), Some(submitted[2].0.as_str())); + assert!( + page.get("nextCursor").is_none(), + "the visible list is exhausted" + ); + + drop(steward); + fixture.finish().await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn manual_no_review_attachments_cas_concealment_and_exact_receipt() { let fixture = client_http::ClientFixture::start( @@ -9592,7 +9813,7 @@ async fn standing_officer_grant_revises_only_named_inputs_and_withdraws_exact_re source["actions"]["correct-name"]["execution"]["proposal"]["review"] = json!({"type":"required","authority":"local-review","source":"proposal-test","policy":{"id":"name-correction","version":"1","digest":format!("sha256:{}","b".repeat(64))}}); source["accessProfiles"]["officer"]["requiredScopes"] = json!(["proposal:officer"]); let grant = &mut source["accessProfiles"]["officer"]["permissions"]["proposals"][0]; - grant.as_object_mut().unwrap().remove("ownership"); + grant.as_object_mut().unwrap().remove("party"); grant["writableInputs"] = json!(["value"]); let review = std::sync::Arc::new(LocalReview { calls: 0.into(), diff --git a/crates/registry-breg/tests/postgres_proposal_generated_identifiers.rs b/crates/registry-breg/tests/postgres_proposal_generated_identifiers.rs index c217ce5152..26f85b2e74 100644 --- a/crates/registry-breg/tests/postgres_proposal_generated_identifiers.rs +++ b/crates/registry-breg/tests/postgres_proposal_generated_identifiers.rs @@ -133,13 +133,13 @@ fn registry() -> registry_breg::CompiledRegistry { ], "proposals":[ {"action":"register-target", - "operations":["get","submit","revise","retry","apply"],"ownership":"caller", + "operations":["get","submit","revise","retry","apply"],"party":"owner", "readableInputs":["name","jurisdiction"], "targets":[{"recordType":"target","rowBoundaries":[{ "field":"jurisdiction","claim":"jurisdiction","operator":"equals" }]}]}, {"action":"register-target-with-document", - "operations":["get","edit","submit"],"ownership":"caller", + "operations":["get","edit","submit"],"party":"owner", "readableInputs":["name","jurisdiction"], "readableAttachments":["support"],"writableAttachments":["support"], "targets":[{"recordType":"target","rowBoundaries":[{ diff --git a/crates/registry-breg/tests/postgres_proposal_guard_failure.rs b/crates/registry-breg/tests/postgres_proposal_guard_failure.rs index e15f63fb62..41e95ec6e1 100644 --- a/crates/registry-breg/tests/postgres_proposal_guard_failure.rs +++ b/crates/registry-breg/tests/postgres_proposal_guard_failure.rs @@ -105,7 +105,7 @@ fn guard_project(readable: &[&str], offset: Option<(&str, i32)>) -> Value { "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], "proposals":[{"action":"correct-name","operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableInputs":["target","value","minimum"],"targets":[{"recordType":"target", + "party":"owner","readableInputs":["target","value","minimum"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}); if let Some((member, offset)) = offset { source["project"]["timezone"] = json!("UTC"); diff --git a/crates/registry-breg/tests/postgres_proposal_human_recovery.rs b/crates/registry-breg/tests/postgres_proposal_human_recovery.rs index 1b5ff1016e..eeea94d223 100644 --- a/crates/registry-breg/tests/postgres_proposal_human_recovery.rs +++ b/crates/registry-breg/tests/postgres_proposal_human_recovery.rs @@ -42,7 +42,7 @@ fn registry(automatic: bool) -> registry_breg::CompiledRegistry { "records":[{"recordType":"contact","operations":["create","get"],"readableFields":["name","jurisdiction"], "writableFields":["name","jurisdiction"],"rowBoundaries":boundary}], "actions":[{"action":"correct-name","operations":["start"],"targets":targets}], - "proposals":[{"action":"correct-name","operations":["get","submit","apply","retry"],"ownership":"caller","targets":targets}]}}} + "proposals":[{"action":"correct-name","operations":["get","submit","apply","retry"],"party":"owner","targets":targets}]}}} }); compile_project( &parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(), diff --git a/crates/registry-breg/tests/postgres_proposal_recovery_permissions.rs b/crates/registry-breg/tests/postgres_proposal_recovery_permissions.rs index 8461c30e35..fd51988a42 100644 --- a/crates/registry-breg/tests/postgres_proposal_recovery_permissions.rs +++ b/crates/registry-breg/tests/postgres_proposal_recovery_permissions.rs @@ -109,7 +109,7 @@ fn registry_source() -> Value { "proposals":[{ "action":"correct-name", "operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableInputs":["target","value"], + "party":"owner","readableInputs":["target","value"], "targets":[{ "recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] diff --git a/crates/registry-breg/tests/postgres_proposal_review_delivery.rs b/crates/registry-breg/tests/postgres_proposal_review_delivery.rs index 1b35c0c96b..476ce5819a 100644 --- a/crates/registry-breg/tests/postgres_proposal_review_delivery.rs +++ b/crates/registry-breg/tests/postgres_proposal_review_delivery.rs @@ -440,7 +440,7 @@ fn registry_source(selection: Value) -> Value { "accessProfiles":{"clerk": {"default":true,"principalClaim":"sub","requiredScopes":["proposal:manage"],"requiredPurposes":["registry-administration"],"permissions":{ "records":[{"recordType":"target","operations":["create","get","list"],"readableFields":["name","jurisdiction"],"writableFields":["name","jurisdiction"],"rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}], "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target","rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], - "proposals":[{"action":"correct-name","operations":["get","list","submit","cancel","get-review-status"],"ownership":"caller","targets":[{"recordType":"target","rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}) + "proposals":[{"action":"correct-name","operations":["get","list","submit","cancel","get-review-status"],"party":"owner","targets":[{"recordType":"target","rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}) } async fn fixture(authority: &Authority) -> client_http::ClientFixture { let bindings = authority.registry.clone(); diff --git a/crates/registry-breg/tests/postgres_proposal_s3.rs b/crates/registry-breg/tests/postgres_proposal_s3.rs index 8716d0b9c1..9e2c007507 100644 --- a/crates/registry-breg/tests/postgres_proposal_s3.rs +++ b/crates/registry-breg/tests/postgres_proposal_s3.rs @@ -82,7 +82,7 @@ fn registry_source(automatic: bool) -> Value { "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], "proposals":[{"action":"correct-name","operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", + "party":"owner","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}); source } diff --git a/crates/registry-breg/tests/postgres_proposal_security.rs b/crates/registry-breg/tests/postgres_proposal_security.rs index 8446fbf8aa..761fc97e59 100644 --- a/crates/registry-breg/tests/postgres_proposal_security.rs +++ b/crates/registry-breg/tests/postgres_proposal_security.rs @@ -37,10 +37,12 @@ fn source(membership: bool) -> Value { let mut reader = json!({"recordType":"target","operations":["get","list"],"readableFields":["name"], "rowBoundaries":[{"field":"jurisdiction","claim":"recordJurisdiction","operator":"equals"}]}); if membership { - reader["membershipBoundaries"] = json!([{"field":"organization","membershipRecordType":"membership", - "membershipKeyField":"organization","principalField":"principal","activeField":"active"}]); + reader["rowBoundaries"] + .as_array_mut() + .unwrap() + .push(json!({"field":"organization","membership":"membership"})); } - let source = json!({"apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + let mut source = json!({"apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", "project":{"id":"proposal-security","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://proposal.example.test"}, "datasets":{"directory": {}},"recordTypes":{ "organization": {"primaryDataset":"directory","route":"organizations","mutationMode":"mutable", @@ -69,16 +71,38 @@ fn source(membership: bool) -> Value { {"recordType":"target","operations":["create","get"],"readableFields":["name","jurisdiction","organization"], "writableFields":["name","jurisdiction","organization"],"rowBoundaries":boundary}], "actions":[{"action":"correct-name","operations":["start"],"targets":targets}], - "proposals":[{"action":"correct-name","operations":["get","edit","submit","cancel"],"ownership":"caller","readableInputs":["target","value"],"targets":targets}]}}, + "proposals":[{"action":"correct-name","operations":["get","edit","submit","cancel"],"party":"owner","readableInputs":["target","value"],"targets":targets}]}}, "task-reviewer": {"principalClaim":"registry_principal","actorKind":"agent","requesterClients":["agent-client"], "requiredScopes":["proposal:manage"],"requiredPurposes":["registry-administration"], "taskGrant":{"sourceIssuer":"https://casework.example"},"permissions":{"records":[reader], "actions":[{"action":"correct-name","operations":["start"],"targets":targets}], "proposals":[{"action":"correct-name","operations":["get","edit","submit","get-review-context"], - "ownership":"caller","readableInputs":["target","value"],"readableContextFields":["currentName","proposedName"],"targets":targets}]}}}}); + "party":"owner","readableInputs":["target","value"],"readableContextFields":["currentName","proposedName"],"targets":targets}]}}}}); + if membership { + source["recordTypes"]["membership"]["membership"] = + json!({"key":"organization","principal":"principal","active":"active"}); + separate_membership_admin(&mut source); + } source } +/// A profile bounded through `membership` cannot also write it, so a +/// separate administrator with the same token keeps the membership rows. +fn separate_membership_admin(source: &mut Value) { + let records = source["accessProfiles"]["clerk"]["permissions"]["records"] + .as_array_mut() + .unwrap(); + let position = records + .iter() + .position(|grant| grant["recordType"] == "membership") + .unwrap(); + let grant = records.remove(position); + source["accessProfiles"]["membership-admin"] = json!({ + "principalClaim":"registry_principal","requiredScopes":["proposal:manage"], + "requiredPurposes":["registry-administration"],"permissions":{"records":[grant]} + }); +} + fn compile(source: Value) -> registry_breg::CompiledRegistry { compile_project( &parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(), @@ -106,6 +130,21 @@ fn clerk() -> VerifiedRequestClaims { .unwrap() } +fn human_clerk() -> VerifiedRequestClaims { + VerifiedRequestClaims::authenticated_with_actor_kind( + "registry_principal", + "author", + BTreeSet::from(["proposal:manage".into()]), + Some("registry-administration".into()), + BTreeMap::from([( + "jurisdiction".into(), + VerifiedClaimValue::direct_string("zone-a").unwrap(), + )]), + registry_platform_oidc::ActorKind::Human, + ) + .unwrap() +} + struct Status { active: AtomicBool, calls: AtomicUsize, @@ -189,11 +228,24 @@ async fn send( (status, response.json().await.unwrap(), etag) } +/// Membership rows are written by their administrator, everything else by +/// the clerk. +fn record_profile(route: &str) -> &'static str { + if route == "memberships" { + "membership-admin" + } else { + "clerk" + } +} + async fn create(http: &client_http::ClientHttp, route: &str, data: Value, key: &str) -> String { let (status, value, _) = send( http, Method::POST, - &format!("/v1/records/{route}?accessProfile=clerk"), + &format!( + "/v1/records/{route}?accessProfile={}", + record_profile(route) + ), json!({"data":data}), Some(key), None, @@ -221,6 +273,25 @@ async fn seed(fixture: &client_http::ClientFixture) -> (String, String) { (organization, target) } +async fn set_membership_active(http: &client_http::ClientHttp, membership: &str, active: bool) { + let path = format!("/v1/records/memberships/{membership}?accessProfile=membership-admin"); + let (code, _, etag) = send(http, Method::GET, &path, Value::Null, None, None).await; + assert_eq!(code, StatusCode::OK); + let response = reqwest::Client::new() + .patch(format!("{}{path}", http.base_url)) + .header("content-type", "application/json-patch+json") + .header("if-match", etag.unwrap()) + .header( + "idempotency-key", + format!("membership-{membership}-{active}"), + ) + .json(&json!([{"op":"replace","path":"/data/active","value":active}])) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn signed_proposal_start_and_lifecycle_receipts_reject_sibling_grants() { let status = Arc::new(Status { @@ -1160,7 +1231,7 @@ async fn explicit_service_assessment_preserves_scope_actor_target_and_record_dis service["permissions"]["proposals"][0] .as_object_mut() .unwrap() - .remove("ownership"); + .remove("party"); let mut human = service.clone(); human["actorKind"] = json!("human"); let mut narrow = service.clone(); @@ -1887,9 +1958,9 @@ async fn applicant_progress_rechecks_withdrawal_and_audit_before_release() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn review_status_service_reads_only_its_exact_frozen_review_binding() { - let mut source = source(false); - let proposal_targets = - source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["targets"].clone(); + let mut source = source(true); + source["actions"]["correct-name"]["execution"]["proposal"]["reviewContext"]["fields"] + ["changes"] = json!({"type":"changes","recordType":"target","fields":["name"]}); source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["operations"] = json!([ "get", "edit", @@ -1899,7 +1970,7 @@ async fn review_status_service_reads_only_its_exact_frozen_review_binding() { "get-review-context" ]); source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["readableContextFields"] = - json!(["currentName", "proposedName"]); + json!(["changes", "currentName", "proposedName"]); source["reviewAuthorities"] = json!({"casework": {"protocol":"id.registrystack.org/protocols/review/v1"}}); source["actions"]["correct-name"]["execution"]["proposal"]["review"] = json!({"type":"required","authority":"casework","source":"proposal-security", @@ -1910,15 +1981,18 @@ async fn review_status_service_reads_only_its_exact_frozen_review_binding() { "reviewAuthority":"casework","operations":["get-review-status"]}]}})); source["accessProfiles"].as_object_mut().unwrap().insert("task-context".to_owned(), json!({"principalClaim":"registry_principal", "actorKind":"service","requesterClients":["agent-client"],"requiredScopes":["proposal:task-context"], - "requiredPurposes":["registry-administration"],"permissions":{"proposals":[{"action":"correct-name", - "operations":["get","get-task-grant-context"],"ownership":"caller", - "readableContextFields":["proposedName"],"targets":proposal_targets}]}})); + "requiredPurposes":["registry-administration"],"permissions":{"records":[{ + "recordType":"target","operations":["get"],"readableFields":["name"],"rowBoundaries":"unrestricted" + }],"proposals":[{"action":"correct-name", + "operations":["get","get-task-grant-context"],"party":"owner", + "readableContextFields":["changes","currentName","proposedName"], + "targets":[{"recordType":"target","rowBoundaries":[{"field":"organization","membership":"membership"}]}]}]}})); let fixture = client_http::ClientFixture::start_with_mutations(compile(source), clerk(), |service| { service.with_review_result_source(review_binding()) }) .await; - let (_, target) = seed(&fixture).await; + let (organization, target) = seed(&fixture).await; let (code, draft, etag) = send( &fixture.http, Method::POST, @@ -2098,11 +2172,11 @@ async fn review_status_service_reads_only_its_exact_frozen_review_binding() { fixture.database.admin.execute("UPDATE registry_internal.registry_proposal_review_submissions SET authority='casework',create_request=$1,expected_policy=$2,expected_submission_digest=$3", &[&stored,&policy,&digest]).await.unwrap(); } - let create: registry_review_client::ReviewCreateRequest = + let create_request: registry_review_client::ReviewCreateRequest = serde_json::from_value(stored).unwrap(); let accepted = registry_review_client::ReviewRequestAccepted { request_id: uuid::Uuid::new_v4(), - subject: create.subject, + subject: create_request.subject, policy: serde_json::from_value(policy).unwrap(), submission_digest: registry_review_client::SubmissionDigest::parse(&digest).unwrap(), }; @@ -2128,6 +2202,13 @@ async fn review_status_service_reads_only_its_exact_frozen_review_binding() { let task_binding = metadata .select_proposal_task_grant_context("task-context", "correct-name") .unwrap(); + let membership = create( + &fixture.http, + "memberships", + json!({"organization":organization,"principal":"review-service","active":true}), + "task-context-membership", + ) + .await; let typed_task_request: registry_breg_client::BRegProposalTaskContextRequest = serde_json::from_value(task_request.clone()).unwrap(); let task_document = task_service @@ -2141,6 +2222,63 @@ async fn review_status_service_reads_only_its_exact_frozen_review_binding() { task_document.proposal.context.fields.unwrap(), BTreeMap::from([("proposedName".into(), json!("Proposed"))]) ); + let record_path = format!("/v1/records/targets/{target}?accessProfile=task-context"); + let context_fields = [ + ("currentName", json!("current-name-canary")), + ( + "changes", + json!([{"recordId":target,"operation":"patch", + "before":{"name":"current-name-canary"},"after":{"name":"Proposed"}}]), + ), + ]; + for (field, expected_value) in &context_fields { + let mut selected = task_request.clone(); + selected["fields"] = json!([field]); + let selected = serde_json::from_value(selected).unwrap(); + let document = task_service + .client + .read_proposal_task_grant_context(&task_binding, &selected) + .await + .unwrap() + .value; + assert_eq!(document.request, selected); + assert_eq!( + document.proposal.context.fields.unwrap(), + BTreeMap::from([(field.to_string(), expected_value.clone())]) + ); + } + set_membership_active(&fixture.http, &membership, false).await; + assert_eq!( + send( + &task_service, + Method::GET, + &record_path, + Value::Null, + None, + None + ) + .await + .0, + StatusCode::OK, + "the ordinary Record grant is independent of the Proposal target scope" + ); + for (field, _) in context_fields { + let mut selected = task_request.clone(); + selected["fields"] = json!([field]); + let (code, problem, _) = send( + &task_service, + Method::POST, + &task_path, + selected, + None, + None, + ) + .await; + assert_eq!(code, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + assert!(problem.get("proposal").is_none()); + } + set_membership_active(&fixture.http, &membership, true).await; let mut substituted_request = task_request.clone(); substituted_request["requestId"] = json!(uuid::Uuid::new_v4()); let (code, value, _) = send( @@ -2647,6 +2785,734 @@ async fn frozen_changes_inspection_covers_patch_and_create_without_applying_or_r fixture.finish().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn review_context_checks_each_frozen_membership_and_saved_document() { + let mut project = source(true); + let profiles = project["accessProfiles"].as_object_mut().unwrap(); + profiles.remove("task-reviewer"); + let clerk_permissions = &mut profiles.get_mut("clerk").unwrap()["permissions"]; + clerk_permissions["actions"][0]["targets"] + .as_array_mut() + .unwrap() + .push(json!({"recordType":"organization","rowBoundaries":"unrestricted"})); + clerk_permissions["proposals"][0]["targets"] + .as_array_mut() + .unwrap() + .push(json!({"recordType":"organization","rowBoundaries":"unrestricted"})); + clerk_permissions["proposals"][0]["operations"] + .as_array_mut() + .unwrap() + .push(json!("apply")); + clerk_permissions["proposals"][0]["readableInputs"] + .as_array_mut() + .unwrap() + .push(json!("destination")); + clerk_permissions["proposals"][0]["writableAttachments"] = json!(["support"]); + profiles.insert("member-review".into(), json!({ + "principalClaim":"registry_principal","actorKind":"human", + "requiredScopes":["proposal:manage"],"requiredPurposes":["registry-administration"], + "permissions":{ + "records":[{"recordType":"target","operations":["get"], + "readableFields":["name"],"rowBoundaries":"unrestricted"}], + "proposals":[{"action":"correct-name","operations":["get-review-context"], + "readableContextFields":["changes","currentName","document"],"targets":[ + {"recordType":"target","rowBoundaries":[{"field":"organization","membership":"membership"}]}, + {"recordType":"organization","rowBoundaries":"unrestricted"} + ]}] + } + })); + let action = &mut project["actions"]["correct-name"]; + action["inputs"].as_array_mut().unwrap().push(json!({ + "id":"destination","type":"reference","target":"organization","required":true, + "classification":"internal" + })); + action["plan"]["effects"][0]["set"]["organization"] = json!({"fromInput":"destination"}); + let proposal = &mut action["execution"]["proposal"]; + proposal["attachments"] = json!([ + {"id":"support","required":false,"maximumBytes":64,"contentTypes":["text/plain"],"classification":"restricted"} + ]); + proposal["reviewContext"]["fields"] = json!({ + "changes":{"type":"changes","recordType":"target","fields":["name"]}, + "currentName":{"type":"record","input":"target","field":"name"}, + "document":{"type":"document","slot":"support"} + }); + let fixture = client_http::ClientFixture::start(compile(project), human_clerk()).await; + let (origin, target) = seed(&fixture).await; + let destination = create( + &fixture.http, + "organizations", + json!({"name":"Destination"}), + "destination", + ) + .await; + let original_membership = create( + &fixture.http, + "memberships", + json!({"organization":origin,"principal":"author","active":true}), + "original-membership", + ) + .await; + let destination_membership = create( + &fixture.http, + "memberships", + json!({"organization":destination,"principal":"author","active":true}), + "destination-membership", + ) + .await; + let (status, draft, etag) = send( + &fixture.http, + Method::POST, + "/v1/actions/correct-name/proposals?accessProfile=clerk", + json!({"input":{"target":target,"value":"Proposed","destination":destination}}), + Some("start-move"), + None, + ) + .await; + assert_eq!(status, StatusCode::CREATED); + let id = draft["id"].as_str().unwrap(); + let support = format!("/v1/proposals/{id}/attachments/support?accessProfile=clerk"); + let response = reqwest::Client::new() + .patch(format!("{}{support}", fixture.http.base_url)) + .header("content-type", "text/plain") + .header("if-match", etag.unwrap()) + .header("idempotency-key", "move-document") + .body("Synthetic review document") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let (status, submitted, etag) = send( + &fixture.http, + Method::POST, + &format!("/v1/proposals/{id}/submit?accessProfile=clerk"), + json!({}), + Some("submit-move"), + response.headers()["etag"].to_str().ok(), + ) + .await; + assert_eq!(status, StatusCode::OK); + + let scalar = format!("/v1/proposals/{id}/review-context?accessProfile=member-review"); + let batch = format!("/v1/proposals/review-context?accessProfile=member-review&ids={id}"); + let (status, context, _) = + send(&fixture.http, Method::GET, &scalar, Value::Null, None, None).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(context["effectDigest"], submitted["effectDigest"]); + assert_eq!( + context["context"]["fields"]["currentName"], + "current-name-canary" + ); + assert_eq!( + context["context"]["fields"]["changes"], + json!([{ + "recordId":target,"operation":"patch","before":{"name":"current-name-canary"},"after":{"name":"Proposed"} + }]) + ); + let (status, page, _) = send(&fixture.http, Method::GET, &batch, Value::Null, None, None).await; + assert_eq!(status, StatusCode::OK); + assert_eq!( + page, + json!({"items":[{"id":id,"status":"visible","context":context}]}) + ); + let saved = context["context"]["fields"]["document"]["download"]["path"] + .as_str() + .unwrap(); + let download = format!( + "{}{saved}&accessProfile=member-review", + fixture.http.base_url + ); + let http = reqwest::Client::new(); + let response = http.get(&download).send().await.unwrap(); + assert_eq!(response.status(), StatusCode::OK); + assert!(response.bytes().await.unwrap().as_ref() == b"Synthetic review document"); + + for (membership, apply_after) in [ + (&destination_membership, true), + (&original_membership, false), + ] { + set_membership_active(&fixture.http, membership, false).await; + let (status, problem, _) = + send(&fixture.http, Method::GET, &scalar, Value::Null, None, None).await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + assert!(problem.get("context").is_none()); + let (status, page, _) = + send(&fixture.http, Method::GET, &batch, Value::Null, None, None).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(page, json!({"items":[{"id":id,"status":"concealed"}]})); + let response = http.get(&download).send().await.unwrap(); + assert_eq!(response.status(), StatusCode::NOT_FOUND); + assert_eq!( + response.json::().await.unwrap()["code"], + "resource.not-found" + ); + if apply_after { + set_membership_active(&fixture.http, membership, true).await; + let (status, value, _) = send( + &fixture.http, Method::POST, &format!("/v1/proposals/{id}/apply?accessProfile=clerk"), + json!({"submissionVersion":submitted["submissionVersion"],"effectDigest":submitted["effectDigest"]}), + Some("apply-move"), etag.as_deref() + ).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(value["state"], "applied"); + assert_eq!( + send(&fixture.http, Method::GET, &scalar, Value::Null, None, None) + .await + .0, + StatusCode::OK + ); + } + } + fixture.finish().await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn attachment_membership_accounting_requires_accepted_refusal_audit() { + use axum::{ + body::{to_bytes, Body}, + http::Request, + }; + use registry_breg::metrics::{metrics_app, Metrics}; + use registry_platform_config::Posture; + use tower::ServiceExt as _; + + // Isolate the process-wide counter from other tests in this target. + const CHILD: &str = "BREG_TEST_ATTACHMENT_MEMBERSHIP_ACCOUNTING_CHILD"; + const TEST: &str = "attachment_membership_accounting_requires_accepted_refusal_audit"; + if std::env::var_os(CHILD).is_none() { + let result = std::process::Command::new(std::env::current_exe().unwrap()) + .args(["--exact", TEST]) + .env(CHILD, "1") + .output() + .unwrap(); + assert!( + result.status.success() + && String::from_utf8_lossy(&result.stdout).contains("1 passed; 0 failed"), + "isolated attachment accounting check failed" + ); + return; + } + + async fn membership_refusals() -> u64 { + let response = metrics_app( + Arc::new(Metrics::without_pool_for_test()), + Posture::Production, + ) + .oneshot( + Request::builder() + .uri("/metrics") + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + let body = to_bytes(response.into_body(), 4 * 1024 * 1024) + .await + .unwrap(); + std::str::from_utf8(&body) + .unwrap() + .lines() + .find_map(|line| { + line.strip_prefix("breg_request_refusals_total{check=\"membership\"} ") + }) + .expect("membership refusal counter is present") + .parse() + .expect("membership refusal counter is numeric") + } + + let mut project = source(true); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("task-reviewer"); + // A submitted Create checks membership against the frozen after-image. + // Loading an existing target can return a generic 412 before that probe. + let action = &mut project["actions"]["correct-name"]; + action.as_object_mut().unwrap().remove("commitGuards"); + action["inputs"][0] = json!({"id":"organization","type":"reference","target":"organization", + "required":true,"classification":"internal"}); + action["plan"]["effects"] = json!([{ + "id":"record","target":{"recordType":"target"},"operation":"create", + "set":{"name":{"fromInput":"value"},"jurisdiction":{"value":"zone-a"}, + "organization":{"fromInput":"organization"}} + }]); + let proposal = &mut action["execution"]["proposal"]; + proposal["reviewContext"]["fields"] = json!({"proposedName":{"type":"input","input":"value"}}); + proposal["attachments"] = json!([ + {"id":"support","required":false,"maximumBytes":64, + "contentTypes":["text/plain"],"classification":"restricted"} + ]); + let permissions = &mut project["accessProfiles"]["clerk"]["permissions"]; + let mut targets = permissions["actions"][0]["targets"].clone(); + targets[0]["rowBoundaries"] + .as_array_mut() + .unwrap() + .push(json!({"field":"organization","membership":"membership"})); + targets + .as_array_mut() + .unwrap() + .push(json!({"recordType":"organization","rowBoundaries":"unrestricted"})); + permissions["actions"][0]["targets"] = targets.clone(); + let grant = &mut permissions["proposals"][0]; + grant["readableInputs"] = json!(["organization", "value"]); + grant["writableAttachments"] = json!(["support"]); + grant["targets"] = targets; + + for method in [Method::PATCH, Method::DELETE] { + let fixture = client_http::ClientFixture::start(compile(project.clone()), clerk()).await; + let organization = create( + &fixture.http, + "organizations", + json!({"name":"Unit"}), + "organization", + ) + .await; + let membership = create( + &fixture.http, + "memberships", + json!({"organization":organization,"principal":"author","active":true}), + "attachment-accounting-membership", + ) + .await; + let (status, draft, etag) = send( + &fixture.http, + Method::POST, + "/v1/actions/correct-name/proposals?accessProfile=clerk", + json!({"input":{"organization":organization,"value":"Proposed"}}), + Some("attachment-accounting-start"), + None, + ) + .await; + assert_eq!(status, StatusCode::CREATED); + let id = draft["id"].as_str().unwrap(); + let (status, _, etag) = send( + &fixture.http, + Method::POST, + &format!("/v1/proposals/{id}/submit?accessProfile=clerk"), + json!({}), + Some("attachment-accounting-submit"), + etag.as_deref(), + ) + .await; + assert_eq!(status, StatusCode::OK); + let etag = etag.unwrap(); + set_membership_active(&fixture.http, &membership, false).await; + let url = format!( + "{}/v1/proposals/{id}/attachments/support?accessProfile=clerk", + fixture.http.base_url + ); + let http = reqwest::Client::new(); + for (reject_audit, expected_status, expected_code, expected_delta) in [ + ( + false, + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + 1, + ), + ( + true, + StatusCode::SERVICE_UNAVAILABLE, + "source.unavailable", + 0, + ), + ] { + let before_count = membership_refusals().await; + let before_entries = fixture.audit_capture.entries().len(); + let before_rejections = fixture.audit_capture.matched_refusal_count(); + if reject_audit { + fixture + .audit_capture + .fail_on(registry_breg::audit::AUDIT_SCHEMA, "refusal"); + } + let request = http + .request(method.clone(), &url) + .header("if-match", etag.as_str()) + .header( + "idempotency-key", + format!("attachment-accounting-{reject_audit}"), + ); + let request = if method == Method::PATCH { + request + .header("content-type", "text/plain") + .body("Synthetic document") + } else { + request + }; + let response = request.send().await.unwrap(); + assert_eq!(response.status(), expected_status, "{method}"); + let problem: Value = response.json().await.unwrap(); + assert_eq!(problem["code"], expected_code, "{method}"); + assert!(problem.get("failedCheck").is_none(), "{method}"); + assert!(problem.get("guardReason").is_none(), "{method}"); + let accepted = fixture.audit_capture.entries()[before_entries..] + .iter() + .any(|entry| { + entry["record"]["phase"] == "refusal" + && entry["record"]["method"] == method.as_str() + }); + let rejected = fixture.audit_capture.matched_refusal_count() > before_rejections; + assert_eq!( + (accepted, rejected), + (!reject_audit, reject_audit), + "{method}" + ); + assert_eq!( + membership_refusals().await - before_count, + expected_delta, + "{method}" + ); + } + fixture.finish().await; + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn submitted_create_membership_controls_attachments_answers_and_commands() { + let mut project = source(true); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("task-reviewer"); + project["reviewAuthorities"] = + json!({"casework":{"protocol":"id.registrystack.org/protocols/review/v1"}}); + let action = &mut project["actions"]["correct-name"]; + action.as_object_mut().unwrap().remove("commitGuards"); + action["inputs"][0] = json!({"id":"organization","type":"reference","target":"organization", + "required":true,"classification":"internal"}); + action["plan"]["effects"] = json!([{ + "id":"record","target":{"recordType":"target"},"operation":"create", + "set":{"name":{"fromInput":"value"},"jurisdiction":{"value":"zone-a"}, + "organization":{"fromInput":"organization"}} + }]); + let proposal = &mut action["execution"]["proposal"]; + proposal["review"] = json!({"type":"required","authority":"casework","source":"proposal-security", + "policy":{"id":"name-correction","version":"1","digest":format!("sha256:{}","b".repeat(64))}}); + proposal["reviewContext"]["fields"] = json!({"proposedName":{"type":"input","input":"value"}}); + proposal["attachments"] = json!([ + {"id":"support","required":false,"maximumBytes":64,"contentTypes":["text/plain"],"classification":"restricted"} + ]); + proposal["additions"] = json!({"id":"other","maximumBytes":64,"maximumCount":3, + "contentTypes":["text/plain"],"classification":"restricted"}); + let permissions = &mut project["accessProfiles"]["clerk"]["permissions"]; + let targets = json!([ + {"recordType":"target","rowBoundaries":[{"field":"organization","membership":"membership"}]}, + {"recordType":"organization","rowBoundaries":"unrestricted"} + ]); + permissions["actions"][0]["targets"] = targets.clone(); + permissions["proposals"][0] = json!({ + "action":"correct-name","party":"owner","targets":targets, + "operations":["get","list","get-review-context","get-review-status","edit","submit","revise","rebase","cancel","retry","answer","add"], + "readableInputs":["organization","value"],"readableContextFields":["proposedName"], + "readableAttachments":["support","other"],"writableAttachments":["support","other"] + }); + project["accessProfiles"]["task-context"] = json!({ + "principalClaim":"registry_principal","actorKind":"service","requesterClients":["agent-client"], + "requiredScopes":["proposal:task-context"],"requiredPurposes":["registry-administration"], + "permissions":{"proposals":[{"action":"correct-name","operations":["get-task-grant-context"], + "readableContextFields":["proposedName"],"targets":targets}]} + }); + let fixture = client_http::ClientFixture::start_with_mutations( + compile(project), + human_clerk(), + |service| service.with_review_result_source(review_binding()), + ) + .await; + let organization = create( + &fixture.http, + "organizations", + json!({"name":"Unit"}), + "attachment-unit", + ) + .await; + let membership = create( + &fixture.http, + "memberships", + json!({"organization":organization,"principal":"author","active":true}), + "attachment-membership", + ) + .await; + let input = json!({"organization":organization,"value":"Proposed"}); + let (status, draft, etag) = send( + &fixture.http, + Method::POST, + "/v1/actions/correct-name/proposals?accessProfile=clerk", + json!({"input":input}), + Some("start-attachments"), + None, + ) + .await; + assert_eq!(status, StatusCode::CREATED); + let id = uuid::Uuid::parse_str(draft["id"].as_str().unwrap()).unwrap(); + let base = format!("/v1/proposals/{id}"); + let attachment = format!("{base}/attachments/support?accessProfile=clerk"); + let addition_upload = format!("{base}/additions/other?accessProfile=clerk"); + let http = reqwest::Client::new(); + let document = |method: Method, path: &str, key: &str, etag: &str| { + let sends_bytes = method != Method::DELETE; + let request = http + .request(method, format!("{}{path}", fixture.http.base_url)) + .header("if-match", etag) + .header("idempotency-key", key); + if sends_bytes { + request + .header("content-type", "text/plain") + .body("Synthetic document") + } else { + request + } + }; + let mut etag = etag.unwrap(); + for (method, key) in [ + (Method::PATCH, "attach-draft-file"), + (Method::DELETE, "remove-draft-file"), + (Method::PATCH, "restore-draft-file"), + ] { + let response = document(method, &attachment, key, &etag) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + etag = response.headers()["etag"].to_str().unwrap().to_owned(); + } + let (status, _, submitted_etag) = send( + &fixture.http, + Method::POST, + &format!("{base}/submit?accessProfile=clerk"), + json!({}), + Some("submit-attachments"), + Some(&etag), + ) + .await; + assert_eq!(status, StatusCode::OK); + let response = document( + Method::POST, + &addition_upload, + "add-document", + &submitted_etag.unwrap(), + ) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let etag = response.headers()["etag"].to_str().unwrap().to_owned(); + let value: Value = response.json().await.unwrap(); + let addition = value["additions"]["other"]["items"][0]["id"] + .as_str() + .unwrap(); + let addition_download = + format!("{base}/additions/{addition}?submissionVersion=1&accessProfile=clerk"); + let attachment_download = format!("{attachment}&submissionVersion=1"); + for path in [&attachment_download, &addition_download] { + let response = http + .get(format!("{}{path}", fixture.http.base_url)) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + assert!(response.bytes().await.unwrap().as_ref() == b"Synthetic document"); + } + // Install the synthetic review acceptance and mirrored ask. The maintained + // review-delivery suite independently exercises their provider transport. + let row = fixture + .database + .admin + .query_one( + "SELECT create_request,expected_policy,expected_submission_digest + FROM registry_internal.registry_proposal_review_submissions WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap(); + let create: registry_review_client::ReviewCreateRequest = + serde_json::from_value(row.get(0)).unwrap(); + let accepted = registry_review_client::ReviewRequestAccepted { + request_id: uuid::Uuid::new_v4(), + subject: create.subject, + policy: serde_json::from_value(row.get(1)).unwrap(), + submission_digest: registry_review_client::SubmissionDigest::parse( + row.get::<_, String>(2).as_str(), + ) + .unwrap(), + }; + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_review_submissions + SET state='accepted',accepted_binding=$1 WHERE proposal_id=$2", + &[&serde_json::to_value(&accepted).unwrap(), &id], + ) + .await + .unwrap(); + let as_of = chrono::Utc::now(); + let ask = uuid::Uuid::new_v4(); + fixture.database.admin.execute( + "INSERT INTO registry_internal.registry_proposal_review_asks + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version,text,wants,asked_at,asked_at_wire,state) + VALUES ('casework',$1,$2,'correct-name',$3,1,'Synthetic question',$4,$5,$6,'open')", + &[&accepted.request_id,&ask,&id,&json!([{"kind":"answer"}]),&as_of,&as_of.to_rfc3339()] + ).await.unwrap(); + let answer = format!("{base}/asks/{ask}/answer?accessProfile=clerk"); + let (status, _, answered_etag) = send( + &fixture.http, + Method::POST, + &answer, + json!({"text":"Synthetic answer"}), + Some("answer-ask"), + Some(&etag), + ) + .await; + assert_eq!(status, StatusCode::OK); + let etag = answered_etag.unwrap(); + let (status, context, _) = send( + &fixture.http, + Method::GET, + &format!("{base}/review-context?accessProfile=clerk"), + Value::Null, + None, + None, + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!( + context["context"]["fields"], + json!({"proposedName":"Proposed"}) + ); + let (status, _, _) = send( + &fixture.http, + Method::GET, + &format!("{base}/review-status?accessProfile=clerk"), + Value::Null, + None, + None, + ) + .await; + assert_eq!(status, StatusCode::OK); + let idp = MockIdp::start().await; + let auth = authenticator(&fixture.registry, &idp).await; + let task_caller = fixture.client_for(auth.authenticate(&idp.mint_token(json!({ + "aud":"urn:example:breg","sub":"author","azp":"agent-client","registry_principal":"author", + "registry_actor_kind":"service","registry_purpose":"registry-administration","scope":"proposal:task-context" + }))).await.unwrap()).await; + let task_path = format!("{base}/task-grant-context?accessProfile=task-context"); + let task_request = json!({ + "expected":{"actionId":"correct-name","subject":context["subject"],"contract":context["context"]["contract"]}, + "requestId":accepted.request_id,"taskId":uuid::Uuid::new_v4(),"taskRevision":1, + "policy":accepted.policy,"purpose":"task-grant","fields":["proposedName"] + }); + let (status, task_context, _) = send( + &task_caller, + Method::POST, + &task_path, + task_request.clone(), + None, + None, + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!( + task_context["proposal"]["context"]["fields"], + json!({"proposedName":"Proposed"}) + ); + set_membership_active(&fixture.http, &membership, false).await; + let (status, problem, _) = send( + &task_caller, + Method::POST, + &task_path, + task_request, + None, + None, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + assert!(problem.get("proposal").is_none()); + for path in [&attachment_download, &addition_download] { + let response = http + .get(format!("{}{path}", fixture.http.base_url)) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::NOT_FOUND); + assert_eq!( + response.json::().await.unwrap()["code"], + "resource.not-found" + ); + } + for (method, path, key, expected, problem) in [ + ( + Method::PATCH, + &attachment, + "deny-attachment-replace", + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ( + Method::DELETE, + &attachment, + "remove-draft-file", + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ( + Method::POST, + &addition_upload, + "deny-addition", + StatusCode::NOT_FOUND, + "resource.not-found", + ), + ] { + let response = document(method, path, key, &etag).send().await.unwrap(); + assert_eq!(response.status(), expected); + let body = response.json::().await.unwrap(); + assert_eq!(body["code"], problem); + assert!(body.get("failedCheck").is_none()); + } + let (status, problem, _) = send( + &fixture.http, + Method::POST, + &answer, + json!({"text":"Synthetic answer"}), + Some("answer-ask"), + Some(&etag), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + for operation in ["review-context", "review-status"] { + let (status, problem, _) = send( + &fixture.http, + Method::GET, + &format!("{base}/{operation}?accessProfile=clerk"), + Value::Null, + None, + None, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + } + for operation in ["revise", "rebase", "cancel", "retry"] { + let (status, problem, _) = send( + &fixture.http, + Method::POST, + &format!("{base}/{operation}?accessProfile=clerk"), + if matches!(operation, "revise" | "rebase") { + json!({"input":input}) + } else { + json!({}) + }, + Some(operation), + Some(&etag), + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED); + assert_eq!(problem["code"], "precondition.failed"); + assert!(problem.get("failedCheck").is_none()); + } + fixture.finish().await; +} + fn caller(subject: &str) -> VerifiedRequestClaims { caller_in(subject, "zone-a") } @@ -2701,6 +3567,15 @@ fn link_source() -> Value { /// Proposal id). async fn linked_history(fixture: &client_http::ClientFixture) -> (String, String, String) { let (organization, target) = seed(fixture).await; + let id = apply_and_link_history(fixture, &organization, &target).await; + (organization, target, id) +} + +async fn apply_and_link_history( + fixture: &client_http::ClientFixture, + organization: &str, + target: &str, +) -> String { let (code, condition, _) = send( &fixture.http, Method::POST, @@ -2754,7 +3629,7 @@ async fn linked_history(fixture: &client_http::ClientFixture) -> (String, String ) .await; assert_eq!(code, StatusCode::OK, "{applied}"); - (organization, target, id) + id } async fn history( @@ -2897,6 +3772,60 @@ async fn record_history_omits_the_proposal_from_a_profile_without_a_proposal_gra fixture.finish().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn record_history_rechecks_proposal_membership_without_hiding_the_revision() { + let mut project = link_source(); + project["recordTypes"]["membership"]["membership"] = + json!({"key":"organization","principal":"principal","active":"active"}); + let clerk_permissions = &mut project["accessProfiles"]["clerk"]["permissions"]; + clerk_permissions["proposals"][0]["targets"][0]["rowBoundaries"] + .as_array_mut() + .unwrap() + .push(json!({"field":"organization","membership":"membership"})); + clerk_permissions["actions"][0]["targets"][0]["rowBoundaries"] + .as_array_mut() + .unwrap() + .push(json!({"field":"organization","membership":"membership"})); + separate_membership_admin(&mut project); + let fixture = client_http::ClientFixture::start(compile(project), clerk()).await; + let (organization, target) = seed(&fixture).await; + let membership = create( + &fixture.http, + "memberships", + json!({"organization":organization,"principal":"author","active":true}), + "history-membership", + ) + .await; + let id = apply_and_link_history(&fixture, &organization, &target).await; + assert_link(&fixture.http, &target, "clerk", &id).await; + set_membership_active(&fixture.http, &membership, false).await; + assert_no_link(&fixture.http, &target, "clerk").await; + let (status, problem, _) = send( + &fixture.http, + Method::GET, + &format!("/v1/proposals/{id}?accessProfile=clerk"), + Value::Null, + None, + None, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_eq!(problem["code"], "resource.not-found"); + let (status, problem, _) = send( + &fixture.http, + Method::POST, + "/v1/actions/correct-name/proposals?accessProfile=clerk", + json!({"input":{"target":target,"value":"Proposed"}}), + Some("start-without-membership"), + None, + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED); + assert_eq!(problem["code"], "precondition.failed"); + assert!(problem.get("failedCheck").is_none()); + fixture.finish().await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn record_history_omits_the_proposal_when_ownership_does_not_match() { let fixture = client_http::ClientFixture::start(compile(link_source()), clerk()).await; @@ -2938,7 +3867,7 @@ fn row_boundary_link_source() -> Value { "permissions":{"records":[ {"recordType":"target","operations":["get","revisions"],"revisionAccess":true, "readableFields":["name","jurisdiction","organization"],"rowBoundaries":"unrestricted"}], - "proposals":[{"action":"correct-name","operations":["get"],"ownership":"caller", + "proposals":[{"action":"correct-name","operations":["get"],"party":"owner", "targets":[{"recordType":"target","rowBoundaries": [{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}); project @@ -3359,7 +4288,7 @@ async fn proposal_target_refusals_are_identical_across_routes_and_postures() { .remove("records"); alternate["permissions"]["actions"][0]["action"] = json!("alternate-name"); alternate["permissions"]["proposals"][0] = json!({ - "action":"alternate-name", "operations":["get"], "ownership":"caller", "targets":targets, + "action":"alternate-name", "operations":["get"], "party":"owner", "targets":targets, }); source["accessProfiles"]["alternate"] = alternate.clone(); alternate["permissions"] diff --git a/crates/registry-breg/tests/postgres_proposal_shape_activation.rs b/crates/registry-breg/tests/postgres_proposal_shape_activation.rs index eb092dc537..763148d654 100644 --- a/crates/registry-breg/tests/postgres_proposal_shape_activation.rs +++ b/crates/registry-breg/tests/postgres_proposal_shape_activation.rs @@ -60,7 +60,7 @@ fn registry_source(automatic: bool) -> Value { "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}], "proposals":[{"action":"correct-name","operations":["get","list","edit","submit","revise","rebase","retry","cancel","apply"], - "ownership":"caller","readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", + "party":"owner","readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target", "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}]}]}}}}); source } diff --git a/crates/registry-breg/tests/postgres_proposal_subject.rs b/crates/registry-breg/tests/postgres_proposal_subject.rs new file mode 100644 index 0000000000..aedc7e250e --- /dev/null +++ b/crates/registry-breg/tests/postgres_proposal_subject.rs @@ -0,0 +1,1592 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The person a Proposal is about follows it when someone else filed it. +//! BReg binds the subject once, at the first Submit, and admits a caller as +//! the subject only when their verified principal equals that value. +#![cfg(feature = "postgres-test")] +#[path = "support/client_http.rs"] +#[allow(dead_code)] +mod client_http; +#[path = "support/postgres_harness.rs"] +#[allow(dead_code)] +mod postgres_harness; + +use axum::http::{HeaderMap, StatusCode}; +use registry_breg::api::VerifiedRequestClaims; +use registry_breg::compiler::{compile_project, CompileProfile}; +use registry_breg::contract::parse_project_json; +use registry_breg_client::{ + BRegCreateRequest, BRegDirectWrite, BRegIdempotencyKey, BRegRecordFormat, +}; +use registry_platform_oidc::ActorKind; +use serde_json::{json, Value}; +use std::collections::{BTreeMap, BTreeSet}; +use uuid::Uuid; + +const CLERK: &str = "clerk-canary"; +const CITIZEN: &str = "citizen-a-canary"; +const NEIGHBOUR: &str = "citizen-b-canary"; + +fn targets() -> Value { + json!([{"recordType":"licence","rowBoundaries":"unrestricted"}]) +} + +fn source() -> Value { + let policy = + json!({"id":"licence-review","version":"1","digest":format!("sha256:{}","b".repeat(64))}); + let proposal = |subject: Value| { + json!({"review":{"type":"required","authority":"local-review","source":"licence-test","policy":policy}, + "application":{"mode":"manual"},"retention":{"mode":"retain"},"subject":subject, + "attachments":[{"id":"id-scan","required":false,"maximumBytes":1024, + "contentTypes":["text/plain"],"classification":"internal"}], + "additions":{"id":"other","maximumBytes":1024,"maximumCount":4, + "contentTypes":["text/plain"],"classification":"internal"}}) + }; + let owner = |action: &str, readable: Value| { + json!({"action":action,"party":"owner", + "operations":["get","list","edit","submit","revise","cancel","get-review-status"], + "readableInputs":readable,"targets":targets()}) + }; + json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + "project":{"id":"proposal-subject","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://proposal-subject.example.test"}, + "datasets":{"licences": {}}, + "reviewAuthorities":{"local-review": {"protocol":"id.registrystack.org/protocols/review/v1"}}, + "recordTypes":{ + "licence": {"route":"licences","primaryDataset":"licences","mutationMode":"mutable","classification":"internal", + "batch":{"maximumItems":3,"maximumBytes":8192}, + "fields":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}]}}, + "actions":{ + "apply-for-licence": {"execution":{"mode":"proposal","proposal":proposal(json!({"input":"holder"}))}, + "inputs":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"issued","target":{"recordType":"licence"},"operation":"create", + "set":{"holder":{"fromInput":"holder"},"statement":{"fromInput":"statement"}}}]}}, + "renew-licence": {"execution":{"mode":"proposal","proposal":proposal(json!({"input":"licence","field":"holder"}))}, + "inputs":[ + {"id":"licence","type":"reference","target":"licence","required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"renewed","target":{"fromInput":"licence"},"operation":"patch", + "set":{"statement":{"fromInput":"statement"}}}]}}, + "issue-copy": {"execution":{"mode":"proposal","proposal":proposal(json!({"input":"original","field":"holder"}))}, + "inputs":[ + {"id":"original","type":"reference","target":"licence","required":true,"classification":"internal"}, + {"id":"copy-holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"copied","target":{"recordType":"licence"},"operation":"create", + "set":{"holder":{"fromInput":"copy-holder"}}}]}}}, + "accessProfiles":{ + "admin": {"principalClaim":"sub","requiredScopes":["licence:admin"],"actorKind":"human", + "permissions":{"records":[{"recordType":"licence","operations":["create","get","patch"], + "readableFields":["holder","statement"],"writableFields":["holder","statement"],"rowBoundaries":"unrestricted"}]}}, + "desk": {"principalClaim":"sub","requiredScopes":["licence:desk"],"actorKind":"human", + "permissions":{ + "actions":[ + {"action":"apply-for-licence","operations":["start"],"targets":targets()}, + {"action":"renew-licence","operations":["start"],"targets":targets()}, + {"action":"issue-copy","operations":["start"],"targets":targets()}], + "proposals":[ + {"action":"issue-copy","party":"owner","submitsFor":"anyone", + "operations":["get","list","edit","submit","cancel"], + "readableInputs":["original","copy-holder"],"targets":targets()}, + {"action":"apply-for-licence","party":"owner","submitsFor":"anyone", + "operations":["get","list","edit","submit","revise","cancel","get-review-status"], + "readableInputs":["holder","statement"],"readableAttachments":["id-scan"], + "writableAttachments":["id-scan"],"targets":targets()}, + {"action":"renew-licence","party":"owner","submitsFor":"anyone", + "operations":["get","list","edit","submit","revise","cancel","get-review-status"], + "readableInputs":["licence","statement"],"targets":targets()}]}}, + "citizen": {"principalClaim":"sub","requiredScopes":["licence:self"],"actorKind":"human", + "permissions":{ + "actions":[ + {"action":"apply-for-licence","operations":["start"],"targets":targets()}, + {"action":"renew-licence","operations":["start"],"targets":targets()}], + "proposals":[ + {"action":"apply-for-licence","party":"owner", + "operations":["get","list","edit","submit","revise","cancel","get-review-status"], + "readableInputs":["holder","statement"],"readableAttachments":["id-scan"], + "writableAttachments":["id-scan"],"targets":targets()}, + {"action":"apply-for-licence","party":"subject", + "operations":["get","list","cancel","get-review-status","answer","add"], + "readableInputs":["holder"],"writableAttachments":["other"], + "targets":targets()}, + owner("renew-licence", json!(["licence","statement"])), + {"action":"renew-licence","party":"subject", + "operations":["get","list","cancel"], + "readableInputs":["licence"],"targets":targets()}]}}, + // A follower profile written for any actor kind: only the human + // test keeps an agent or service with the same principal out. + "follower": {"principalClaim":"sub","requiredScopes":["licence:follow"], + "permissions":{"proposals":[ + {"action":"apply-for-licence","party":"subject","operations":["get","list"], + "readableInputs":["holder"],"targets":targets()}]}}} + }) +} + +fn compile(source: &Value) -> registry_breg::CompiledRegistry { + let project = parse_project_json(&serde_json::to_vec(source).unwrap()).unwrap(); + compile_project(&project, &[], CompileProfile::Authoring).expect("subject project compiles") +} + +fn person(principal: &str, scope: &str, kind: ActorKind) -> VerifiedRequestClaims { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + principal, + BTreeSet::from([scope.to_owned()]), + Some("licence-portal".into()), + BTreeMap::new(), + kind, + ) + .unwrap() +} + +fn clerk() -> VerifiedRequestClaims { + person(CLERK, "licence:desk", ActorKind::Human) +} + +fn citizen(principal: &str) -> VerifiedRequestClaims { + person(principal, "licence:self", ActorKind::Human) +} + +struct NoToken; +#[async_trait::async_trait] +impl registry_platform_httputil::TokenProvider for NoToken { + async fn bearer_token( + &self, + ) -> Result + { + Err(registry_platform_httputil::TokenError::Unavailable) + } +} + +struct NoResult; +#[async_trait::async_trait] +impl registry_breg::review_store::ReviewResultSource for NoResult { + async fn approved_evidence( + &self, + _authority: &str, + _accepted: ®istry_review_client::ReviewRequestAccepted, + ) -> Result< + registry_breg::review_integration::AcceptedReviewEvidence, + registry_breg::mutation::MutationError, + > { + Err(registry_breg::mutation::MutationError::Unavailable) + } +} + +fn local_review() -> std::sync::Arc { + use registry_breg::review_store::{ReviewAuthorityClient, ReviewAuthorityRegistry}; + let client = registry_review_client::ReviewClient::new( + registry_review_client::ReviewClientConfig::new_without_peer_policy( + "http://127.0.0.1:9/".parse().unwrap(), + ), + ) + .unwrap(); + let authority = std::sync::Arc::new( + ReviewAuthorityClient::new( + "local-review".into(), + client, + std::sync::Arc::new(NoToken), + "producer".into(), + "proposal-producer".into(), + 7, + None, + None, + ) + .unwrap(), + ); + std::sync::Arc::new( + ReviewAuthorityRegistry::new(BTreeMap::from([("local-review".into(), authority)])).unwrap(), + ) +} + +async fn fixture_from(source: &Value) -> client_http::ClientFixture { + client_http::ClientFixture::start_with_mutations( + compile(source), + person("admin-canary", "licence:admin", ActorKind::Human), + |mutations| { + mutations.with_proposal_review_substitute_for_test( + local_review(), + std::sync::Arc::new(NoResult), + ) + }, + ) + .await +} + +async fn fixture() -> client_http::ClientFixture { + fixture_from(&source()).await +} + +async fn request( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + method: &str, + path: &str, + etag: Option<&str>, + key: Option<&str>, + body: Value, +) -> (StatusCode, HeaderMap, Value) { + use tower::ServiceExt; + let mut req = axum::http::Request::builder() + .method(method) + .uri(path) + .header("content-type", "application/json"); + if let Some(etag) = etag { + req = req.header("if-match", etag); + } + if let Some(key) = key { + req = req.header("idempotency-key", key); + } + let response = registry_breg::api::router(fixture.service()) + .layer(axum::Extension(caller)) + .oneshot( + req.body(if method == "GET" { + axum::body::Body::empty() + } else { + axum::body::Body::from(serde_json::to_vec(&body).unwrap()) + }) + .unwrap(), + ) + .await + .unwrap(); + let status = response.status(); + let headers = response.headers().clone(); + let bytes = axum::body::to_bytes(response.into_body(), 1 << 22) + .await + .unwrap(); + let value = if bytes.is_empty() { + Value::Null + } else { + serde_json::from_slice(&bytes).unwrap() + }; + (status, headers, value) +} + +async fn get( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + id: Uuid, +) -> (StatusCode, Option, Value) { + let (status, headers, value) = request( + fixture, + caller, + "GET", + &format!("/v1/proposals/{id}"), + None, + None, + Value::Null, + ) + .await; + let etag = headers + .get("etag") + .map(|etag| etag.to_str().unwrap().to_owned()); + (status, etag, value) +} + +/// Run `operation` as `caller` against the Proposal's current ETag for that +/// caller. +async fn command( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + id: Uuid, + operation: &str, + key: &str, + body: Value, +) -> (StatusCode, Value) { + let (status, etag, document) = get(fixture, caller.clone(), id).await; + assert_eq!(status, StatusCode::OK, "{document}"); + let (status, _, value) = request( + fixture, + caller, + "POST", + &format!("/v1/proposals/{id}/{operation}"), + etag.as_deref(), + Some(key), + body, + ) + .await; + (status, value) +} + +async fn start( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + action: &str, + input: Value, + key: &str, +) -> Uuid { + let (status, _, value) = request( + fixture, + caller, + "POST", + &format!("/v1/actions/{action}/proposals"), + None, + Some(key), + json!({ "input": input }), + ) + .await; + assert_eq!(status, StatusCode::CREATED, "{value}"); + Uuid::parse_str(value["id"].as_str().unwrap()).unwrap() +} + +/// A Proposal `caller` filed naming `holder`, submitted. +async fn filed( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + holder: &str, + key: &str, +) -> Uuid { + let id = start( + fixture, + caller.clone(), + "apply-for-licence", + json!({"holder":holder,"statement":"Officer-only statement"}), + &format!("{key}-start"), + ) + .await; + let (status, value) = command( + fixture, + caller, + id, + "submit", + &format!("{key}-submit"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + id +} + +async fn list( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + query: &str, +) -> Vec { + let (status, _, page) = request( + fixture, + caller, + "GET", + &format!("/v1/proposals{query}"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + page["items"].as_array().unwrap().clone() +} + +fn link_names(document: &Value) -> BTreeSet { + document["links"] + .as_object() + .unwrap() + .keys() + .cloned() + .collect() +} + +/// Return the current review round with changes requested, so the party has +/// the turn and Revise is open. +async fn request_changes(fixture: &client_http::ClientFixture, id: Uuid) { + let row = fixture + .database + .admin + .query_one( + "SELECT create_request,expected_submission_digest FROM registry_internal.registry_proposal_review_submissions + WHERE proposal_id=$1 ORDER BY submission_version DESC LIMIT 1", + &[&id], + ) + .await + .unwrap(); + let create: registry_review_client::ReviewCreateRequest = + serde_json::from_value(row.get(0)).unwrap(); + let accepted = registry_review_client::ReviewRequestAccepted { + request_id: Uuid::new_v4(), + subject: create.subject, + policy: serde_json::from_value(json!({"id":"licence-review","version":"1","digest":format!("sha256:{}","b".repeat(64))})).unwrap(), + submission_digest: serde_json::from_value(json!(row.get::<_, String>(1))).unwrap(), + }; + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_review_submissions SET state='accepted',accepted_binding=$2 + WHERE proposal_id=$1 AND state<>'accepted'", + &[&id, &serde_json::to_value(&accepted).unwrap()], + ) + .await + .unwrap(); + let now = chrono::Utc::now(); + let result = registry_review_client::ReviewResult { + result_id: Uuid::new_v4(), + request_id: accepted.request_id, + subject: accepted.subject.clone(), + policy: accepted.policy.clone(), + submission_digest: accepted.submission_digest.clone(), + status: serde_json::from_value(json!("changes-requested")).unwrap(), + outcome: Some("changes-requested".to_owned()), + public_reason: Some("Public reason for the applicant".to_owned()), + result: None, + completed_at: now - chrono::Duration::seconds(2), + available_until: now + chrono::Duration::minutes(5), + }; + let (mut migration, task) = fixture.database.connect_migration().await; + let tx = migration.transaction().await.unwrap(); + registry_breg::review_store::reconcile_result( + &tx, + "local-review", + &accepted, + &result, + &fixture.mutations, + ) + .await + .unwrap(); + tx.commit().await.unwrap(); + drop(migration); + task.abort(); +} + +#[tokio::test] +async fn a_citizen_follows_a_proposal_the_desk_filed_and_a_neighbour_sees_nothing() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "desk-files").await; + + let (status, _, filer) = get(&fixture, clerk(), id).await; + assert_eq!(status, StatusCode::OK, "{filer}"); + assert_eq!(filer["partyRole"], "owner"); + + let (status, _, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + assert_eq!(followed["partyRole"], "subject"); + assert_eq!(followed["state"], "submitted"); + // The subject entry's readable inputs govern the projection. + assert_eq!(followed["input"], json!({"holder": CITIZEN})); + // Only what the subject entry holds is linked. + let links = link_names(&followed); + assert!(links.contains("cancel"), "{links:?}"); + for owner_only in ["edit", "submit", "revise"] { + assert!(!links.contains(owner_only), "{owner_only} in {links:?}"); + } + + request_changes(&fixture, id).await; + let waiting = list(&fixture, citizen(CITIZEN), "?turn=party").await; + assert_eq!(waiting.len(), 1, "{waiting:?}"); + assert_eq!(waiting[0]["id"], id.to_string()); + assert_eq!(waiting[0]["partyRole"], "subject"); + let (_, _, returned) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(returned["turn"], "party"); + + // A neighbour with the same profile learns nothing. + let (status, _, concealed) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND, "{concealed}"); + assert!(list(&fixture, citizen(NEIGHBOUR), "").await.is_empty()); + assert!(list(&fixture, citizen(NEIGHBOUR), "?turn=party") + .await + .is_empty()); + let (status, _, value) = request( + &fixture, + citizen(NEIGHBOUR), + "POST", + &format!("/v1/proposals/{id}/cancel"), + Some("\"breg-proposal-guess\""), + Some("neighbour-cancel"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{value}"); + + // The subject may not use an operation only the owner entry holds. The + // subject already knows the Proposal exists, so the refusal names the + // profile rather than concealing it. + let (status, etag, _) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK); + let (status, _, refused) = request( + &fixture, + citizen(CITIZEN), + "POST", + &format!("/v1/proposals/{id}/revise"), + etag.as_deref(), + Some("subject-revise"), + json!({"input":{"holder":CITIZEN,"statement":"Changed by the subject"}}), + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{refused}"); + assert_eq!(refused["code"], "profile.not-authorized"); + let (_, _, unchanged) = get(&fixture, clerk(), id).await; + assert_eq!(unchanged["input"]["statement"], "Officer-only statement"); + + let (status, cancelled) = command( + &fixture, + citizen(CITIZEN), + id, + "cancel", + "subject-cancel", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{cancelled}"); + assert_eq!(cancelled["state"], "cancelled"); + assert_eq!(cancelled["partyRole"], "subject"); + fixture.finish().await; +} + +#[tokio::test] +async fn a_self_filer_is_the_owner_and_sees_what_the_owner_entry_shows() { + let fixture = fixture().await; + let id = filed(&fixture, citizen(CITIZEN), CITIZEN, "self-files").await; + let (status, _, own) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{own}"); + assert_eq!(own["partyRole"], "owner"); + assert_eq!(own["input"]["statement"], "Officer-only statement"); + let mine = list(&fixture, citizen(CITIZEN), "").await; + assert_eq!(mine.len(), 1); + assert_eq!(mine[0]["partyRole"], "owner"); + fixture.finish().await; +} + +#[tokio::test] +async fn submit_names_someone_else_only_under_submits_for_anyone() { + let fixture = fixture().await; + let id = start( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + json!({"holder":NEIGHBOUR}), + "names-neighbour", + ) + .await; + let (status, refused) = command( + &fixture, + citizen(CITIZEN), + id, + "submit", + "names-neighbour-submit", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{refused}"); + assert_eq!(refused["code"], "proposal.subject-not-caller"); + let (_, _, draft) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(draft["state"], "draft"); + // The neighbour never became the subject of the refused draft. + let (status, _, _) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + + // The desk files for the neighbour. + let desk = filed(&fixture, clerk(), NEIGHBOUR, "desk-names-neighbour").await; + let (status, _, followed) = get(&fixture, citizen(NEIGHBOUR), desk).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + fixture.finish().await; +} + +#[tokio::test] +async fn the_subject_is_frozen_at_the_first_submit() { + let fixture = fixture().await; + // A draft names its subject but binds no one until it is submitted. + let draft = start( + &fixture, + clerk(), + "apply-for-licence", + json!({"holder":CITIZEN}), + "unsubmitted", + ) + .await; + let (status, _, _) = get(&fixture, citizen(CITIZEN), draft).await; + assert_eq!(status, StatusCode::NOT_FOUND); + + let id = filed(&fixture, clerk(), CITIZEN, "frozen").await; + request_changes(&fixture, id).await; + let (status, refused) = command( + &fixture, + clerk(), + id, + "revise", + "move-subject", + json!({"input":{"holder":NEIGHBOUR,"statement":"Officer-only statement"}}), + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{refused}"); + assert_eq!(refused["code"], "request.invalid"); + assert_eq!(refused["fieldPath"], "/input/holder", "{refused}"); + + let (status, revised) = command( + &fixture, + clerk(), + id, + "revise", + "keep-subject", + json!({"input":{"holder":CITIZEN,"statement":"Revised statement"}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{revised}"); + // A revised draft keeps its bound subject. + let (status, _, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + assert_eq!(followed["state"], "draft"); + let (status, edited) = command( + &fixture, + clerk(), + id, + "edit", + "edit-subject", + json!({"input":{"holder":NEIGHBOUR}}), + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{edited}"); + assert_eq!(edited["fieldPath"], "/input/holder"); + let (status, resubmitted) = + command(&fixture, clerk(), id, "submit", "resubmit", json!({})).await; + assert_eq!(status, StatusCode::OK, "{resubmitted}"); + assert_eq!(resubmitted["submissionVersion"], 2); + let (status, _, _) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + fixture.finish().await; +} + +#[tokio::test] +async fn the_field_form_reads_the_holder_and_refuses_a_moved_holder() { + let fixture = fixture().await; + let client = &fixture.http.client; + let metadata = client.registry_contract(Some("admin")).await.unwrap(); + let BRegDirectWrite::Create(create) = metadata + .value + .select_direct_write("records.licence.create", "admin") + .unwrap() + else { + panic!("create") + }; + let licence = client + .create_record( + &create, + &BRegCreateRequest::new(json!({"holder":CITIZEN}).as_object().unwrap().clone()) + .unwrap(), + &BRegIdempotencyKey::parse("seed-licence").unwrap(), + BRegRecordFormat::Json, + ) + .await + .unwrap() + .value + .data + .record_id; + let id = start( + &fixture, + clerk(), + "renew-licence", + json!({"licence":licence,"statement":"Renewal"}), + "renew", + ) + .await; + let (status, value) = command(&fixture, clerk(), id, "submit", "renew-submit", json!({})).await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (status, _, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + assert_eq!(followed["partyRole"], "subject"); + let (status, _, _) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + + // The holder moves on the register; the next Submit refuses. + request_changes(&fixture, id).await; + let (status, value) = command( + &fixture, + clerk(), + id, + "revise", + "renew-revise", + json!({"input":{"licence":licence,"statement":"Renewal"}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + // Move the holder underneath BReg, as another writer of the register + // would, without disclosing anything to the submitter. + let licence_id = Uuid::parse_str(&licence).unwrap(); + let located = fixture + .database + .admin + .query_one( + "SELECT format('%I.%I', c.table_schema, c.table_name), quote_ident(c.column_name) + FROM information_schema.columns c + WHERE c.table_name LIKE 'breg_e_licence%' AND c.column_name LIKE '%holder%'", + &[], + ) + .await + .unwrap(); + let (table, column): (String, String) = (located.get(0), located.get(1)); + let moved = fixture + .database + .admin + .execute( + &format!("UPDATE {table} SET {column}=$2 WHERE record_id=$1"), + &[&licence_id, &NEIGHBOUR], + ) + .await + .unwrap(); + assert_eq!(moved, 1); + let (status, refused) = + command(&fixture, clerk(), id, "submit", "renew-resubmit", json!({})).await; + assert_eq!(status, StatusCode::CONFLICT, "{refused}"); + assert_eq!(refused["code"], "proposal.subject-changed"); + fixture.finish().await; +} + +#[tokio::test] +async fn only_a_person_acting_for_themselves_is_matched_as_the_subject() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "people-only").await; + let follower = |kind| person(CITIZEN, "licence:follow", kind); + let (status, _, followed) = get(&fixture, follower(ActorKind::Human), id).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + assert_eq!(followed["partyRole"], "subject"); + // A standing agent is refused at admission, before any Proposal is + // read; a service is admitted and never matched as the subject. + for (kind, expected) in [ + (ActorKind::Agent, StatusCode::FORBIDDEN), + (ActorKind::Service, StatusCode::NOT_FOUND), + ] { + let (status, _, refused) = get(&fixture, follower(kind), id).await; + assert_eq!(status, expected, "{kind:?}: {refused}"); + assert!(refused.get("partyRole").is_none()); + let (status, _, page) = request( + &fixture, + follower(kind), + "GET", + "/v1/proposals", + None, + None, + Value::Null, + ) + .await; + assert!( + status != StatusCode::OK || page["items"] == json!([]), + "{kind:?}: {page}" + ); + } + fixture.finish().await; +} + +#[tokio::test] +async fn audit_names_the_subject_by_pseudonym_and_each_later_request_by_party() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "audited").await; + let (status, _, _) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK); + let entries = fixture.audit_capture.entries(); + let text = serde_json::to_string(&entries).unwrap(); + assert!( + !text.contains(CITIZEN), + "the subject identifier reached audit" + ); + let stored: Option = fixture + .database + .admin + .query_one( + "SELECT subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + let stored = stored.expect("the subject is bound at Submit"); + assert!( + !text.contains(&stored), + "the internal subject reference reached audit" + ); + let submit = entries + .iter() + .rev() + .find(|entry| entry.to_string().contains("subjectPseudonym")) + .unwrap_or_else(|| panic!("no audit entry carries the subject pseudonym: {text}")); + assert!(submit.to_string().contains("submit"), "{submit}"); + let read = entries.last().unwrap(); + assert!( + read.to_string().contains("\"partyRole\":\"subject\""), + "{read}" + ); + fixture.finish().await; +} + +#[allow(clippy::too_many_arguments)] +async fn request_bytes( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + method: &str, + path: &str, + etag: Option<&str>, + key: Option<&str>, + content_type: &str, + body: Vec, +) -> (StatusCode, Vec) { + use tower::ServiceExt; + let mut req = axum::http::Request::builder() + .method(method) + .uri(path) + .header("content-type", content_type); + if let Some(etag) = etag { + req = req.header("if-match", etag); + } + if let Some(key) = key { + req = req.header("idempotency-key", key); + } + let response = registry_breg::api::router(fixture.service()) + .layer(axum::Extension(caller)) + .oneshot(req.body(axum::body::Body::from(body)).unwrap()) + .await + .unwrap(); + let status = response.status(); + let bytes = axum::body::to_bytes(response.into_body(), 1 << 22) + .await + .unwrap() + .to_vec(); + (status, bytes) +} + +/// A draft `caller` started naming `holder`, with `id-scan` uploaded, then +/// submitted. +async fn filed_with_scan( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + holder: &str, + key: &str, +) -> Uuid { + let id = start( + fixture, + caller.clone(), + "apply-for-licence", + json!({"holder":holder,"statement":"Officer-only statement"}), + &format!("{key}-start"), + ) + .await; + let (_, etag, _) = get(fixture, caller.clone(), id).await; + let (status, body) = request_bytes( + fixture, + caller.clone(), + "PATCH", + &format!("/v1/proposals/{id}/attachments/id-scan"), + etag.as_deref(), + Some(&format!("{key}-scan")), + "text/plain", + b"identity scan canary".to_vec(), + ) + .await; + assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body)); + let (status, value) = command( + fixture, + caller, + id, + "submit", + &format!("{key}-submit"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + id +} + +async fn download_scan( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + id: Uuid, +) -> (StatusCode, Vec) { + request_bytes( + fixture, + caller, + "GET", + &format!("/v1/proposals/{id}/attachments/id-scan?submissionVersion=1"), + None, + None, + "application/json", + Vec::new(), + ) + .await +} + +#[tokio::test] +async fn attachment_downloads_follow_the_entry_that_admitted_the_caller() { + let fixture = fixture().await; + let id = filed_with_scan(&fixture, clerk(), CITIZEN, "scan-subject").await; + // The subject entry reads no attachment, whatever the owner entry reads. + let (_, _, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert!(followed.get("attachments").is_none(), "{followed}"); + let (status, bytes) = download_scan(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert!(!String::from_utf8_lossy(&bytes).contains("canary")); + // The filer's owner entry reads it. + let (status, bytes) = download_scan(&fixture, clerk(), id).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(bytes, b"identity scan canary"); + fixture.finish().await; + + // Authored the other way round: the subject entry reads the slot and + // the owner entry does not, so a self-filer reads nothing. + let mut swapped = source(); + let entries = swapped["accessProfiles"]["citizen"]["permissions"]["proposals"] + .as_array_mut() + .unwrap(); + entries[0]["readableAttachments"] = json!([]); + entries[1]["readableAttachments"] = json!(["id-scan"]); + entries.swap(0, 1); + let fixture = fixture_from(&swapped).await; + let own = filed_with_scan(&fixture, citizen(CITIZEN), CITIZEN, "scan-owner").await; + let (status, _) = download_scan(&fixture, citizen(CITIZEN), own).await; + assert_eq!(status, StatusCode::NOT_FOUND); + let followed = filed_with_scan(&fixture, clerk(), CITIZEN, "scan-followed").await; + let (status, bytes) = download_scan(&fixture, citizen(CITIZEN), followed).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(bytes, b"identity scan canary"); + fixture.finish().await; +} + +#[tokio::test] +async fn the_subject_reads_review_status() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "subject-status").await; + let (status, _, value) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/review-status"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (status, _, _) = request( + &fixture, + citizen(NEIGHBOUR), + "GET", + &format!("/v1/proposals/{id}/review-status"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + fixture.finish().await; +} + +/// The subject of `renew-licence` is bounded to licences that name them. +fn bounded_subject_source() -> Value { + let mut project = source(); + for entry in project["accessProfiles"]["citizen"]["permissions"]["proposals"] + .as_array_mut() + .unwrap() + { + if entry["action"] == "renew-licence" && entry["party"] == "subject" { + entry["targets"] = json!([{"recordType":"licence","rowBoundaries": + [{"field":"holder","claim":"holder_ref","operator":"equals"}]}]); + } + } + project +} + +/// A citizen whose token also carries the identifier licences name them by. +fn bounded_citizen(principal: &str) -> VerifiedRequestClaims { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + principal, + BTreeSet::from(["licence:self".to_owned()]), + Some("licence-portal".into()), + BTreeMap::from([( + "holder_ref".to_owned(), + registry_breg::api::VerifiedClaimValue::direct_string(principal).unwrap(), + )]), + ActorKind::Human, + ) + .unwrap() +} + +async fn seed_licence(fixture: &client_http::ClientFixture, holder: &str, key: &str) -> String { + let client = &fixture.http.client; + let metadata = client.registry_contract(Some("admin")).await.unwrap(); + let BRegDirectWrite::Create(create) = metadata + .value + .select_direct_write("records.licence.create", "admin") + .unwrap() + else { + panic!("create") + }; + client + .create_record( + &create, + &BRegCreateRequest::new(json!({"holder":holder}).as_object().unwrap().clone()).unwrap(), + &BRegIdempotencyKey::parse(key).unwrap(), + BRegRecordFormat::Json, + ) + .await + .unwrap() + .value + .data + .record_id +} + +async fn move_holder(fixture: &client_http::ClientFixture, licence: &str, holder: &str) { + let located = fixture + .database + .admin + .query_one( + "SELECT format('%I.%I', c.table_schema, c.table_name), quote_ident(c.column_name) + FROM information_schema.columns c + WHERE c.table_name LIKE 'breg_e_licence%' AND c.column_name LIKE '%holder%'", + &[], + ) + .await + .unwrap(); + let (table, column): (String, String) = (located.get(0), located.get(1)); + let moved = fixture + .database + .admin + .execute( + &format!("UPDATE {table} SET {column}=$2 WHERE record_id=$1"), + &[&Uuid::parse_str(licence).unwrap(), &holder], + ) + .await + .unwrap(); + assert_eq!(moved, 1); +} + +#[tokio::test] +async fn a_subject_outside_the_row_boundary_learns_nothing() { + let fixture = fixture_from(&bounded_subject_source()).await; + let licence = seed_licence(&fixture, CITIZEN, "bounded-seed").await; + let id = start( + &fixture, + clerk(), + "renew-licence", + json!({"licence":licence,"statement":"Desk renewal"}), + "bounded-renew", + ) + .await; + let (status, value) = + command(&fixture, clerk(), id, "submit", "bounded-submit", json!({})).await; + assert_eq!(status, StatusCode::OK, "{value}"); + let revise = |key: &'static str, target: Uuid| { + let fixture = &fixture; + let licence = licence.clone(); + async move { + request( + fixture, + bounded_citizen(CITIZEN), + "POST", + &format!("/v1/proposals/{target}/revise"), + Some("\"breg-proposal-guess\""), + Some(key), + json!({"input":{"licence":licence}}), + ) + .await + } + }; + // Within reach, the subject reads it and is told the operation is not theirs. + let (status, _, _) = get(&fixture, bounded_citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK); + let (status, _, refused) = revise("bounded-revise-in", id).await; + assert_eq!(status, StatusCode::FORBIDDEN, "{refused}"); + // Out of reach, every operation answers as an unknown Proposal does. + move_holder(&fixture, &licence, NEIGHBOUR).await; + let (status, _, _) = get(&fixture, bounded_citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + let (status, _, _) = revise("bounded-revise-out", id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + let (status, _, _) = revise("bounded-revise-unknown", Uuid::new_v4()).await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert!(list(&fixture, bounded_citizen(CITIZEN), "") + .await + .is_empty()); + fixture.finish().await; +} + +#[tokio::test] +async fn a_self_service_field_submit_answers_alike_for_an_empty_or_another_holder() { + let fixture = fixture().await; + for (holder, key) in [("", "empty-holder"), (NEIGHBOUR, "other-holder")] { + let licence = seed_licence(&fixture, holder, &format!("{key}-seed")).await; + let id = start( + &fixture, + citizen(CITIZEN), + "renew-licence", + json!({"licence":licence,"statement":"Self renewal"}), + &format!("{key}-start"), + ) + .await; + let (status, refused) = command( + &fixture, + citizen(CITIZEN), + id, + "submit", + &format!("{key}-submit"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{key}: {refused}"); + assert_eq!(refused["code"], "proposal.subject-not-caller", "{key}"); + } + fixture.finish().await; +} + +#[tokio::test] +async fn a_submit_replay_neither_rebinds_nor_reveals() { + let fixture = fixture().await; + let id = start( + &fixture, + clerk(), + "apply-for-licence", + json!({"holder":CITIZEN,"statement":"Replayed statement"}), + "replay-start", + ) + .await; + let (_, etag, _) = get(&fixture, clerk(), id).await; + let path = format!("/v1/proposals/{id}/submit"); + let submit = || { + request( + &fixture, + clerk(), + "POST", + &path, + etag.as_deref(), + Some("replay-submit"), + json!({}), + ) + }; + let (first, _, original) = submit().await; + assert_eq!(first, StatusCode::OK, "{original}"); + let bound: Option = fixture + .database + .admin + .query_one( + "SELECT subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + let (again, _, replayed) = submit().await; + assert_eq!(again, StatusCode::OK, "{replayed}"); + assert_eq!(replayed["submissionVersion"], original["submissionVersion"]); + let after: Option = fixture + .database + .admin + .query_one( + "SELECT subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + assert_eq!(bound, after); + fixture.finish().await; +} + +#[tokio::test] +async fn a_stored_subject_input_that_drifts_is_refused_at_submit() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "input-drift").await; + request_changes(&fixture, id).await; + let (status, value) = command( + &fixture, + clerk(), + id, + "revise", + "input-drift-revise", + json!({"input":{"holder":CITIZEN,"statement":"Revised"}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + // Model a stored input no command could write, such as one carried over + // from an earlier Action contract. + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_state SET input=jsonb_set(input,'{holder}',to_jsonb($2::text)) WHERE proposal_id=$1", + &[&id, &NEIGHBOUR], + ) + .await + .unwrap(); + let (status, refused) = command( + &fixture, + clerk(), + id, + "submit", + "input-drift-resubmit", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::CONFLICT, "{refused}"); + assert_eq!(refused["code"], "proposal.subject-changed"); + let (status, _, _) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + fixture.finish().await; +} + +#[tokio::test] +async fn erasing_a_proposals_detail_forgets_its_subject() { + let mut project = source(); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["retention"] = + json!({"mode":"operator-erase"}); + let fixture = fixture_from(&project).await; + let id = filed(&fixture, clerk(), CITIZEN, "erased").await; + let (status, value) = command( + &fixture, + citizen(CITIZEN), + id, + "cancel", + "erased-cancel", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (mut migration, task) = fixture.database.connect_migration().await; + registry_breg::proposal_retention::erase_proposal_detail( + &mut migration, + &fixture.registry, + registry_breg::proposal_retention::ProposalDetailErasureScope { + action_id: "apply-for-licence", + proposal_id: id, + submission_version: 1, + }, + ) + .await + .unwrap(); + drop(migration); + task.abort(); + let stored: Option = fixture + .database + .admin + .query_one( + "SELECT subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + assert_eq!( + stored, None, + "an erased Proposal keeps no recoverable subject" + ); + // The subject no longer follows it; the filer still reads its state. + let (status, _, _) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + let (status, _, filer) = get(&fixture, clerk(), id).await; + assert_eq!(status, StatusCode::OK, "{filer}"); + fixture.finish().await; +} + +#[tokio::test] +async fn a_subject_cannot_probe_a_hidden_reference_with_the_target_filter() { + let mut project = source(); + for entry in project["accessProfiles"]["citizen"]["permissions"]["proposals"] + .as_array_mut() + .unwrap() + { + if entry["action"] == "renew-licence" && entry["party"] == "subject" { + entry["readableInputs"] = json!([]); + } + } + let fixture = fixture_from(&project).await; + let licence = seed_licence(&fixture, CITIZEN, "hidden-seed").await; + let id = start( + &fixture, + clerk(), + "renew-licence", + json!({"licence":licence,"statement":"Desk renewal"}), + "hidden-renew", + ) + .await; + let (status, value) = + command(&fixture, clerk(), id, "submit", "hidden-submit", json!({})).await; + assert_eq!(status, StatusCode::OK, "{value}"); + assert_eq!(list(&fixture, citizen(CITIZEN), "").await.len(), 1); + assert!( + list(&fixture, citizen(CITIZEN), &format!("?target={licence}")) + .await + .is_empty(), + "the filter matched a reference the subject entry hides" + ); + // The desk reads the licence input, so its filter still matches. + assert_eq!( + list(&fixture, clerk(), &format!("?target={licence}")) + .await + .len(), + 1 + ); + fixture.finish().await; +} + +#[tokio::test] +async fn a_list_audits_each_party_with_its_own_count() { + let fixture = fixture().await; + filed(&fixture, citizen(CITIZEN), CITIZEN, "own-listed").await; + filed(&fixture, clerk(), CITIZEN, "followed-listed").await; + filed(&fixture, clerk(), CITIZEN, "followed-listed-again").await; + assert_eq!(list(&fixture, citizen(CITIZEN), "").await.len(), 3); + let entries = fixture.audit_capture.entries(); + let counts = entries + .iter() + .filter(|entry| { + entry["record"]["operationId"] == "proposals.apply-for-licence.list" + && entry["record"]["phase"] == "terminal" + }) + .map(|entry| { + ( + entry["record"]["partyRole"] + .as_str() + .unwrap_or("none") + .to_owned(), + entry["record"]["resultCount"].as_u64().unwrap(), + ) + }) + .collect::>(); + assert_eq!( + counts, + BTreeMap::from([("owner".to_owned(), 1), ("subject".to_owned(), 2)]), + "{entries:?}" + ); + fixture.finish().await; +} + +#[tokio::test] +async fn a_subjects_pages_hold_only_their_own_proposals() { + let fixture = fixture().await; + let mut mine = BTreeSet::new(); + for (holder, key) in [ + (CITIZEN, "paged-a"), + (NEIGHBOUR, "paged-b"), + (CITIZEN, "paged-c"), + (NEIGHBOUR, "paged-d"), + (CITIZEN, "paged-e"), + ] { + let id = filed(&fixture, clerk(), holder, key).await; + if holder == CITIZEN { + mine.insert(id.to_string()); + } + } + let mut seen = BTreeSet::new(); + let mut query = "?limit=1".to_owned(); + for _ in 0..10 { + let (status, _, page) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals{query}"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + for item in page["items"].as_array().unwrap() { + assert_eq!(item["partyRole"], "subject"); + assert!(seen.insert(item["id"].as_str().unwrap().to_owned())); + } + match page["nextCursor"].as_str() { + Some(cursor) => query = format!("?limit=1&cursor={cursor}"), + None => break, + } + } + assert_eq!(seen, mine); + fixture.finish().await; +} + +#[tokio::test] +async fn a_reference_read_only_for_its_subject_binds_at_submit() { + let fixture = fixture().await; + let original = seed_licence(&fixture, CITIZEN, "copy-seed").await; + let id = start( + &fixture, + clerk(), + "issue-copy", + json!({"original":original,"copyHolder":"Copy holder"}), + "copy-start", + ) + .await; + let (status, value) = command(&fixture, clerk(), id, "submit", "copy-submit", json!({})).await; + assert_eq!(status, StatusCode::OK, "{value}"); + let bound: Option = fixture + .database + .admin + .query_one( + "SELECT subject_reference FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + assert!( + bound.is_some(), + "the subject was read from the referenced Record" + ); + fixture.finish().await; +} + +/// Accept the current review round and open one ask the party may answer. +async fn open_ask(fixture: &client_http::ClientFixture, id: Uuid) -> Uuid { + let row = fixture + .database + .admin + .query_one( + "SELECT create_request,expected_submission_digest FROM registry_internal.registry_proposal_review_submissions + WHERE proposal_id=$1 ORDER BY submission_version DESC LIMIT 1", + &[&id], + ) + .await + .unwrap(); + let create: registry_review_client::ReviewCreateRequest = + serde_json::from_value(row.get(0)).unwrap(); + let accepted = registry_review_client::ReviewRequestAccepted { + request_id: Uuid::new_v4(), + subject: create.subject, + policy: serde_json::from_value(json!({"id":"licence-review","version":"1","digest":format!("sha256:{}","b".repeat(64))})).unwrap(), + submission_digest: serde_json::from_value(json!(row.get::<_, String>(1))).unwrap(), + }; + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_review_submissions SET state='accepted',accepted_binding=$2 + WHERE proposal_id=$1", + &[&id, &serde_json::to_value(&accepted).unwrap()], + ) + .await + .unwrap(); + let ask = Uuid::new_v4(); + let asked_at = chrono::Utc::now(); + fixture + .database + .admin + .execute( + "INSERT INTO registry_internal.registry_proposal_review_asks + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version,text,wants,asked_at,asked_at_wire,state) + VALUES ('local-review',$1,$2,'apply-for-licence',$3,1,'Synthetic question',$4,$5,$6,'open')", + &[&accepted.request_id, &ask, &id, &json!([{"kind":"answer"}]), &asked_at, &asked_at.to_rfc3339()], + ) + .await + .unwrap(); + ask +} + +#[tokio::test] +async fn the_subject_answers_an_ask_and_adds_a_file() { + let fixture = fixture().await; + let id = filed(&fixture, clerk(), CITIZEN, "answering").await; + let ask = open_ask(&fixture, id).await; + + // A neighbour reaches neither command. + let answer_path = format!("/v1/proposals/{id}/asks/{ask}/answer"); + let (status, _, _) = request( + &fixture, + citizen(NEIGHBOUR), + "POST", + &answer_path, + Some("\"breg-proposal-guess\""), + Some("neighbour-answer"), + json!({"text":"Not mine to answer"}), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + + let (status, etag, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(followed["asks"][0]["id"], ask.to_string(), "{followed}"); + let (status, _, answered) = request( + &fixture, + citizen(CITIZEN), + "POST", + &answer_path, + etag.as_deref(), + Some("subject-answer"), + json!({"text":"Answered by the person it is about"}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + assert_eq!(answered["partyRole"], "subject"); + + let (_, etag, _) = get(&fixture, citizen(CITIZEN), id).await; + let (status, body) = request_bytes( + &fixture, + citizen(CITIZEN), + "POST", + &format!("/v1/proposals/{id}/additions/other"), + etag.as_deref(), + Some("subject-add"), + "text/plain", + b"supporting letter".to_vec(), + ) + .await; + assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body)); + let (status, body) = request_bytes( + &fixture, + citizen(NEIGHBOUR), + "POST", + &format!("/v1/proposals/{id}/additions/other"), + Some("\"breg-proposal-guess\""), + Some("neighbour-add"), + "text/plain", + b"not mine".to_vec(), + ) + .await; + assert_eq!( + status, + StatusCode::NOT_FOUND, + "{}", + String::from_utf8_lossy(&body) + ); + fixture.finish().await; +} + +/// Each entry order and each readability split: the self-filer reads the +/// slot exactly when the owner entry does, the subject exactly when the +/// subject entry does. +#[tokio::test] +async fn attachment_reads_follow_the_party_in_either_entry_order() { + for subject_first in [false, true] { + for owner_reads in [true, false] { + let mut project = source(); + let entries = project["accessProfiles"]["citizen"]["permissions"]["proposals"] + .as_array_mut() + .unwrap(); + assert_eq!(entries[0]["party"], "owner"); + assert_eq!(entries[1]["party"], "subject"); + entries[0]["readableAttachments"] = + json!(if owner_reads { vec!["id-scan"] } else { vec![] }); + entries[1]["readableAttachments"] = + json!(if owner_reads { vec![] } else { vec!["id-scan"] }); + if subject_first { + entries.swap(0, 1); + } + let fixture = fixture_from(&project).await; + let tag = format!("{subject_first}-{owner_reads}"); + let own = filed_with_scan( + &fixture, + citizen(CITIZEN), + CITIZEN, + &format!("matrix-own-{tag}"), + ) + .await; + let followed = filed_with_scan( + &fixture, + clerk(), + CITIZEN, + &format!("matrix-followed-{tag}"), + ) + .await; + let (own_status, own_bytes) = download_scan(&fixture, citizen(CITIZEN), own).await; + let (followed_status, followed_bytes) = + download_scan(&fixture, citizen(CITIZEN), followed).await; + let (reader, reader_bytes, refused, refused_bytes) = if owner_reads { + (own_status, own_bytes, followed_status, followed_bytes) + } else { + (followed_status, followed_bytes, own_status, own_bytes) + }; + assert_eq!(reader, StatusCode::OK, "{tag}"); + assert_eq!(reader_bytes, b"identity scan canary", "{tag}"); + assert_eq!(refused, StatusCode::NOT_FOUND, "{tag}"); + assert!( + !String::from_utf8_lossy(&refused_bytes).contains("canary"), + "{tag}" + ); + fixture.finish().await; + } + } +} diff --git a/crates/registry-breg/tests/postgres_proposal_task_authority.rs b/crates/registry-breg/tests/postgres_proposal_task_authority.rs index 1f214854e1..18598ba274 100644 --- a/crates/registry-breg/tests/postgres_proposal_task_authority.rs +++ b/crates/registry-breg/tests/postgres_proposal_task_authority.rs @@ -119,7 +119,7 @@ fn registry(automatic: bool, reviewed: bool) -> registry_breg::CompiledRegistry "proposals":[{ "action":"correct-name", "operations":["get","edit","submit","retry","cancel","apply"], - "ownership":"caller", + "party":"owner", "readableInputs":["target","value"], "targets":[{"recordType":"target","rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}] }] @@ -141,7 +141,7 @@ fn registry(automatic: bool, reviewed: bool) -> registry_breg::CompiledRegistry "proposals":[{ "action":"correct-name", "operations":["get","edit","submit","cancel"], - "ownership":"caller", + "party":"owner", "readableInputs":["target","value"], "targets":[{"recordType":"target","rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]}] }] diff --git a/crates/registry-breg/tests/postgres_read_dependencies.rs b/crates/registry-breg/tests/postgres_read_dependencies.rs index ab74ce3b1f..68e440203e 100644 --- a/crates/registry-breg/tests/postgres_read_dependencies.rs +++ b/crates/registry-breg/tests/postgres_read_dependencies.rs @@ -363,7 +363,7 @@ async fn send(app: &axum::Router, uri: &str, lookup: bool, tenant: &str) -> (Sta VerifiedRequestClaims::authenticated( "registry_principal", "test-principal", - BTreeSet::new(), + BTreeSet::from(["records:write".to_owned()]), None, BTreeMap::from([( "tenant".to_owned(), @@ -412,7 +412,7 @@ fn compiled_registry( {"id":"population","sql":"population.sql","key":"id","execution":"live","fields":[{"id":"population","type":"int64","classification":"internal"}]} ] }}, - "accessProfiles":{"reader": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"reader": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"records":[{ "recordType":"entry","operations":["create","get","list","lookup"], "readableFields":["code","active","population"], diff --git a/crates/registry-breg/tests/postgres_record_attachments.rs b/crates/registry-breg/tests/postgres_record_attachments.rs index d0985d9de9..e8ac85fe08 100644 --- a/crates/registry-breg/tests/postgres_record_attachments.rs +++ b/crates/registry-breg/tests/postgres_record_attachments.rs @@ -162,15 +162,15 @@ fn record_source() -> Value { {"recordType":"programme","rowBoundaries":jurisdiction_boundary()}, {"recordType":"application","rowBoundaries":jurisdiction_boundary()}]}], "proposals":[{"action":"rename","operations":["get","list","edit","submit","apply"], - "ownership":"caller","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"], + "party":"owner","readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"], "targets":[{"recordType":"application","rowBoundaries":jurisdiction_boundary()}]}, {"action":"enrol","operations":["get","list","edit","submit"], - "ownership":"caller","readableInputs":["name","jurisdiction","programme"],"readableAttachments":["document","note"], + "party":"owner","readableInputs":["name","jurisdiction","programme"],"readableAttachments":["document","note"], "writableAttachments":["document","note"],"targets":[ {"recordType":"programme","rowBoundaries":jurisdiction_boundary()}, {"recordType":"application","rowBoundaries":jurisdiction_boundary()}]}, {"action":"amend","operations":["get","list","edit","submit","apply"], - "ownership":"caller","readableInputs":["target","name","jurisdiction","programme"],"readableAttachments":["document"], + "party":"owner","readableInputs":["target","name","jurisdiction","programme"],"readableAttachments":["document"], "writableAttachments":["document"],"targets":[ {"recordType":"programme","rowBoundaries":jurisdiction_boundary()}, {"recordType":"application","rowBoundaries":jurisdiction_boundary()}]}]}}, @@ -2466,7 +2466,7 @@ fn overseer_source() -> Value { let mut source = record_source(); source["accessProfiles"]["overseer"] = json!({"principalClaim":"sub", "requiredScopes":["application:oversee"],"requiredPurposes":["registry-administration"], - "permissions":{"proposals":[{"action":"enrol","operations":["get"],"ownership":"caller", + "permissions":{"proposals":[{"action":"enrol","operations":["get"],"party":"owner", "targets":[{"recordType":"programme","rowBoundaries":"unrestricted"}, {"recordType":"application","rowBoundaries":jurisdiction_boundary()}]}]}}); source @@ -2717,7 +2717,7 @@ fn paired_promotion_source() -> Value { .as_array_mut() .unwrap() .push(json!({"action":"pair", - "operations":["get","list","edit","submit","apply"],"ownership":"caller", + "operations":["get","list","edit","submit","apply"],"party":"owner", "readableInputs":["name","jurisdiction","programme"], "readableAttachments":["first","second"],"writableAttachments":["first","second"], "targets":targets})); diff --git a/crates/registry-breg/tests/postgres_record_profile_conformance.rs b/crates/registry-breg/tests/postgres_record_profile_conformance.rs index 4667c572b0..35473de2e6 100644 --- a/crates/registry-breg/tests/postgres_record_profile_conformance.rs +++ b/crates/registry-breg/tests/postgres_record_profile_conformance.rs @@ -226,7 +226,7 @@ async fn real_postgres_registry_record_profile_matches_the_cross_product_semanti #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn breg_client_executes_metadata_bound_direct_writes_against_real_postgres() { let harness = PilotHarness::start("asset-site-placement").await; - let token = harness.token("asset-management", &[]); + let token = harness.token_with_scopes("asset-management", &[], &["asset:manage"]); let http_server = harness.serve_http().await; let client = BaseRegistryClient::new( BaseRegistryClientConfig::new_without_peer_policy( diff --git a/crates/registry-breg/tests/postgres_record_timer_clock.rs b/crates/registry-breg/tests/postgres_record_timer_clock.rs index c5d54ad17d..96127b2292 100644 --- a/crates/registry-breg/tests/postgres_record_timer_clock.rs +++ b/crates/registry-breg/tests/postgres_record_timer_clock.rs @@ -932,7 +932,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "accessProfiles":{"service-editor": { "default":true, "principalClaim":"registry_principal", - "requiredScopes":"unrestricted", + "requiredScopes":["records:write"], "requiredPurposes":["service-administration"], "permissions":{"records":[{ "recordType":"service", diff --git a/crates/registry-breg/tests/postgres_record_timer_retention.rs b/crates/registry-breg/tests/postgres_record_timer_retention.rs index 4bc32f98b7..f57931920d 100644 --- a/crates/registry-breg/tests/postgres_record_timer_retention.rs +++ b/crates/registry-breg/tests/postgres_record_timer_retention.rs @@ -797,7 +797,7 @@ fn timer_project_source() -> Value { }]} }}, "accessProfiles":{"service-editor": {"default":true,"principalClaim":"registry_principal", - "requiredScopes":"unrestricted","requiredPurposes":["service-administration"], + "requiredScopes":["records:write"],"requiredPurposes":["service-administration"], "permissions":{"records":[{ "recordType":"service","operations":["create","get","patch"], "readableFields":["jurisdiction","status","activates-at"], diff --git a/crates/registry-breg/tests/postgres_record_timers.rs b/crates/registry-breg/tests/postgres_record_timers.rs index e28d436106..34fcfcb4e0 100644 --- a/crates/registry-breg/tests/postgres_record_timers.rs +++ b/crates/registry-breg/tests/postgres_record_timers.rs @@ -7518,7 +7518,7 @@ fn timer_project_source() -> Value { "id":"activated","target":{"fromInput":"service"},"operation":"patch","set":{"status":{"value":"active"}} }]} }}, - "accessProfiles":{"service-editor": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"service-editor": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["service-administration"], "permissions":{"records":[{ "recordType":"service","operations":["create","get","patch"], diff --git a/crates/registry-breg/tests/postgres_reference_integrity.rs b/crates/registry-breg/tests/postgres_reference_integrity.rs index 6207d735b2..b15a169cd4 100644 --- a/crates/registry-breg/tests/postgres_reference_integrity.rs +++ b/crates/registry-breg/tests/postgres_reference_integrity.rs @@ -840,13 +840,13 @@ fn event_record_registry() -> registry_breg::CompiledRegistry { "occurredAt":{"at":"noted-on"} } }}, - "accessProfiles":{"subject-operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["operations"], + "accessProfiles":{"subject-operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"subject","operations":["create","get","patch","tombstone"], "readableFields":["jurisdiction","name"],"writableFields":["jurisdiction","name"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"recorder": {"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["operations"], + },"recorder": {"principalClaim":"principal","requiredScopes":["records:write"],"requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"decision","operations":["create","get"], "readableFields":["jurisdiction","subject","corrects","occurred-on"], @@ -1125,13 +1125,13 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { {"id":"alternate","type":"reference","target":"target","onDelete":"restrict","classification":"internal"} ] }}, - "accessProfiles":{"target-operator": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["operations"], + "accessProfiles":{"target-operator": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"target","operations":["create","get","patch","tombstone"], "readableFields":["jurisdiction","name","related"],"writableFields":["jurisdiction","name","related"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} - },"linker": {"principalClaim":"principal","requiredScopes":"unrestricted","requiredPurposes":["operations"], + },"linker": {"principalClaim":"principal","requiredScopes":["records:write"],"requiredPurposes":["operations"], "permissions":{"records":[{ "recordType":"source","operations":["create","get","patch","tombstone","batch"], "readableFields":["jurisdiction","name","target","alternate"], diff --git a/crates/registry-breg/tests/postgres_spatial_migration.rs b/crates/registry-breg/tests/postgres_spatial_migration.rs index 266fe115c9..a25cf07e77 100644 --- a/crates/registry-breg/tests/postgres_spatial_migration.rs +++ b/crates/registry-breg/tests/postgres_spatial_migration.rs @@ -927,7 +927,7 @@ fn module_bytes(variant: Variant) -> Vec { r#",{"id":"legacy","type":"string","maximumLength":16,"classification":"internal"}"# }; format!( - r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"site":{{"primaryDataset":"spatial-migration-registry","route":"sites","mutationMode":"mutable","classification":"internal","fields":[{{"id":"code","type":"string","maximumLength":16,"required":true,"classification":"internal"}}{point}{legacy}{polygon}]{geometry_field},"accessProfiles":{{"reader":{{"requiredScopes":"unrestricted","rowBoundaries":"unrestricted","principalClaim":"principal","operations":["get","list","create","patch"],"readableFields":["code"{geometry_access}],"writableFields":["code"{geometry_access}]{spatial_queries}}}}}}}}}}}"# + r#"{{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{{"site":{{"primaryDataset":"spatial-migration-registry","route":"sites","mutationMode":"mutable","classification":"internal","fields":[{{"id":"code","type":"string","maximumLength":16,"required":true,"classification":"internal"}}{point}{legacy}{polygon}]{geometry_field},"accessProfiles":{{"reader":{{"requiredScopes":["records:write"],"rowBoundaries":"unrestricted","principalClaim":"principal","operations":["get","list","create","patch"],"readableFields":["code"{geometry_access}],"writableFields":["code"{geometry_access}]{spatial_queries}}}}}}}}}}}"# ) .into_bytes() } diff --git a/crates/registry-breg/tests/postgres_spatial_storage.rs b/crates/registry-breg/tests/postgres_spatial_storage.rs index 4c7a47d525..270ac9e0f9 100644 --- a/crates/registry-breg/tests/postgres_spatial_storage.rs +++ b/crates/registry-breg/tests/postgres_spatial_storage.rs @@ -140,7 +140,7 @@ fn compiled_spatial_registry() -> registry_breg::CompiledRegistry { ], "geojson":{"geometryField":"location"} }}, - "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"site","operations":["create","get","list","patch","tombstone"], "readableFields":["code","location"],"writableFields":["code","location"], "spatialQueries":{"bbox":{"maximumLongitudeSpanDegrees":0.25,"maximumLatitudeSpanDegrees":1.5}}, @@ -173,7 +173,7 @@ fn compiled_spatial_derived_registry() -> registry_breg::CompiledRegistry { "fields":[{"id":"map-label","type":"string","maximumLength":64,"classification":"internal"}] }] }}, - "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"site","operations":["create","get","list","patch"], "readableFields":["code","location","map-label"], "writableFields":["code","location"], @@ -222,7 +222,7 @@ fn compiled_spatial_cross_entity_derived_registry() -> registry_breg::CompiledRe "fields":[{"id":"map-label","type":"string","maximumLength":96,"classification":"internal"}] }] }}, - "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "accessProfiles":{"map-reader": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"zone","operations":["create","get","list"], "readableFields":["code","label"],"writableFields":["code","label"], "rowBoundaries": "unrestricted" diff --git a/crates/registry-breg/tests/postgres_statistics_exact.rs b/crates/registry-breg/tests/postgres_statistics_exact.rs index 739160e061..9362131a43 100644 --- a/crates/registry-breg/tests/postgres_statistics_exact.rs +++ b/crates/registry-breg/tests/postgres_statistics_exact.rs @@ -91,7 +91,7 @@ fn registry_source(dimension: &str) -> Value { "filterableFields":["subject","active","category","event-date","evaluated-category"],"allowCount":true, "rowBoundaries":"unrestricted" }],"datasets":[{"dataset":"records-by-category","operations":["read-live"]}]}}, - "seed": {"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "seed": {"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"record","operations":["create"], "writableFields":["subject","active","category","event-date","amount","quantity"], "rowBoundaries":"unrestricted" diff --git a/crates/registry-breg/tests/postgres_statistics_http.rs b/crates/registry-breg/tests/postgres_statistics_http.rs index 7beb06d8bd..f8c5d8a69d 100644 --- a/crates/registry-breg/tests/postgres_statistics_http.rs +++ b/crates/registry-breg/tests/postgres_statistics_http.rs @@ -4870,7 +4870,7 @@ fn statistics_registry_source() -> Value { "readableFields":["subject","active","category","event-date","jurisdiction"], "filterableFields":["subject","active","category","event-date","jurisdiction"],"allowCount":true,"rowBoundaries":"unrestricted" }],"datasets":[{"dataset":"records-by-category","operations":["publish","read-releases"]}]}}, - "seed": {"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "seed": {"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"record","operations":["create"], "writableFields":["subject","active","category","event-date","jurisdiction"],"rowBoundaries":"unrestricted" }]}}, diff --git a/crates/registry-breg/tests/postgres_statistics_measures.rs b/crates/registry-breg/tests/postgres_statistics_measures.rs index 9025c8de32..ccd01f3284 100644 --- a/crates/registry-breg/tests/postgres_statistics_measures.rs +++ b/crates/registry-breg/tests/postgres_statistics_measures.rs @@ -651,7 +651,7 @@ fn registry_source(dimensions: &[&str], measures: Value) -> Value { "filterableFields":["subject","active","category","event-date"],"allowCount":true, "rowBoundaries":"unrestricted" }],"datasets":[{"dataset":"records-by-category","operations":["read-live"]}]}}, - "seed": {"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{"records":[{ + "seed": {"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{"records":[{ "recordType":"record","operations":["create"], "writableFields":["subject","active","category","event-date","amount","quantity"], "rowBoundaries":"unrestricted" diff --git a/crates/registry-breg/tests/postgres_tombstone_revision.rs b/crates/registry-breg/tests/postgres_tombstone_revision.rs index 4aa4938fe1..05d3cc1945 100644 --- a/crates/registry-breg/tests/postgres_tombstone_revision.rs +++ b/crates/registry-breg/tests/postgres_tombstone_revision.rs @@ -602,7 +602,7 @@ fn compiled_registry(tombstone: bool) -> registry_breg::CompiledRegistry { {{"id":"message","type":"string","maximumLength":128,"required":true,"classification":"public"}} ] }}}}, - "accessProfiles":{{"operator":{{"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{{"operator":{{"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{{"records":[{{ "recordType":"widget","operations":[{operations}], diff --git a/crates/registry-breg/tests/postgres_webhook_delivery.rs b/crates/registry-breg/tests/postgres_webhook_delivery.rs index 1d6696da63..35c2d066c2 100644 --- a/crates/registry-breg/tests/postgres_webhook_delivery.rs +++ b/crates/registry-breg/tests/postgres_webhook_delivery.rs @@ -3229,7 +3229,7 @@ const WEBHOOK_PROJECT: &[u8] = br#"{"datasets":{"test-dataset": {}}, } }] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"case","operations":["create","get","list"], @@ -3264,7 +3264,7 @@ fn local_hook_compiled_registry() -> registry_breg::CompiledRegistry { } }] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"case","operations":["create","get","list"], diff --git a/crates/registry-breg/tests/postgres_webhook_outbox.rs b/crates/registry-breg/tests/postgres_webhook_outbox.rs index acfa6a4890..107e50574b 100644 --- a/crates/registry-breg/tests/postgres_webhook_outbox.rs +++ b/crates/registry-breg/tests/postgres_webhook_outbox.rs @@ -738,7 +738,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "handler":{"type":"url","destinationId":"case-operations"} }] }}, - "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"operator": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "requiredPurposes":["case-management"], "permissions":{"records":[{ "recordType":"case","operations":["create","patch","get","list"], diff --git a/crates/registry-breg/tests/postgres_workspace_metadata.rs b/crates/registry-breg/tests/postgres_workspace_metadata.rs index 747a10c283..886de1af74 100644 --- a/crates/registry-breg/tests/postgres_workspace_metadata.rs +++ b/crates/registry-breg/tests/postgres_workspace_metadata.rs @@ -25,7 +25,7 @@ fn operation<'a>(document: &'a Value, id: &str) -> &'a Value { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn real_postgres_workspace_metadata_mutation_and_replay_contract() { let harness = PilotHarness::start("asset-site-placement").await; - let token = harness.token("asset-management", &[]); + let token = harness.token_with_scopes("asset-management", &[], &["asset:manage"]); let metadata_response = harness .send(Method::GET, "/v1/registry", Some(&token), &[], Vec::new()) .await; @@ -126,7 +126,7 @@ async fn real_postgres_workspace_metadata_mutation_and_replay_contract() { "schema and parser disagree: {document}" ); } - let planner_token = harness.token("site-planning", &[]); + let planner_token = harness.token_with_scopes("site-planning", &[], &["asset:plan"]); let planner = response_json( harness .send( diff --git a/crates/registry-breg/tests/proposal_default_grants.rs b/crates/registry-breg/tests/proposal_default_grants.rs index e4fd863866..f7af640db7 100644 --- a/crates/registry-breg/tests/proposal_default_grants.rs +++ b/crates/registry-breg/tests/proposal_default_grants.rs @@ -15,7 +15,7 @@ fn proposal_grant(operations: Value, client: &str) -> Value { "requesterClients":[client], "permissions":{"records":[ {"recordType":"case","operations":["get","list"],"readableFields":["label"],"rowBoundaries":"unrestricted"}], - "proposals":[{"action":"correct-case","operations":operations,"ownership":"caller", + "proposals":[{"action":"correct-case","operations":operations,"party":"owner", "targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]} }) } diff --git a/crates/registry-breg/tests/proposal_generated_identifier_policies.rs b/crates/registry-breg/tests/proposal_generated_identifier_policies.rs index 77df9fd355..cce53c435b 100644 --- a/crates/registry-breg/tests/proposal_generated_identifier_policies.rs +++ b/crates/registry-breg/tests/proposal_generated_identifier_policies.rs @@ -55,7 +55,7 @@ fn project() -> Value { "accessProfiles": {"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["proposals:write"], "permissions": { "actions": [{ "action": "register", @@ -68,7 +68,7 @@ fn project() -> Value { "proposals": [{ "action": "register", "operations": ["apply"], - "ownership": "caller", + "party": "owner", "targets": [{ "recordType": "registration", "rowBoundaries": "unrestricted" diff --git a/crates/registry-breg/tests/proposal_party_compiler.rs b/crates/registry-breg/tests/proposal_party_compiler.rs new file mode 100644 index 0000000000..44a20f5b26 --- /dev/null +++ b/crates/registry-breg/tests/proposal_party_compiler.rs @@ -0,0 +1,511 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A Proposal grant is bound to a party: the owner who filed it or the +//! subject it is about. The Action names where the subject comes from. + +use registry_breg::model::{CompiledActionExecution, ProposalOperation, ProposalParty}; +use registry_breg::{compile_project, parse_project_json, CompileFailure, CompileProfile}; +use serde_json::{json, Value}; + +fn targets() -> Value { + json!([{"recordType":"licence","rowBoundaries":"unrestricted"}]) +} + +/// A licence register. `desk` files for citizens; `citizen` files for +/// itself and follows Proposals filed about it. +fn project() -> Value { + json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + "project":{"id":"party-rule","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://party-rule.example.test"}, + "datasets":{"licences": {}}, + "recordTypes":{ + "licence": {"route":"licences","primaryDataset":"licences","mutationMode":"mutable","classification":"internal", + "batch":{"maximumItems":3,"maximumBytes":8192},"mutationPolicy":{"patch":"proposal-required"}, + "fields":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}, + {"id":"grade","type":"int64","required":false,"classification":"internal"}]}}, + "actions":{ + "apply-for-licence": {"execution":{"mode":"proposal","proposal":{ + "review":{"type":"none"},"application":{"mode":"manual"},"retention":{"mode":"retain"}, + "subject":{"input":"holder"}}}, + "inputs":[ + {"id":"licence","type":"reference","target":"licence","required":true,"classification":"internal"}, + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}, + {"id":"grade","type":"int64","required":false,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"stated","target":{"fromInput":"licence"},"operation":"patch", + "set":{"statement":{"fromInput":"statement"}}}]}}}, + "accessProfiles":{ + "desk": {"principalClaim":"registry_principal","requiredScopes":["licence:desk"],"actorKind":"human", + "permissions":{ + "actions":[{"action":"apply-for-licence","operations":["start"],"targets":targets()}], + "proposals":[{"action":"apply-for-licence","party":"owner","submitsFor":"anyone", + "operations":["get","list","edit","submit","cancel"], + "readableInputs":["licence","holder","statement","grade"],"targets":targets()}]}}, + "citizen": {"principalClaim":"registry_principal","requiredScopes":["licence:self"],"actorKind":"human", + "permissions":{ + "actions":[{"action":"apply-for-licence","operations":["start"],"targets":targets()}], + "proposals":[ + {"action":"apply-for-licence","party":"owner", + "operations":["get","list","edit","submit","cancel"], + "readableInputs":["licence","holder","statement","grade"],"targets":targets()}, + {"action":"apply-for-licence","party":"subject", + "operations":["get","list","cancel"], + "readableInputs":["holder","statement"],"targets":targets()}]}}} + }) +} + +fn citizen_entries(project: &mut Value) -> &mut Value { + &mut project["accessProfiles"]["citizen"]["permissions"]["proposals"] +} + +fn compile(value: &Value) -> Result { + let project = parse_project_json(&serde_json::to_vec(value).expect("project serializes"))?; + compile_project(&project, &[], CompileProfile::Authoring) +} + +fn refused(value: &Value, code: &str) -> registry_breg::Diagnostic { + let failure = match compile(value) { + Ok(_) => panic!("project compiled; expected {code}"), + Err(failure) => failure, + }; + failure + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == code) + .cloned() + .unwrap_or_else(|| panic!("expected {code}: {:?}", failure.diagnostics())) +} + +fn proposal_policy( + registry: ®istry_breg::CompiledRegistry, +) -> ®istry_breg::model::CompiledProposalPolicy { + let action = registry + .actions() + .actions + .iter() + .find(|action| action.id == "apply-for-licence") + .expect("action compiled"); + match &action.execution { + CompiledActionExecution::Proposal { proposal } => proposal, + CompiledActionExecution::Immediate => panic!("proposal execution"), + } +} + +fn revision(registry: ®istry_breg::CompiledRegistry) -> String { + registry + .actions() + .actions + .iter() + .find(|action| action.id == "apply-for-licence") + .expect("action compiled") + .definition_revision + .clone() +} + +#[test] +fn owner_and_subject_entries_compile_for_one_profile() { + let registry = compile(&project()).expect("party grants compile"); + let policy = proposal_policy(®istry); + let citizen = policy + .permissions + .iter() + .filter(|grant| grant.profile_id == "citizen") + .map(|grant| grant.party) + .collect::>(); + assert_eq!( + citizen, + [Some(ProposalParty::Owner), Some(ProposalParty::Subject)] + ); + let desk = policy + .permissions + .iter() + .find(|grant| grant.profile_id == "desk") + .expect("desk grant"); + assert!(desk.submits_for_anyone); + assert!(!policy.permissions[1].submits_for_anyone); + let subject = policy.subject.as_ref().expect("subject compiled"); + assert_eq!(subject.input, "holder"); + assert_eq!(subject.field, None); +} + +#[test] +fn the_removed_ownership_key_names_party_owner() { + let mut project = project(); + let entry = &mut project["accessProfiles"]["desk"]["permissions"]["proposals"][0]; + entry.as_object_mut().unwrap().remove("party"); + entry["ownership"] = json!("caller"); + let report = registry_breg::contract::read_project_yaml( + "registry.yaml", + &serde_json::to_vec(&project).unwrap(), + ) + .unwrap_err(); + let removed = report + .diagnostics() + .iter() + .find(|diagnostic| diagnostic.code == "config.removed-key") + .unwrap_or_else(|| panic!("{report:?}")); + let rendered = format!("{removed:?}"); + assert!(rendered.contains("party: owner"), "{rendered}"); +} + +#[test] +fn declaring_a_subject_changes_the_action_revision() { + let with_subject = revision(&compile(&project()).expect("compiles")); + let mut without = project(); + without["actions"]["apply-for-licence"]["execution"]["proposal"] + .as_object_mut() + .unwrap() + .remove("subject"); + for profile in ["desk", "citizen"] { + let entries = without["accessProfiles"][profile]["permissions"]["proposals"] + .as_array_mut() + .unwrap(); + entries.retain(|entry| entry["party"] != "subject"); + for entry in entries { + entry.as_object_mut().unwrap().remove("submitsFor"); + } + } + let without = revision(&compile(&without).expect("compiles without subject")); + assert_ne!(with_subject, without); +} + +#[test] +fn the_field_form_compiles_against_a_reference_input() { + let mut project = project(); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["subject"] = + json!({"input":"licence","field":"holder"}); + let registry = compile(&project).expect("field form compiles"); + let subject = proposal_policy(®istry).subject.clone().expect("subject"); + assert_eq!(subject.input, "licence"); + assert_eq!(subject.field.as_deref(), Some("holder")); +} + +#[test] +fn a_subject_entry_needs_a_declared_subject() { + let mut project = project(); + project["actions"]["apply-for-licence"]["execution"]["proposal"] + .as_object_mut() + .unwrap() + .remove("subject"); + project["accessProfiles"]["desk"]["permissions"]["proposals"][0] + .as_object_mut() + .unwrap() + .remove("submitsFor"); + let diagnostic = refused(&project, "breg.proposal.subject-undeclared"); + assert!(diagnostic.path.contains("citizen"), "{diagnostic:?}"); +} + +#[test] +fn the_subject_input_must_be_declared_required_and_typed() { + let subject = |value: Value| { + let mut project = project(); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["subject"] = value; + project + }; + refused( + &subject(json!({"input":"nobody"})), + "breg.proposal.subject-input-unknown", + ); + refused( + &subject(json!({"input":"grade"})), + "breg.proposal.subject-input-type", + ); + refused( + &subject(json!({"input":"statement"})), + "breg.proposal.subject-input-optional", + ); + // A reference input names a record, not a person, without a field. + refused( + &subject(json!({"input":"licence"})), + "breg.proposal.subject-input-type", + ); + // The field form reads through a reference input only. + refused( + &subject(json!({"input":"holder","field":"holder"})), + "breg.proposal.subject-input-type", + ); +} + +#[test] +fn the_subject_field_must_be_a_plaintext_string_of_the_referenced_type() { + let field = |name: &str| { + let mut project = project(); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["subject"] = + json!({"input":"licence","field":name}); + project + }; + refused(&field("grade"), "breg.proposal.subject-field-type"); + refused(&field("missing"), "breg.proposal.subject-field-type"); +} + +#[test] +fn a_subject_entry_holds_only_the_follower_operations() { + for operation in [ + "edit", + "submit", + "revise", + "rebase", + "apply", + "retry", + "get-review-context", + ] { + let mut project = project(); + citizen_entries(&mut project)[1]["operations"] = json!(["get", operation]); + let diagnostic = refused(&project, "breg.proposal.subject-operation-forbidden"); + assert!(diagnostic.message.contains(operation), "{diagnostic:?}"); + } + let mut project = project(); + citizen_entries(&mut project)[1]["operations"] = json!([ + "get", + "list", + "get-review-status", + "answer", + "add", + "cancel" + ]); + compile(&project).expect("every follower operation compiles"); +} + +#[test] +fn a_profile_holds_one_entry_per_party_and_no_unbound_entry_beside_them() { + let mut duplicate = project(); + let owner = citizen_entries(&mut duplicate)[0].clone(); + citizen_entries(&mut duplicate) + .as_array_mut() + .unwrap() + .push(owner); + let diagnostic = refused(&duplicate, "breg.proposal.permission-invalid"); + assert!(diagnostic.message.contains("owner"), "{diagnostic:?}"); + + let mut mixed = project(); + citizen_entries(&mut mixed)[0] + .as_object_mut() + .unwrap() + .remove("party"); + let diagnostic = refused(&mixed, "breg.proposal.permission-invalid"); + assert!(diagnostic.message.contains("party"), "{diagnostic:?}"); +} + +#[test] +fn submits_for_needs_submit_and_a_declared_subject() { + let mut without_submit = project(); + without_submit["accessProfiles"]["desk"]["permissions"]["proposals"][0]["operations"] = + json!(["get", "list", "edit", "cancel"]); + refused(&without_submit, "breg.proposal.submits-for-invalid"); + + let mut without_subject = project(); + without_subject["actions"]["apply-for-licence"]["execution"]["proposal"] + .as_object_mut() + .unwrap() + .remove("subject"); + citizen_entries(&mut without_subject) + .as_array_mut() + .unwrap() + .truncate(1); + refused(&without_subject, "breg.proposal.submits-for-invalid"); +} + +#[test] +fn a_subject_entry_is_for_people() { + for kind in ["service", "agent"] { + let mut project = project(); + project["accessProfiles"]["citizen"]["actorKind"] = json!(kind); + citizen_entries(&mut project) + .as_array_mut() + .unwrap() + .remove(0); + project["accessProfiles"]["citizen"]["permissions"]["actions"] = json!([]); + let diagnostic = refused(&project, "breg.proposal.permission-invalid"); + assert!(diagnostic.message.contains("subject"), "{diagnostic:?}"); + } +} + +#[test] +fn an_open_profile_with_a_subject_entry_uses_sub() { + let mut project = project(); + // A follower that writes nothing, so only the principal rule applies. + project["accessProfiles"]["citizen"]["requiredScopes"] = json!("unrestricted"); + project["accessProfiles"]["citizen"]["permissions"]["actions"] = json!([]); + citizen_entries(&mut project) + .as_array_mut() + .unwrap() + .remove(0); + citizen_entries(&mut project)[0]["operations"] = json!(["get", "list"]); + refused(&project, "breg.access.open-subject-principal-not-sub"); + project["accessProfiles"]["citizen"]["principalClaim"] = json!("sub"); + compile(&project).expect("an open subject profile on sub compiles"); +} + +#[test] +fn review_progress_is_open_to_either_party() { + let mut project = project(); + project["reviewAuthorities"] = + json!({"licensing": {"protocol":"id.registrystack.org/protocols/review/v1"}}); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["review"] = json!({"type":"required","authority":"licensing","source":"licence-applications","policy":{"id":"licence-review"}}); + for index in [0, 1] { + let entry = &mut citizen_entries(&mut project)[index]; + entry["operations"] + .as_array_mut() + .unwrap() + .push(json!("get-review-status")); + entry["readableReviewProgress"] = json!(true); + } + let registry = compile(&project).expect("either party may read review progress"); + assert!(proposal_policy(®istry) + .permissions + .iter() + .filter(|grant| grant.profile_id == "citizen") + .all(|grant| grant.readable_review_progress + && grant + .operations + .contains(&ProposalOperation::GetReviewStatus))); +} + +#[test] +fn a_compiled_grant_from_an_earlier_package_keeps_its_meaning() { + let registry = compile(&project()).expect("compiles"); + let mut owner = serde_json::to_value(&proposal_policy(®istry).permissions[0]).unwrap(); + assert_eq!(owner["party"], "owner"); + owner.as_object_mut().unwrap().remove("party"); + let mut staff = owner.clone(); + owner["ownership"] = json!("caller"); + staff["ownership"] = Value::Null; + let owner: registry_breg::model::CompiledProposalPermission = + serde_json::from_value(owner).expect("a stored owner grant loads"); + let staff: registry_breg::model::CompiledProposalPermission = + serde_json::from_value(staff).expect("a stored unbound grant loads"); + assert_eq!(owner.party, Some(ProposalParty::Owner)); + assert_eq!(staff.party, None); + assert_eq!( + serde_json::to_value(&owner).unwrap()["party"], + "owner", + "a loaded grant serializes under its current name" + ); +} + +/// The field-form project with a `district` on each licence and an `editor` +/// profile whose record grant may Patch `holder` under `rows`. +fn field_subject_with_editor(rows: Value) -> Value { + let mut project = project(); + project["recordTypes"]["licence"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"district","type":"string","maximumLength":32,"required":false,"classification":"internal"})); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["subject"] = + json!({"input":"licence","field":"holder"}); + project["accessProfiles"]["editor"] = json!({"principalClaim":"registry_principal","requiredScopes":["licence:edit"], + "actorKind":"human","permissions":{"records":[{"recordType":"licence","operations":["get","patch"], + "readableFields":["holder","district"],"writableFields":["holder"],"rowBoundaries":rows}]}}); + project +} + +#[test] +fn a_bounded_writer_cannot_choose_who_a_subject_field_names() { + let diagnostic = refused( + &field_subject_with_editor( + json!([{"field":"district","claim":"district","operator":"equals"}]), + ), + "breg.proposal.subject-field-write", + ); + assert!( + diagnostic.path.contains("editor") && diagnostic.path.contains("licence"), + "{diagnostic:?}" + ); + // An unrestricted writer is trusted to decide who a Record is about. + compile(&field_subject_with_editor(json!("unrestricted"))) + .expect("an unrestricted writer of the subject field compiles"); + // A writer bounded to rows that name themselves can only name themselves. + compile(&field_subject_with_editor(json!([ + {"field":"holder","claim":"registry_principal","operator":"equals"} + ]))) + .expect("a writer bounded on the subject field by its own principal compiles"); +} + +#[test] +fn a_bounded_immediate_action_cannot_set_a_subject_field() { + let mut project = field_subject_with_editor(json!("unrestricted")); + // Immediate writes need a Record type without reviewed change control. + project["recordTypes"]["licence"] + .as_object_mut() + .unwrap() + .remove("mutationPolicy"); + project["actions"]["reassign-licence"] = json!({"execution":{"mode":"immediate"}, + "inputs":[ + {"id":"licence","type":"reference","target":"licence","required":true,"classification":"internal"}, + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"reassigned","target":{"fromInput":"licence"},"operation":"patch", + "set":{"holder":{"fromInput":"holder"}}}]}}); + project["accessProfiles"]["editor"]["permissions"]["actions"] = json!([{"action":"reassign-licence", + "operations":["invoke"],"results":[], + "targets":[{"recordType":"licence","rowBoundaries":[{"field":"district","claim":"district","operator":"equals"}]}]}]); + let diagnostic = refused(&project, "breg.proposal.subject-field-write"); + assert!( + diagnostic.path.contains("reassign-licence"), + "{diagnostic:?}" + ); + project["accessProfiles"]["editor"]["permissions"]["actions"][0]["targets"][0] + ["rowBoundaries"] = json!("unrestricted"); + compile(&project).expect("an unrestricted Action grant may set the subject field"); +} + +#[test] +fn the_input_form_puts_no_rule_on_record_writers() { + let mut project = field_subject_with_editor( + json!([{"field":"district","claim":"district","operator":"equals"}]), + ); + project["actions"]["apply-for-licence"]["execution"]["proposal"]["subject"] = + json!({"input":"holder"}); + compile(&project).expect("only a designating field is authority-bearing"); +} + +/// A Proposal Action that patches `holder` from an input, started and +/// submitted by the citizen under targets bounded by district. +fn self_reassign(review: Value, application: Value) -> Value { + let district = json!([{"field":"district","claim":"district","operator":"equals"}]); + let mut project = field_subject_with_editor(json!("unrestricted")); + project["actions"]["self-reassign"] = json!({"execution":{"mode":"proposal","proposal":{ + "review":review,"application":application,"retention":{"mode":"retain"}}}, + "inputs":[ + {"id":"licence","type":"reference","target":"licence","required":true,"classification":"internal"}, + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"reassigned","target":{"fromInput":"licence"},"operation":"patch", + "set":{"holder":{"fromInput":"holder"}}}]}}); + project["accessProfiles"]["citizen"]["permissions"]["actions"] + .as_array_mut() + .unwrap() + .push(json!({"action":"self-reassign","operations":["start"], + "targets":[{"recordType":"licence","rowBoundaries":district.clone()}]})); + project["accessProfiles"]["citizen"]["permissions"]["proposals"] + .as_array_mut() + .unwrap() + .push( + json!({"action":"self-reassign","party":"owner","operations":["get","edit","submit"], + "readableInputs":["licence","holder"], + "targets":[{"recordType":"licence","rowBoundaries":district}]}), + ); + project +} + +#[test] +fn a_proposal_applied_with_no_one_in_the_loop_cannot_set_a_subject_field() { + let diagnostic = refused( + &self_reassign(json!({"type":"none"}), json!({"mode":"automatic"})), + "breg.proposal.subject-field-write", + ); + assert!(diagnostic.path.contains("self-reassign"), "{diagnostic:?}"); + // A person applies it, or a reviewer decides it. + compile(&self_reassign( + json!({"type":"none"}), + json!({"mode":"manual"}), + )) + .expect("a manually applied Proposal may set the subject field"); + let mut reviewed = self_reassign( + json!({"type":"required","authority":"licensing","source":"licence-applications","policy":{"id":"licence-review"}}), + json!({"mode":"automatic"}), + ); + reviewed["reviewAuthorities"] = + json!({"licensing": {"protocol":"id.registrystack.org/protocols/review/v1"}}); + compile(&reviewed).expect("a reviewed Proposal may set the subject field"); +} diff --git a/crates/registry-breg/tests/proposal_status_contract.rs b/crates/registry-breg/tests/proposal_status_contract.rs index 1ca62f7e66..0a55dcd8b3 100644 --- a/crates/registry-breg/tests/proposal_status_contract.rs +++ b/crates/registry-breg/tests/proposal_status_contract.rs @@ -249,6 +249,9 @@ fn every_proposal_error_response_declares_its_problem_body() { if id == "proposals.get-submission" { expected.insert(Code::ProposalSubmissionExpired); } + if id == "proposals.submit" { + expected.extend([Code::ProposalSubjectNotCaller, Code::ProposalSubjectChanged]); + } let actual = operation["responses"] .as_object() .unwrap() diff --git a/crates/registry-breg/tests/refactor_contract.rs b/crates/registry-breg/tests/refactor_contract.rs index 4f340e1b7b..e831cf37d4 100644 --- a/crates/registry-breg/tests/refactor_contract.rs +++ b/crates/registry-breg/tests/refactor_contract.rs @@ -1460,7 +1460,7 @@ fn applicant_review_progress_is_explicit_caller_owned_status_authority() { .unwrap(); assert_eq!(original.definition_revision, action.definition_revision); - for (field, value) in [("ownership", Value::Null), ("operations", json!(["get"]))] { + for (field, value) in [("party", Value::Null), ("operations", json!(["get"]))] { let mut invalid = source.clone(); let grant = &mut &mut invalid["accessProfiles"]["facility-correction-author"] ["permissions"]["proposals"][0]; @@ -1828,7 +1828,7 @@ fn retired_authoring_keys_point_to_governed_replacements() { ), ( "/recordTypes/directory-entry/accessProfiles/reader/requestVisibility", - "ownership: caller", + "party: owner", ), ( "/recordTypes/directory-entry/accessProfiles/reader/readableRequestFields", diff --git a/crates/registry-breg/tests/row_boundary_sets.rs b/crates/registry-breg/tests/row_boundary_sets.rs index a2984e4f1c..70d7c226da 100644 --- a/crates/registry-breg/tests/row_boundary_sets.rs +++ b/crates/registry-breg/tests/row_boundary_sets.rs @@ -41,7 +41,7 @@ fn inline() -> Value { "rowBoundaries":[boundary()]}], "actions":[{"action":"register","operations":["invoke"], "targets":[{"recordType":"entry","rowBoundaries":[boundary()]}]}], - "proposals":[{"action":"register","operations":["get"],"ownership":"caller", + "proposals":[{"action":"register","operations":["get"],"party":"owner", "targets":[{"recordType":"entry","rowBoundaries":[boundary()]}]}] }}} }) diff --git a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs index a3dae22d64..32aa3fc7f8 100644 --- a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs +++ b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs @@ -39,9 +39,10 @@ const SOURCE_REVISION: &str = "rehearsal-source-revision"; // live/erased shape constraints for stripped Record/Proposal attachment // erasure markers. The migration ledger bounds statement checksums at 4,096 entries. // The fingerprint also includes the Proposal additions and review ask tables -// and their indexes, and the application-rebase blocked reason. +// and their indexes, the application-rebase blocked reason, and the Proposal +// subject reference column and its partial index. const PORTABLE_SCHEMA_FINGERPRINT: &str = - "sha256:43d9c4d56b2737426e3fa5bc0b15adc3120d0c90ca4ba708b39219f541800ba8"; + "sha256:e0aa036bd82f0274b567be71a63f573cb2dc16e19de231c65f4eed701c081688"; const FIXTURE_JOURNEYS: &[u8] = br#"apiVersion: id.registrystack.org/formats/breg/journeys/v1 kind: BRegJourneys journeys: [] diff --git a/crates/registry-breg/tests/script_baseline.rs b/crates/registry-breg/tests/script_baseline.rs index 0a5d2ef06c..31565f50b6 100644 --- a/crates/registry-breg/tests/script_baseline.rs +++ b/crates/registry-breg/tests/script_baseline.rs @@ -37,7 +37,7 @@ fn action(script: &str) -> CompiledAction { "refusals":[{"code":"blank-label","label":"A label is required."}], "writes":[{"id":"record","target":{"recordType":"record"},"operation":"create","fields":["label","count","amount"]}] }}}, - "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":"unrestricted","permissions":{ + "accessProfiles":{"writer": {"default":true,"principalClaim":"principal","requiredScopes":["records:write"],"permissions":{ "actions":[ {"action":"register-record","operations":["invoke"],"targets":[{"recordType":"record","rowBoundaries":"unrestricted"}],"results":["record"]} ] diff --git a/crates/registry-breg/tests/standing_agent_ceiling.rs b/crates/registry-breg/tests/standing_agent_ceiling.rs index 80076c154b..1cd0ca8b19 100644 --- a/crates/registry-breg/tests/standing_agent_ceiling.rs +++ b/crates/registry-breg/tests/standing_agent_ceiling.rs @@ -48,7 +48,7 @@ fn project() -> Value { "plan":{"type":"fixed","effects":[{"id":"corrected","target":{"fromInput":"case-ref"},"operation":"patch","set":{"label":{"fromInput":"new-label"}}}]}} }, "accessProfiles":{ - "clerk": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted","actorKind":"human","requesterClients":["clerk-portal"], + "clerk": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"],"actorKind":"human","requesterClients":["clerk-portal"], "permissions":{"records":[ {"recordType":"case","operations":["create","get","list","import"],"readableFields":["label"],"writableFields":["label"],"rowBoundaries":"unrestricted"}, {"recordType":"memo","operations":["create","get","list","patch"],"readableFields":["label"],"writableFields":["label"],"rowBoundaries":"unrestricted"}, @@ -56,14 +56,14 @@ fn project() -> Value { "actions":[ {"action":"relabel-note","operations":["invoke"],"targets":[{"recordType":"note","rowBoundaries":"unrestricted"}],"results":["relabelled"]}, {"action":"correct-case","operations":["start"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}], - "proposals":[{"action":"correct-case","operations":["get","list","edit","submit","revise","cancel","apply","rebase","retry","get-review-status"],"ownership":"caller","readableInputs":["case-ref","new-label"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]}}, - "assistant": {"principalClaim":"registry_principal","requiredScopes":"unrestricted","actorKind":"agent","requesterClients":["assistant-client"], + "proposals":[{"action":"correct-case","operations":["get","list","edit","submit","revise","cancel","apply","rebase","retry","get-review-status"],"party":"owner","readableInputs":["case-ref","new-label"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]}}, + "assistant": {"principalClaim":"registry_principal","requiredScopes":["proposals:draft"],"actorKind":"agent","requesterClients":["assistant-client"], "permissions":{"records":[ {"recordType":"case","operations":["get","list"],"readableFields":["label"],"rowBoundaries":"unrestricted"}, {"recordType":"memo","operations":["get","list"],"readableFields":["label"],"writableFields":["label"],"rowBoundaries":"unrestricted"}, {"recordType":"note","operations":["get","list"],"readableFields":["label"],"writableFields":["label"],"rowBoundaries":"unrestricted"}], "actions":[{"action":"correct-case","operations":["start"],"targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}], - "proposals":[{"action":"correct-case","operations":["edit"],"ownership":"caller","targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]}} + "proposals":[{"action":"correct-case","operations":["edit"],"party":"owner","targets":[{"recordType":"case","rowBoundaries":"unrestricted"}]}]}} } }) } @@ -172,7 +172,7 @@ fn standing_agent_may_hold_only_bounded_review_context_disclosure() { value["accessProfiles"]["assistant"]["permissions"]["proposals"][0] .as_object_mut() .expect("proposal permission") - .remove("ownership"); + .remove("party"); value["accessProfiles"]["assistant"]["permissions"]["proposals"][0]["readableContextFields"] = json!(["currentLabel", "proposedLabel"]); @@ -210,7 +210,7 @@ fn standing_agent_review_context_requires_an_exact_requester_client() { value["accessProfiles"]["assistant"]["permissions"]["proposals"][0] .as_object_mut() .expect("proposal permission") - .remove("ownership"); + .remove("party"); value["accessProfiles"]["assistant"]["permissions"]["proposals"][0]["readableContextFields"] = json!(["currentLabel", "proposedLabel"]); value["accessProfiles"]["assistant"] @@ -241,7 +241,7 @@ fn imported_proposal_action_uses_the_global_requester_client_binding() { value["accessProfiles"]["assistant"]["permissions"]["proposals"][0] .as_object_mut() .expect("proposal permission") - .remove("ownership"); + .remove("party"); value["accessProfiles"]["assistant"]["permissions"]["proposals"][0]["readableContextFields"] = json!(["currentLabel", "proposedLabel"]); value["accessProfiles"]["assistant"] @@ -337,10 +337,10 @@ fn standing_agent_cannot_hold_a_proposal_lifecycle_decision() { assert!(!codes(&failure).contains(&DIRECT_MUTATION_FORBIDDEN)); } let mut value = project(); - value["accessProfiles"]["assistant"]["permissions"]["proposals"][0]["ownership"] = json!("any"); + value["accessProfiles"]["assistant"]["permissions"]["proposals"][0]["party"] = json!("any"); assert!( parse_project_json(&serde_json::to_vec(&value).unwrap()).is_err(), - "ownership has no any-caller escape" + "party has no any-caller escape" ); } diff --git a/crates/registry-breg/tests/steward_authoring.rs b/crates/registry-breg/tests/steward_authoring.rs new file mode 100644 index 0000000000..908211de3d --- /dev/null +++ b/crates/registry-breg/tests/steward_authoring.rs @@ -0,0 +1,1130 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Authoring rules for an organisation steward: a person who may manage the +//! members of the organisations a live stewardship record names, and nothing +//! else. The steward reads their organisation by its own identifier, reads and +//! changes its members through two bounded Actions, and can never write a +//! stewardship. + +#![cfg(all(feature = "runtime", feature = "tooling"))] + +use registry_breg::compiler::{compile_project, CompileProfile}; +use registry_breg::diagnostics::CompileFailure; +use registry_breg::{parse_project_yaml, CompiledRegistry}; +use serde_json::{json, Value}; + +const PROJECT: &[u8] = + include_bytes!("../../../products/breg/fixtures/organization-membership-access/registry.yaml"); +const STEWARD: &str = "organisation-steward"; + +fn compile(project: &Value) -> Result { + let source = parse_project_yaml(&serde_json::to_vec_pretty(project).unwrap())?; + compile_project(&source, &[], CompileProfile::Authoring) +} + +fn compile_production(project: &Value) -> Result { + let mut project = project.clone(); + project["package"] = json!({"sourceRevision":"steward-authoring-test"}); + let source = parse_project_yaml(&serde_json::to_vec_pretty(&project).unwrap())?; + compile_project(&source, &[], CompileProfile::Production) +} + +fn assert_compiles(project: &Value) { + if let Err(failure) = compile(project) { + panic!( + "the steward project must compile: {:?}", + failure.diagnostics() + ); + } +} + +fn assert_refused(project: &Value, code: &str) { + let failure = compile(project).expect_err("the project must be refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code), + "wanted {code}: {:?}", + failure.diagnostics() + ); +} + +fn assert_refused_at(project: &Value, code: &str, path: &str) { + let failure = compile(project).expect_err("the project must be refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code && diagnostic.path == path), + "wanted {code} at {path}: {:?}", + failure.diagnostics() + ); +} + +/// The membership fixture with a separate `stewardship` source: a leaf that +/// only a registrar writes, keyed like `membership` by organisation. +fn base() -> Value { + let mut project: Value = serde_json::from_slice(PROJECT).unwrap(); + let mut stewardship = project["recordTypes"]["membership"].clone(); + stewardship["route"] = json!("stewardships"); + stewardship["indexes"][0]["id"] = json!("stewardship-principal-key"); + project["recordTypes"]["stewardship"] = stewardship; + project["recordTypes"]["membership"]["tombstone"] = json!(true); + project["accessProfiles"][STEWARD] = json!({ + "principalClaim":"principal", + "requiredScopes":["records:read","membership:use"], + "permissions":{"records":[]} + }); + project +} + +fn stewards(project: &mut Value) -> &mut Vec { + project["accessProfiles"][STEWARD]["permissions"]["records"] + .as_array_mut() + .unwrap() +} + +/// The steward reads their organisation by its own canonical identifier. +fn with_organisation_read(mut project: Value) -> Value { + stewards(&mut project).push(json!({ + "recordType":"organization", + "rowBoundaries":[{"field":"id","membership":"stewardship"}], + "operations":["get","list"], + "readableFields":["name"] + })); + project +} + +/// The steward reads the members of the organisations they steward: one +/// level of membership over `membership`, through the separate leaf. +fn with_member_read(mut project: Value) -> Value { + stewards(&mut project).push(json!({ + "recordType":"membership", + "rowBoundaries":[{"field":"organization","membership":"stewardship"}], + "operations":["get","list"], + "readableFields":["organization","principal","active"] + })); + project +} + +/// The two bounded Actions, granted on targets the steward's stewardship +/// bounds. The steward holds no direct write on `membership`. +fn with_actions(mut project: Value) -> Value { + project["actions"] = json!({ + "appoint-member": { + "execution":{"mode":"immediate"}, + "inputs":[ + {"id":"organization","type":"reference","target":"organization","required":true, + "classification":"internal"}, + {"id":"principal","type":"string","maximumLength":80,"required":true, + "classification":"restricted"} + ], + "plan":{"type":"fixed","effects":[{ + "id":"membership","target":{"recordType":"membership"},"operation":"create", + "set":{"organization":{"fromInput":"organization"}, + "principal":{"fromInput":"principal"},"active":{"value":true}} + }]} + }, + "remove-member": { + "execution":{"mode":"immediate","concurrency":"current-revision"}, + "inputs":[{"id":"membership","type":"reference","target":"membership","required":true, + "classification":"internal"}], + "commitGuards":{"targets":[{"input":"membership","field":"active","equals":true, + "reason":"membership-inactive"}]}, + "plan":{"type":"fixed","effects":[{ + "id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}} + }]} + } + }); + let bounded = json!([{"field":"organization","membership":"stewardship"}]); + let own = json!([{"field":"id","membership":"stewardship"}]); + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"appoint-member","operations":["invoke"],"results":["membership"], + "targets":[{"recordType":"membership","rowBoundaries":bounded.clone()}, + {"recordType":"organization","rowBoundaries":own}]}, + {"action":"remove-member","operations":["invoke"],"results":["membership"], + "targets":[{"recordType":"membership","rowBoundaries":bounded}]} + ]); + project +} + +fn steward_project() -> Value { + with_actions(with_member_read(with_organisation_read(base()))) +} + +// The canonical identifier as a membership boundary field. + +#[test] +fn a_membership_boundary_may_name_the_protected_record_types_own_identifier() { + assert_compiles(&with_organisation_read(base())); +} + +#[test] +fn the_identifier_field_is_refused_when_the_key_references_another_record_type() { + let mut project = base(); + stewards(&mut project).push(json!({ + "recordType":"facility", + "rowBoundaries":[{"field":"id","membership":"stewardship"}], + "operations":["get"], + "readableFields":["label"] + })); + assert_refused(&project, "breg.access.membership-key-type"); +} + +#[test] +fn the_identifier_field_bounds_reads_and_referenced_targets_only() { + // A write bounded by the row's own identifier is refused: a create has + // no identifier to probe, and the steward needs only reads and the + // reference their Actions check. + let mut project = with_organisation_read(base()); + let grant = &mut stewards(&mut project)[0]; + grant["operations"] = json!(["get", "patch"]); + grant["writableFields"] = json!(["name"]); + assert_refused(&project, "breg.access.membership-key-type"); + + let mut project = steward_project(); + project["actions"]["rename-organisation"] = json!({ + "execution":{"mode":"immediate"}, + "inputs":[{"id":"organization","type":"reference","target":"organization","required":true, + "classification":"internal"}], + "plan":{"type":"fixed","effects":[{ + "id":"organization","target":{"fromInput":"organization"},"operation":"patch", + "set":{"name":{"value":"renamed"}} + }]} + }); + project["accessProfiles"][STEWARD]["permissions"]["actions"] + .as_array_mut() + .unwrap() + .push(json!({"action":"rename-organisation","operations":["invoke"],"results":["organization"], + "targets":[{"recordType":"organization", + "rowBoundaries":[{"field":"id","membership":"stewardship"}]}]})); + assert_refused(&project, "breg.access.membership-key-type"); +} + +// One level of membership over a different leaf. + +#[test] +fn one_level_of_membership_over_a_different_leaf_compiles() { + assert_compiles(&with_member_read(base())); +} + +#[test] +fn a_membership_source_bounded_by_itself_stays_refused() { + let mut project = base(); + stewards(&mut project).push(json!({ + "recordType":"membership", + "rowBoundaries":[{"field":"organization","membership":"membership"}], + "operations":["get"], + "readableFields":["organization"] + })); + assert_refused(&project, "breg.access.membership-source-recursive"); +} + +#[test] +fn a_chain_of_two_membership_levels_stays_refused() { + // `membership` over `stewardship` is one level. Bounding `stewardship` + // over `membership` as well makes a chain, which stays refused. + let mut project = with_member_read(base()); + stewards(&mut project).push(json!({ + "recordType":"stewardship", + "rowBoundaries":[{"field":"organization","membership":"membership"}], + "operations":["get"], + "readableFields":["organization"] + })); + assert_refused(&project, "breg.access.membership-source-recursive"); +} + +#[test] +fn a_leaf_source_with_an_incoming_read_path_stays_refused() { + let mut project = with_member_read(base()); + project["recordTypes"]["organization"]["readPaths"] = + json!([{"id":"stewards","through":"stewardship","to":"facility","route":"stewards"}]); + assert_refused(&project, "breg.access.membership-source-recursive"); +} + +// The steward's two Actions. + +#[test] +fn the_steward_project_compiles_for_production() { + if let Err(failure) = compile_production(&steward_project()) { + panic!( + "Production must admit the steward's bounded Actions: {:?}", + failure.diagnostics() + ); + } +} + +#[test] +fn a_steward_profile_without_scopes_cannot_change_members() { + let mut project = steward_project(); + project["accessProfiles"][STEWARD]["requiredScopes"] = json!("unrestricted"); + project["accessProfiles"][STEWARD]["requesterClients"] = json!(["bounded-client"]); + assert_refused(&project, "breg.access.scopeless-membership-source-write"); +} + +#[test] +fn a_chain_through_an_action_target_stays_refused() { + // Bounding a `stewardship` Action target by `membership` makes the leaf + // that `membership` relies on depend on `membership` in turn. + let mut project = with_member_read(base()); + project["actions"] = json!({"confirm-stewardship": { + "execution":{"mode":"immediate"}, + "inputs":[{"id":"stewardship","type":"reference","target":"stewardship","required":true, + "classification":"internal"}], + "plan":{"type":"fixed","effects":[{ + "id":"stewardship","target":{"fromInput":"stewardship"},"operation":"patch", + "set":{"active":{"value":true}} + }]} + }}); + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"confirm-stewardship","operations":["invoke"],"results":["stewardship"], + "targets":[{"recordType":"stewardship", + "rowBoundaries":[{"field":"organization","membership":"membership"}]}]} + ]); + assert_refused(&project, "breg.access.membership-source-recursive"); +} + +#[test] +fn a_membership_source_over_a_source_that_is_not_a_leaf_stays_refused() { + // `membership` is one level over `stewardship`. A third source bounded + // by `membership` would be a second level. + let mut project = with_member_read(base()); + let mut delegation = project["recordTypes"]["membership"].clone(); + delegation["route"] = json!("delegations"); + delegation["indexes"][0]["id"] = json!("delegation-principal-key"); + project["recordTypes"]["delegation"] = delegation; + stewards(&mut project).push(json!({ + "recordType":"delegation", + "rowBoundaries":[{"field":"organization","membership":"membership"}], + "operations":["get"], + "readableFields":["organization"] + })); + assert_refused(&project, "breg.access.membership-source-recursive"); +} + +// The maintained example. + +#[test] +fn the_organisation_stewardship_example_and_its_journey_validate_for_production() { + let directory = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../products/breg/examples/organisation-stewardship"); + let read = |path: &str| std::fs::read(directory.join(path)).expect("example file"); + let source = parse_project_yaml(&read("registry.yaml")).expect("the example parses"); + let registry = compile_project(&source, &[], CompileProfile::Production) + .unwrap_or_else(|failure| panic!("{:?}", failure.diagnostics())); + // remove-member runs at the current revision, so its journey step sends + // no preconditions, exactly as the Action's HTTP descriptor says. + let suite = + registry_breg::fixtures::validate_fixture_journeys(&read("tests/journeys.yaml"), ®istry) + .unwrap_or_else(|error| panic!("{error}")); + assert_eq!(suite.journey_ids(), ["organisation-steward"]); +} + +// Chains through targets. Each removes one arm of the leaf check. + +/// A third membership source, keyed like the other two. +fn with_delegation(mut project: Value) -> Value { + let mut delegation = project["recordTypes"]["membership"].clone(); + delegation["route"] = json!("delegations"); + delegation["indexes"][0]["id"] = json!("delegation-principal-key"); + project["recordTypes"]["delegation"] = delegation; + project +} + +fn stewardship_action(mode: &str) -> Value { + let execution = if mode == "proposal" { + json!({"mode":"proposal","proposal":{"review":{"type":"none"}, + "application":{"mode":"manual"},"retention":{"mode":"operator-erase"}}}) + } else { + json!({"mode":"immediate"}) + }; + json!({ + "execution": execution, + "inputs":[{"id":"stewardship","type":"reference","target":"stewardship","required":true, + "classification":"internal"}], + "plan":{"type":"fixed","effects":[{ + "id":"stewardship","target":{"fromInput":"stewardship"},"operation":"patch", + "set":{"active":{"value":false}} + }]} + }) +} + +#[test] +fn a_two_level_chain_through_an_action_target_is_refused() { + // membership is bounded over stewardship by a Record grant, and + // stewardship is an Action target bounded over delegation: two levels. + let mut project = with_delegation(with_member_read(base())); + project["actions"] = json!({"end-stewardship": stewardship_action("immediate")}); + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"end-stewardship","operations":["invoke"],"results":["stewardship"], + "targets":[{"recordType":"stewardship", + "rowBoundaries":[{"field":"organization","membership":"delegation"}]}]} + ]); + assert_refused_at( + &project, + "breg.access.membership-source-recursive", + "recordTypes[id=membership].membership", + ); +} + +#[test] +fn a_two_level_chain_through_a_proposal_target_is_refused() { + let mut project = with_delegation(with_member_read(base())); + project["actions"] = json!({"end-stewardship": stewardship_action("proposal")}); + let bounded = json!([{"field":"organization","membership":"delegation"}]); + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"end-stewardship","operations":["start"], + "targets":[{"recordType":"stewardship","rowBoundaries":"unrestricted"}]} + ]); + project["accessProfiles"][STEWARD]["permissions"]["proposals"] = json!([ + {"action":"end-stewardship","operations":["get","submit","apply"],"party":"owner", + "targets":[{"recordType":"stewardship","rowBoundaries":bounded}]} + ]); + assert_refused_at( + &project, + "breg.access.membership-source-recursive", + "recordTypes[id=membership].membership", + ); +} + +// The identifier boundary on every kind of write. + +fn with_organisation_write(mut project: Value, action: Value, proposal: bool) -> Value { + project["actions"] = json!({"change-organisation": action}); + let own = json!([{"field":"id","membership":"stewardship"}]); + if proposal { + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"change-organisation","operations":["start"], + "targets":[{"recordType":"organization","rowBoundaries":"unrestricted"}]} + ]); + project["accessProfiles"][STEWARD]["permissions"]["proposals"] = json!([ + {"action":"change-organisation","operations":["get","submit","apply"], + "party":"owner","targets":[{"recordType":"organization","rowBoundaries":own}]} + ]); + } else { + project["accessProfiles"][STEWARD]["permissions"]["actions"] = json!([ + {"action":"change-organisation","operations":["invoke"],"results":["organization"], + "targets":[{"recordType":"organization","rowBoundaries":own}]} + ]); + } + project +} + +fn rename(mode: &str) -> Value { + let mut action = stewardship_action(mode); + action["inputs"][0] = json!({"id":"organization","type":"reference","target":"organization", + "required":true,"classification":"internal"}); + action["plan"] = json!({"type":"fixed","effects":[{ + "id":"organization","target":{"fromInput":"organization"},"operation":"patch", + "set":{"name":{"value":"renamed"}} + }]}); + action +} + +#[test] +fn the_identifier_field_cannot_bound_any_kind_of_write() { + let path = "accessProfiles[id=organisation-steward].permissions.actions[action=change-organisation].targets[recordType=organization].rowBoundaries[membership=stewardship:field=id]"; + // A create target. + let mut create = rename("immediate"); + create["inputs"] = json!([]); + create["plan"] = json!({"type":"fixed","effects":[{ + "id":"organization","target":{"recordType":"organization"},"operation":"create", + "set":{"name":{"value":"new"}} + }]}); + assert_refused_at( + &with_organisation_write(base(), create, false), + "breg.access.membership-key-type", + path, + ); + // A Proposal target. + assert_refused_at( + &with_organisation_write(base(), rename("proposal"), true), + "breg.access.membership-key-type", + "accessProfiles[id=organisation-steward].permissions.proposals[action=change-organisation].targets[recordType=organization].rowBoundaries[membership=stewardship:field=id]", + ); + // A function plan's write ceiling. + let mut function = rename("immediate"); + function["plan"] = json!({"type":"scripted","actionPlan":"rename","inputs":["organization"], + "writes":[{"id":"organization","target":{"fromInput":"organization"}, + "operation":"patch","fields":["name"]}]}); + let mut project = with_organisation_write(base(), function, false); + project["actionPlans"] = json!({"rename": {"runtime":"rhai","source":"scripts/rename.rhai", + "entrypoint":"handle","abi":"registry.action-plan/v1"}}); + let failure = compile_with_script(&project, "organization").expect_err("refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| { + diagnostic.code == "breg.access.membership-key-type" && diagnostic.path == path + }), + "{:?}", + failure.diagnostics() + ); + // Batch and Import Record grants. + for operation in ["batch", "import"] { + let mut project = base(); + stewards(&mut project).push(json!({ + "recordType":"organization","rowBoundaries":[{"field":"id","membership":"stewardship"}], + "operations":["get", operation],"readableFields":["name"],"writableFields":["name"] + })); + assert_refused(&project, "breg.access.membership-key-type"); + } +} + +/// Compile with the script the function plan names. It returns one empty +/// effect for `effect`; the checks under test never run it. +fn compile_with_script(project: &Value, effect: &str) -> Result { + use registry_breg::compiler::compile_project_with_assets; + use registry_breg::contract::ModuleAssetSource; + let source = parse_project_yaml(&serde_json::to_vec_pretty(project).unwrap())?; + compile_project_with_assets( + &source, + &[], + &[ModuleAssetSource { + module: None, + path: "scripts/rename.rhai".to_owned(), + bytes: format!(r#"fn handle(ctx) {{ #{{effects:[#{{id:"{effect}"}}]}} }}"#) + .into_bytes(), + }], + CompileProfile::Authoring, + ) +} + +// A profile bounded through a source cannot write what that source's probe +// reads, except to remove authority. + +const PROTECTED: &str = "breg.access.membership-source-write"; + +/// `member` reads facilities through `membership`, and gains a grant on its +/// own membership rows by its principal claim. +fn member_with_membership_grant(grant: Value) -> Value { + let mut project = base(); + project["recordTypes"]["membership"]["tombstone"] = json!(true); + let mut grant = grant; + grant["recordType"] = json!("membership"); + grant["rowBoundaries"] = json!([{"field":"principal","claim":"principal","operator":"equals"}]); + grant["readableFields"] = json!(["organization", "principal", "active"]); + project["accessProfiles"]["member"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push(grant); + project +} + +fn member_with_membership_action(effects: Value, mode: &str) -> Value { + let mut project = base(); + let mut action = stewardship_action(mode); + action["inputs"][0] = json!({"id":"membership","type":"reference","target":"membership", + "required":true,"classification":"internal"}); + action["plan"] = json!({"type":"fixed","effects":effects}); + project["actions"] = json!({"change-membership": action}); + let own = json!([{"field":"principal","claim":"principal","operator":"equals"}]); + project["accessProfiles"]["member"]["permissions"]["actions"] = json!([ + {"action":"change-membership","operations":["invoke"],"results":["membership"], + "targets":[{"recordType":"membership","rowBoundaries":own}]} + ]); + project +} + +fn patch_membership(set: Value) -> Value { + json!([{"id":"membership","target":{"fromInput":"membership"},"operation":"patch","set":set}]) +} + +#[test] +fn a_member_cannot_write_the_fields_their_membership_probe_reads() { + let record = "recordTypes[id=membership].accessProfiles[id=member]"; + for field in ["active", "organization", "principal"] { + assert_refused_at( + &member_with_membership_grant( + json!({"operations":["get","patch"],"writableFields":[field]}), + ), + PROTECTED, + &format!("{record}.writableFields"), + ); + } + for operation in ["create", "batch", "import"] { + assert_refused( + &member_with_membership_grant(json!({ + "operations":["get", operation], + "writableFields":["organization","principal","active"] + })), + PROTECTED, + ); + } + let action = "accessProfiles[id=member].permissions.actions[action=change-membership].targets[recordType=membership]"; + for set in [ + json!({"active":{"value":true}}), + json!({"active":{"fromInput":"membership"}}), + json!({"principal":{"value":"someone-else"}}), + ] { + assert_refused_at( + &member_with_membership_action(patch_membership(set), "immediate"), + PROTECTED, + action, + ); + } + let create = json!([{"id":"membership","target":{"recordType":"membership"},"operation":"create", + "set":{"organization":{"fromInput":"membership"},"principal":{"value":"x"},"active":{"value":true}}}]); + assert_refused( + &member_with_membership_action(create, "immediate"), + PROTECTED, + ); +} + +#[test] +fn a_function_ceiling_over_a_probe_field_is_refused() { + let mut project = member_with_membership_action( + patch_membership(json!({"active":{"value":false}})), + "immediate", + ); + project["actions"]["change-membership"]["plan"] = json!({"type":"scripted", + "actionPlan":"rename","inputs":["membership"], + "writes":[{"id":"membership","target":{"fromInput":"membership"}, + "operation":"patch","fields":["active"]}]}); + project["actionPlans"] = json!({"rename": {"runtime":"rhai","source":"scripts/rename.rhai", + "entrypoint":"handle","abi":"registry.action-plan/v1"}}); + let failure = compile_with_script(&project, "membership").expect_err("refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == PROTECTED), + "{:?}", + failure.diagnostics() + ); +} + +#[test] +fn a_proposal_that_reactivates_the_callers_source_is_refused() { + let mut project = member_with_membership_action( + patch_membership(json!({"active":{"value":true}})), + "proposal", + ); + let own = json!([{"field":"principal","claim":"principal","operator":"equals"}]); + project["accessProfiles"]["member"]["permissions"]["actions"] = json!([ + {"action":"change-membership","operations":["start"], + "targets":[{"recordType":"membership","rowBoundaries":own.clone()}]} + ]); + project["accessProfiles"]["member"]["permissions"]["proposals"] = json!([ + {"action":"change-membership","operations":["get","submit","apply"],"party":"owner", + "targets":[{"recordType":"membership","rowBoundaries":own}]} + ]); + assert_refused(&project, PROTECTED); +} + +#[test] +fn a_steward_cannot_hold_a_write_on_stewardship() { + let mut project = steward_project(); + stewards(&mut project).push(json!({ + "recordType":"stewardship","rowBoundaries":"unrestricted", + "operations":["get","patch"],"readableFields":["active"],"writableFields":["active"] + })); + assert_refused_at( + &project, + PROTECTED, + "recordTypes[id=stewardship].accessProfiles[id=organisation-steward].writableFields", + ); +} + +#[test] +fn writes_that_only_remove_authority_stay_admitted() { + // Leaving: a fixed deactivation, a tombstone, or a field the probe + // does not read. + assert_compiles(&member_with_membership_action( + patch_membership(json!({"active":{"value":false}})), + "immediate", + )); + assert_compiles(&member_with_membership_grant( + json!({"operations":["get","tombstone"]}), + )); + assert_compiles(&member_with_membership_grant( + json!({"operations":["get","patch"],"writableFields":["private-note"]}), + )); + // The steward's own Actions write membership, a different source from + // the one that bounds them. + assert_compiles(&steward_project()); +} + +// Consent and membership together. + +#[test] +fn a_membership_source_requiring_consent_read_through_itself_is_refused() { + use registry_breg::compiler::module_digest; + use registry_breg::contract::parse_module_yaml; + let project = + include_str!("../../../products/breg/fixtures/consent-person-registry/registry.yaml"); + let modules = [ + include_str!( + "../../../products/breg/fixtures/consent-person-registry/modules/consent-person/module.yaml" + ), + include_str!( + "../../../products/breg/fixtures/consent-person-registry/modules/consent-person-registry-core/module.yaml" + ), + ]; + // A read-only recipient reads the decision through the link's + // membership, and its grant on the link requires that decision's + // consent: each probe needs the other. + let profile = " person-consent-self:\n"; + assert_eq!(project.matches(profile).count(), 1); + let cyclic = project.replacen( + profile, + &format!( + " link-reader: + principalClaim: registry_principal + actorKind: service + requesterClients: [food-agency-portal] + requiredScopes: ['consent:link:read'] + requiredPurposes: [food-assistance] + permissions: + records: + - recordType: person-consent-decision + rowBoundaries: + - {{field: subject, membership: person-consent-link}} + operations: [get] + readableFields: [subject] + - recordType: person-consent-link + rowBoundaries: + - {{field: principal, claim: registry_principal, operator: equals}} + operations: [get] + readableFields: [subject] + requireConsent: + - {{record: person-consent-decision, on: subject}} +{profile}" + ), + 1, + ); + let mut source = parse_project_yaml(cyclic.as_bytes()).expect("the edit parses"); + let modules = modules + .iter() + .map(|module| parse_module_yaml(module.as_bytes()).expect("module parses")) + .collect::>(); + for lock in &mut source.modules { + let module = modules.iter().find(|module| module.id == lock.id).unwrap(); + lock.digest = Some(module_digest(module)); + } + let failure = compile_project(&source, &modules, CompileProfile::Authoring) + .expect_err("a consent and membership cycle must be refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| { + diagnostic.code == "breg.access.membership-source-recursive" + && diagnostic.path == "recordTypes[id=person-consent-link].membership" + }), + "{:?}", + failure.diagnostics() + ); +} + +// Who a membership source names, and for which key, is authority. A grant +// bounded by claims on the source row cannot set its key or principal; an +// Action whose reference target is bounded can. + +const KEY_WRITE: &str = "breg.access.membership-source-key-write"; +const CLERK: &str = "membership-clerk"; + +/// A clerk whose membership grant is bounded by a claim on the row itself. +fn with_clerk(grant: Value) -> Value { + let mut project = base(); + project["recordTypes"]["membership"]["tombstone"] = json!(true); + project["recordTypes"]["membership"]["batch"] = json!({"maximumItems":4,"maximumBytes":8192}); + let mut grant = grant; + grant["recordType"] = json!("membership"); + grant["readableFields"] = json!(["organization", "principal", "active", "private-note"]); + if grant.get("rowBoundaries").is_none() { + grant["rowBoundaries"] = + json!([{"field":"private-note","claim":"team","operator":"equals"}]); + } + project["accessProfiles"][CLERK] = json!({ + "principalClaim":"principal","requiredScopes":["records:manage","membership:use"], + "permissions":{"records":[grant]} + }); + project +} + +#[test] +fn a_claim_bounded_grant_cannot_set_a_sources_key_or_principal() { + let at = + |member: &str| format!("recordTypes[id=membership].accessProfiles[id={CLERK}].{member}"); + let all = json!(["organization", "principal", "active", "private-note"]); + assert_refused_at( + &with_clerk(json!({"operations":["get","create"],"writableFields":all})), + KEY_WRITE, + &at("operations"), + ); + for operation in ["batch", "import"] { + assert_refused( + &with_clerk(json!({"operations":["get", operation],"writableFields":all})), + KEY_WRITE, + ); + } + for field in ["organization", "principal"] { + assert_refused_at( + &with_clerk(json!({"operations":["get","patch"],"writableFields":[field]})), + KEY_WRITE, + &at("writableFields"), + ); + } +} + +#[test] +fn unrestricted_membership_bounded_and_non_key_writes_stay_admitted() { + for grant in [ + json!({"operations":["get","patch"],"writableFields":["private-note"]}), + json!({"operations":["get","tombstone"]}), + json!({"operations":["get","create","patch"],"rowBoundaries":"unrestricted", + "writableFields":["organization","principal","active"]}), + ] { + assert_compiles(&with_clerk(grant)); + } + // The steward writes membership rows bounded by stewardship, so each key + // it writes is checked against the steward's own stewardship. + let mut project = steward_project(); + let grant = stewards(&mut project) + .iter_mut() + .find(|grant| grant["recordType"] == "membership") + .unwrap(); + grant["operations"] = json!(["get", "list", "create"]); + grant["writableFields"] = json!(["organization", "principal", "active"]); + assert_compiles(&project); +} + +fn clerk_action(effect: Value, mode: &str) -> Value { + let mut project = with_clerk(json!({"operations":["get"]})); + let mut action = stewardship_action(mode); + action["inputs"] = json!([ + {"id":"organization","type":"reference","target":"organization","required":true, + "classification":"internal"}, + {"id":"membership","type":"reference","target":"membership","required":false, + "classification":"internal"}, + {"id":"principal","type":"string","maximumLength":80,"required":true, + "classification":"restricted"} + ]); + action["plan"] = json!({"type":"fixed","effects":[effect]}); + project["actions"] = json!({"change-membership": action}); + let claim = json!([{"field":"private-note","claim":"team","operator":"equals"}]); + let targets = json!([ + {"recordType":"membership","rowBoundaries":claim}, + {"recordType":"organization","rowBoundaries":[{"field":"name","claim":"team","operator":"equals"}]} + ]); + if mode == "proposal" { + project["accessProfiles"][CLERK]["permissions"]["actions"] = json!([ + {"action":"change-membership","operations":["start"],"targets":targets.clone()} + ]); + project["accessProfiles"][CLERK]["permissions"]["proposals"] = json!([ + {"action":"change-membership","operations":["get","submit","apply"], + "party":"owner","targets":targets} + ]); + } else { + project["accessProfiles"][CLERK]["permissions"]["actions"] = json!([ + {"action":"change-membership","operations":["invoke"],"results":["membership"], + "targets":targets} + ]); + } + project +} + +#[test] +fn an_action_sets_a_key_only_through_a_bounded_reference() { + let path = "accessProfiles[id=membership-clerk].permissions.actions[action=change-membership].targets[recordType=membership]"; + // Admitted: a created row's key comes from a reference input whose + // target grant is bounded, and its principal is set with it. + assert_compiles(&clerk_action( + json!({"id":"membership","target":{"recordType":"membership"},"operation":"create", + "set":{"organization":{"fromInput":"organization"},"principal":{"fromInput":"principal"}, + "active":{"value":true}}}), + "immediate", + )); + // Refused: a principal moved on an existing row. A fixed plan sets a + // key only from a reference input, whose target grant is checked. + let moved = json!({"id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"principal":{"fromInput":"principal"}}}); + assert_refused_at(&clerk_action(moved.clone(), "immediate"), KEY_WRITE, path); + assert_refused_at( + &clerk_action(moved, "proposal"), + KEY_WRITE, + "accessProfiles[id=membership-clerk].permissions.proposals[action=change-membership].targets[recordType=membership]", + ); +} + +#[test] +fn a_function_ceiling_cannot_set_a_key_on_a_claim_bounded_target() { + let mut project = clerk_action( + json!({"id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}}}), + "immediate", + ); + project["actions"]["change-membership"]["inputs"][1]["required"] = json!(true); + project["actions"]["change-membership"]["plan"] = json!({"type":"scripted", + "actionPlan":"rename","inputs":["membership","organization"], + "writes":[{"id":"membership","target":{"fromInput":"membership"}, + "operation":"patch","fields":["organization"]}]}); + project["actionPlans"] = json!({"rename": {"runtime":"rhai","source":"scripts/rename.rhai", + "entrypoint":"handle","abi":"registry.action-plan/v1"}}); + let failure = compile_with_script(&project, "membership").expect_err("refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == KEY_WRITE), + "{:?}", + failure.diagnostics() + ); +} + +// The rules see every profile a grant can come from, and every grant kind. + +/// The fixture with `member` declared only by a module: its bounded +/// facility grant, and `source_grant` on its own `membership` rows. +fn module_member(source_grant: Value) -> (Value, registry_breg::contract::RegistryModule) { + use registry_breg::compiler::module_digest; + use registry_breg::contract::parse_module_yaml; + let mut project: Value = serde_json::from_slice(PROJECT).unwrap(); + let grant = project["accessProfiles"]["member"]["permissions"]["records"][0].clone(); + let mut profile = grant.as_object().unwrap().clone(); + profile.remove("recordType"); + profile.insert( + "requiredScopes".into(), + json!(["records:read", "membership:use"]), + ); + profile.insert("principalClaim".into(), json!("principal")); + profile.insert("default".into(), json!(true)); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("member"); + let records = project["recordTypes"].as_object_mut().unwrap(); + let mut facility = records.remove("facility").unwrap(); + facility["accessProfiles"] = json!({"member": profile}); + let mut membership = records.remove("membership").unwrap(); + let mut own = source_grant.as_object().unwrap().clone(); + own.insert( + "requiredScopes".into(), + json!(["records:read", "membership:use"]), + ); + own.insert("principalClaim".into(), json!("principal")); + own.insert( + "readableFields".into(), + json!(["organization", "principal", "active"]), + ); + membership["accessProfiles"] = json!({"member": own}); + let module = parse_module_yaml( + &serde_json::to_vec(&json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule", + "id":"membership-core","version":"1", + "recordTypes":{"facility":facility,"membership":membership} + })) + .unwrap(), + ) + .unwrap(); + project["modules"] = json!({"membership-core":{"version":"1","digest":module_digest(&module)}}); + (project, module) +} + +#[test] +fn a_module_declared_profile_cannot_write_its_own_source() { + for (grant, member) in [ + ( + json!({"operations":["get","patch"],"writableFields":["active"], + "rowBoundaries":[{"field":"principal","claim":"principal","operator":"equals"}]}), + "writableFields", + ), + ( + json!({"operations":["get","create"],"rowBoundaries":"unrestricted", + "writableFields":["organization","principal","active"]}), + "operations", + ), + ] { + let (project, module) = module_member(grant); + let source = parse_project_yaml(&serde_json::to_vec_pretty(&project).unwrap()).unwrap(); + let failure = compile_project(&source, &[module], CompileProfile::Authoring) + .expect_err("a module profile bounded through its source cannot write it"); + let path = format!("recordTypes[id=membership].accessProfiles[id=member].{member}"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| { diagnostic.code == PROTECTED && diagnostic.path == path }), + "wanted {PROTECTED} at {path}: {:?}", + failure.diagnostics() + ); + } +} + +#[test] +fn a_bounded_member_cannot_apply_a_proposal_that_reactivates_its_source() { + // Another profile starts and submits the Proposal. The bounded member + // holds only the lifecycle grant that applies it. + let mut project: Value = serde_json::from_slice(PROJECT).unwrap(); + project["actions"] = json!({"reactivate": { + "execution":{"mode":"proposal","proposal":{"review":{"type":"none"}, + "application":{"mode":"manual"},"retention":{"mode":"operator-erase"}}}, + "inputs":[{"id":"membership","type":"reference","target":"membership","required":true, + "classification":"internal"}], + "plan":{"type":"fixed","effects":[{"id":"membership","target":{"fromInput":"membership"}, + "operation":"patch","set":{"active":{"value":true}}}]} + }}); + let own = json!([{"field":"principal","claim":"principal","operator":"equals"}]); + project["accessProfiles"]["applicant"] = json!({ + "principalClaim":"principal", + "requiredScopes":["membership:apply","membership:use"], + "permissions":{ + "actions":[{"action":"reactivate","operations":["start"], + "targets":[{"recordType":"membership","rowBoundaries":own.clone()}]}], + "proposals":[{"action":"reactivate","operations":["get","submit"],"party":"owner", + "targets":[{"recordType":"membership","rowBoundaries":own.clone()}]}] + } + }); + project["accessProfiles"]["member"]["permissions"]["proposals"] = json!([ + {"action":"reactivate","operations":["get","apply"], + "targets":[{"recordType":"membership","rowBoundaries":own}]} + ]); + assert_refused_at( + &project, + PROTECTED, + "accessProfiles[id=member].permissions.proposals[action=reactivate].targets[recordType=membership]", + ); +} + +#[test] +fn a_separate_self_service_profile_cannot_reactivate_a_membership() { + let mut project: Value = serde_json::from_slice(PROJECT).unwrap(); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("steward"); + project["accessProfiles"]["self-service"] = json!({ + "principalClaim":"principal", + "requiredScopes":["membership:self","membership:use"], + "permissions":{"records":[{"recordType":"membership", + "operations":["get","patch"], + "readableFields":["organization","principal","active"], + "writableFields":["active"], + "rowBoundaries":[{"field":"principal","claim":"principal","operator":"equals"}]}]} + }); + assert_refused_at( + &project, + KEY_WRITE, + "recordTypes[id=membership].accessProfiles[id=self-service].writableFields", + ); + // Leaving through a fixed deactivation stays possible. + let mut leave = clerk_action( + json!({"id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}}}), + "immediate", + ); + leave["actions"]["change-membership"]["inputs"][1]["required"] = json!(true); + assert_compiles(&leave); + let reactivate = clerk_action( + json!({"id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":true}}}), + "immediate", + ); + assert_refused(&reactivate, KEY_WRITE); +} + +/// `membership` gains a second reference, `unit`, and a `unit-lead` source +/// keyed by it, so a grant on `membership` can carry a membership entry on a +/// field other than the source's key. +fn with_unit_lead() -> Value { + let mut project = base(); + project["recordTypes"]["unit"] = json!({ + "primaryDataset":"test-dataset","route":"units","mutationMode":"mutable", + "classification":"internal", + "fields":[{"id":"name","type":"string","maximumLength":80,"classification":"internal"}] + }); + project["recordTypes"]["membership"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"unit","type":"reference","target":"unit","classification":"internal"})); + let mut lead = project["recordTypes"]["membership"].clone(); + lead["route"] = json!("unit-leads"); + lead["indexes"][0]["id"] = json!("unit-lead-principal-key"); + lead["indexes"][0]["fields"] = json!(["principal", "unit", "active"]); + lead["membership"] = json!({"key":"unit","principal":"principal","active":"active"}); + lead["fields"] + .as_array_mut() + .unwrap() + .retain(|field| field["id"] != "organization"); + lead["fields"] + .as_array_mut() + .unwrap() + .iter_mut() + .filter(|field| field["id"] == "unit") + .for_each(|field| field["required"] = json!(true)); + project["recordTypes"]["unit-lead"] = lead; + project +} + +#[test] +fn a_membership_entry_off_the_key_does_not_check_the_key() { + let grant = json!({"recordType":"membership", + "rowBoundaries":[{"field":"unit","membership":"unit-lead"}], + "operations":["get","create"], + "readableFields":["organization","principal","active","unit"], + "writableFields":["organization","principal","active","unit"]}); + // A separate unit-lead clerk names any organisation it likes. + let mut project = with_unit_lead(); + project["accessProfiles"]["unit-lead-clerk"] = json!({ + "principalClaim":"principal","requiredScopes":["records:manage","membership:use"], + "permissions":{"records":[grant.clone()]} + }); + assert_refused_at( + &project, + KEY_WRITE, + "recordTypes[id=membership].accessProfiles[id=unit-lead-clerk].operations", + ); + // And a member bounded through `membership` cannot grant itself one. + let mut project = with_unit_lead(); + project["accessProfiles"]["member"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push(grant); + assert_refused_at( + &project, + PROTECTED, + "recordTypes[id=membership].accessProfiles[id=member].operations", + ); +} + +#[test] +fn a_function_create_ceiling_and_a_function_proposal_are_refused() { + // A function ceiling that creates rows of the caller's own source. + let mut project = member_with_membership_action( + patch_membership(json!({"active":{"value":false}})), + "immediate", + ); + project["actions"]["change-membership"]["plan"] = json!({"type":"scripted", + "actionPlan":"rename","inputs":["membership"], + "writes":[{"id":"membership","target":{"recordType":"membership"}, + "operation":"create","fields":["organization","principal","active"]}]}); + project["actionPlans"] = json!({"rename": {"runtime":"rhai","source":"scripts/rename.rhai", + "entrypoint":"handle","abi":"registry.action-plan/v1"}}); + let failure = compile_with_script(&project, "membership").expect_err("refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| diagnostic.code == PROTECTED + && diagnostic.path + == "accessProfiles[id=member].permissions.actions[action=change-membership].targets[recordType=membership]"), + "{:?}", + failure.diagnostics() + ); + // A Proposal whose function plan may reactivate a claim-bounded target. + let mut project = clerk_action( + json!({"id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}}}), + "proposal", + ); + project["actions"]["change-membership"]["inputs"][1]["required"] = json!(true); + project["actions"]["change-membership"]["plan"] = json!({"type":"scripted", + "actionPlan":"rename","inputs":["membership"], + "writes":[{"id":"membership","target":{"fromInput":"membership"}, + "operation":"patch","fields":["active"]}]}); + project["actionPlans"] = json!({"rename": {"runtime":"rhai","source":"scripts/rename.rhai", + "entrypoint":"handle","abi":"registry.action-plan/v1"}}); + let failure = compile_with_script(&project, "membership").expect_err("refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| diagnostic.code == KEY_WRITE + && diagnostic.path + == "accessProfiles[id=membership-clerk].permissions.proposals[action=change-membership].targets[recordType=membership]"), + "{:?}", + failure.diagnostics() + ); +} diff --git a/crates/registry-breg/tests/support/action_evidence_provider.rs b/crates/registry-breg/tests/support/action_evidence_provider.rs index e4966ceeb6..109b09685d 100644 --- a/crates/registry-breg/tests/support/action_evidence_provider.rs +++ b/crates/registry-breg/tests/support/action_evidence_provider.rs @@ -30,6 +30,10 @@ impl EvidenceProvider { pub async fn start() -> Self { let mut key = registry_platform_crypto::PrivateJwk::parse(r#"{"kty":"EC","crv":"P-256","d":"MInq88dvxx-e1-MEfmdes4I6Gt2QbsKoEmYyk2j0Oj4","x":"3kpzAK6fK6xyfqbdp0HvfZCqfgz7MajMviKyM6bsNE4","y":"GkSdSn8xqge52rp9Sv-4qPaw1Q9TJ2eMUyY22flavLU","alg":"ES256"}"#).unwrap(); key.kid = Some(key.public().jkt().unwrap()); + Self::start_with_key(key).await + } + + pub async fn start_with_key(key: registry_platform_crypto::PrivateJwk) -> Self { let key = Arc::new(key); let public = serde_json::to_value(key.public()).unwrap(); let requests = Arc::new(Mutex::new(Vec::new())); diff --git a/crates/registry-breg/tests/support/event_record_registry.rs b/crates/registry-breg/tests/support/event_record_registry.rs index 36ab85d69c..6dee45c1dc 100644 --- a/crates/registry-breg/tests/support/event_record_registry.rs +++ b/crates/registry-breg/tests/support/event_record_registry.rs @@ -237,7 +237,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [records:write] permissions: records: - {recordType: grant, operations: [get, list], readableFields: [grant-number, status], rowBoundaries: unrestricted} diff --git a/crates/registry-breg/tests/support/membership_targets.rs b/crates/registry-breg/tests/support/membership_targets.rs new file mode 100644 index 0000000000..796be3bd54 --- /dev/null +++ b/crates/registry-breg/tests/support/membership_targets.rs @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: Apache-2.0 + +#[path = "action_requirements.rs"] +mod action_requirements; + +use super::breg_fixture_crate::model::{ + CompiledActionExecution, CompiledActionInventory, CompiledMembershipBoundary, +}; +use super::breg_fixture_crate::{ + compile_project, parse_project_json, CompileProfile, CompiledRegistry, +}; +use serde_json::{json, Value}; + +fn fixture() -> Value { + serde_json::from_str(include_str!( + "../../../../products/breg/fixtures/organization-membership-access/registry.yaml" + )) + .unwrap() +} + +fn compile(source: &Value) -> CompiledRegistry { + compile_project( + &parse_project_json(&serde_json::to_vec(source).unwrap()).unwrap(), + &[], + CompileProfile::Authoring, + ) + .unwrap() +} + +pub fn immediate(with_steward: bool) -> (CompiledRegistry, CompiledActionInventory) { + let mut source = action_requirements::project(); + let fixture = fixture(); + source["recordTypes"]["membership"] = fixture["recordTypes"]["membership"].clone(); + if with_steward { + let mut steward = fixture["accessProfiles"]["steward"].clone(); + steward["permissions"]["records"] = json!([steward["permissions"]["records"][1]]); + source["accessProfiles"]["steward"] = steward; + } + source["recordTypes"]["membership"]["fields"][0]["target"] = json!("parent"); + source["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + source["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("indexes"); + source["recordTypes"]["parent"]["fields"].as_array_mut().unwrap().push( + json!({"id":"directory","type":"reference","target":"parent","classification":"internal"}), + ); + let registry = compile(&source); + let mut actions = registry.actions().clone(); + for target in &mut actions.actions[0].permissions[0].targets { + let field = match target.entity_id.as_str() { + "child" => "parent", + "parent" => "directory", + other => panic!("unexpected target {other}"), + }; + target + .membership_boundaries + .push(boundary(®istry, field)); + } + (registry, actions) +} + +#[allow(dead_code)] +pub fn proposal(mut source: Value, automatic: bool) -> (CompiledRegistry, CompiledActionInventory) { + let fixture = fixture(); + for id in ["membership", "organization"] { + source["recordTypes"][id] = fixture["recordTypes"][id].clone(); + source["recordTypes"][id]["primaryDataset"] = json!("directory"); + } + source["recordTypes"]["membership"]["accessRequirements"]["requiredScopes"] = + json!(["proposal:manage"]); + source["recordTypes"]["target"]["fields"].as_array_mut().unwrap().push( + json!({"id":"organization","type":"reference","target":"organization","classification":"internal"}), + ); + if automatic { + source["actions"]["correct-name"]["execution"]["proposal"]["application"] = + json!({"mode":"automatic"}); + source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["operations"] = + json!(["get", "edit", "submit", "cancel"]); + } + let registry = compile(&source); + let mut actions = registry.actions().clone(); + let action = &mut actions.actions[0]; + for target in &mut action.permissions[0].targets { + target + .membership_boundaries + .push(boundary(®istry, "organization")); + } + let CompiledActionExecution::Proposal { proposal } = &mut action.execution else { + panic!("expected a compiled Proposal"); + }; + proposal.permissions[0].targets[0] + .membership_boundaries + .push(boundary(®istry, "organization")); + (registry, actions) +} + +fn boundary(registry: &CompiledRegistry, field: &str) -> CompiledMembershipBoundary { + let source = ®istry.entities()["membership"]; + let column = |field: &str| source.fields[field].physical_name.clone(); + CompiledMembershipBoundary { + field: field.into(), + membership_entity: source.id.clone(), + membership_table: source.physical_table.clone(), + membership_key_column: column("organization"), + principal_column: column("principal"), + active_column: column("active"), + } +} diff --git a/crates/registry-breg/tests/support/membership_write_journeys.rs b/crates/registry-breg/tests/support/membership_write_journeys.rs new file mode 100644 index 0000000000..7045d2da26 --- /dev/null +++ b/crates/registry-breg/tests/support/membership_write_journeys.rs @@ -0,0 +1,4924 @@ +// SPDX-License-Identifier: Apache-2.0 + +use super::{membership_write_project, postgres_harness::TestDatabase, AlwaysReady}; +use axum::body::{to_bytes, Body}; +use axum::http::{HeaderMap, Method, Request, StatusCode}; +use registry_breg::api::{authenticated_router, HttpService, ReadRuntimeIdentity}; +use registry_breg::auth::{AuthenticatorIssuer, AuthorityClaimConfig, RegistryAuthenticator}; +use registry_breg::compiler::compile_project_with_assets; +use registry_breg::contract::ModuleAssetSource; +use registry_breg::cursor::CursorCodec; +use registry_breg::migration::{ + apply_verified_package, ActivationDeployment, ApplyPrecondition, ApplyRoles, ApplyTimeouts, + ApplyVerifiedPackageRequest, +}; +use registry_breg::package::{ + load_package, prepare_package_with_project_assets, PackageBuildRequest, PackageLoadContext, + PackageMigrationPlanInput, PackageSourceFile, FIXTURE_JOURNEYS_PATH, +}; +use registry_breg::postgres::{ + install_compiled_schema, managed_schema_fingerprint, ExpectedManagedCatalog, + ExpectedRegistryIdentity, PostgresRecordMutationService, PostgresRecordReadService, + RegistryLockKey, +}; +use registry_breg::{parse_project_json, CompileProfile, CompiledRegistry}; +use registry_platform_audit::AuditProfile; +use registry_platform_config::{DeclaredPosture, Posture, PostureSource}; +use registry_platform_httputil::FetchUrlPolicy; +use registry_platform_oidc::{ActorKind, DeclaredKinds, JwksFetcher, JwksFetcherConfig}; +use registry_platform_testing::{oidc_verifier_config, MockIdp}; +use serde_json::{json, Value}; +use sha2::{Digest, Sha256}; +use std::{sync::Arc, time::Duration}; +use tower::ServiceExt as _; +use uuid::Uuid; +use zeroize::Zeroizing; + +const PACKAGE: &str = "membership-writes"; +const AUDIENCE: &str = "urn:breg:membership-writes"; +const MEMBER: &str = "member"; +const MEMBERSHIP_WRITER: &str = "steward"; +const CLAIMED: &str = "claimed"; +const RECORDS: &str = "/v1/records/facilities"; + +struct Fixture { + database: TestDatabase, + registry: Arc, + identity: ExpectedRegistryIdentity, + app: axum::Router, + service: Arc, + authenticator: Arc, + development: axum::Router, + mutations: Arc, + idp: MockIdp, + keys: Keys, +} + +struct Keys { + allowed: String, + second: String, + inactive: String, + tombstoned: String, + foreign: String, + membership: String, + second_membership: String, +} + +impl Fixture { + async fn create(lock_timeout: Duration) -> Self { + Self::configured( + lock_timeout, + membership_write_project::project(), + Vec::new(), + |service| service, + ) + .await + } + + async fn configured( + lock_timeout: Duration, + project: Value, + assets: Vec, + configure: impl FnOnce(PostgresRecordMutationService) -> PostgresRecordMutationService, + ) -> Self { + Self::configured_with_isolation(lock_timeout, project, assets, "repeatable read", configure) + .await + } + + async fn configured_with_isolation( + lock_timeout: Duration, + project: Value, + assets: Vec, + isolation: &str, + configure: impl FnOnce(PostgresRecordMutationService) -> PostgresRecordMutationService, + ) -> Self { + Self::configured_with_pool(lock_timeout, project, assets, isolation, 4, configure).await + } + + async fn configured_with_pool( + lock_timeout: Duration, + project: Value, + assets: Vec, + isolation: &str, + pool_size: usize, + configure: impl FnOnce(PostgresRecordMutationService) -> PostgresRecordMutationService, + ) -> Self { + let bytes = serde_json::to_vec(&project).unwrap(); + let compiled = compile_project_with_assets( + &parse_project_json(&bytes).unwrap(), + &[], + &assets, + CompileProfile::Production, + ) + .expect("Production admits membership-bound Records and immediate Actions"); + let database = TestDatabase::create(pool_size).await; + let (mut migration, connection) = database.connect_migration().await; + let tx = migration.transaction().await.unwrap(); + install_compiled_schema(&tx, &compiled, &database.runtime_role) + .await + .unwrap(); + let fingerprint = managed_schema_fingerprint( + &tx, + &database.runtime_role, + &ExpectedManagedCatalog::compiled(&compiled), + ) + .await + .unwrap(); + tx.rollback().await.unwrap(); + drop(migration); + connection.abort(); + + let prepared = prepare_package_with_project_assets(PackageBuildRequest { + from_package_digest: None, + compiler_source_revision: "membership-writes-fixture".into(), + schema_fingerprint: fingerprint, + project: PackageSourceFile { + path: "registry.json".into(), + bytes, + }, + modules: vec![], + fixture_journeys: PackageSourceFile { + path: FIXTURE_JOURNEYS_PATH.into(), + bytes: b"apiVersion: id.registrystack.org/formats/breg/journeys/v1\nkind: BRegJourneys\njourneys: []\n".to_vec(), + }, + migration_plan: PackageMigrationPlanInput::InitialCompiledDdl, + }, assets.into_iter().map(|asset| PackageSourceFile {path:asset.path, bytes:asset.bytes}).collect()) + .unwrap(); + let directory = tempfile::tempdir_in(std::env::temp_dir().canonicalize().unwrap()).unwrap(); + let package_root = directory.path().join("package"); + prepared.publish_to_directory(&package_root).unwrap(); + let package = load_package( + &package_root, + &PackageLoadContext { + posture: Posture::Production, + }, + ) + .unwrap(); + let identity = apply_verified_package(ApplyVerifiedPackageRequest::new( + &database.migration_config, + &package, + ActivationDeployment::new("production", PACKAGE, PACKAGE), + ApplyPrecondition::InitialActivation, + ApplyRoles::new(&database.migration_role, &database.runtime_role), + ApplyTimeouts::new(Duration::from_secs(2), Duration::from_secs(5)).unwrap(), + database.activation_audit(), + )) + .await + .unwrap(); + let registry = Arc::new(package.registry().clone()); + database + .admin + .batch_execute(&format!( + "ALTER ROLE \"{}\" SET default_transaction_isolation = '{isolation}'", + database.runtime_role.as_str() + )) + .await + .unwrap(); + let pool = database.runtime_config.build_pool().unwrap(); + let client = pool.get_for_test().await.unwrap(); + assert_eq!( + client + .query_one("SHOW transaction_isolation", &[]) + .await + .unwrap() + .get::<_, String>(0), + isolation + ); + let facility = ®istry.entities()["facility"]; + assert!(client.query_one( + "SELECT c.relrowsecurity AND c.relforcerowsecurity AND NOT (r.rolsuper OR r.rolbypassrls) + FROM pg_catalog.pg_class c, pg_catalog.pg_roles r + WHERE c.oid = $1::text::regclass AND r.rolname = current_user", + &[&format!("registry_data.\"{}\"", facility.physical_table)] + ).await.unwrap().get::<_,bool>(0)); + drop(client); + let secret = || [Uuid::new_v4().into_bytes(), Uuid::new_v4().into_bytes()].concat(); + let audit = + database.audit(AuditProfile::production_from_secret_bytes(secret().into()).unwrap()); + let cursors = + Arc::new(CursorCodec::new(Zeroizing::new(secret()), Duration::from_secs(300)).unwrap()); + let lock_key = RegistryLockKey::derive(PACKAGE).unwrap(); + let records = Arc::new(PostgresRecordReadService::new( + pool.clone(), + registry.clone(), + identity.clone(), + lock_key, + lock_timeout, + audit.clone(), + cursors.clone(), + )); + let destinations = event_destinations(®istry, &secret()); + let mutations = Arc::new(configure( + PostgresRecordMutationService::new_with_event_destinations( + pool, + registry.clone(), + identity.clone(), + PACKAGE, + lock_key, + lock_timeout, + audit, + Some(Arc::new(destinations)), + ) + .with_action_timeout_for_test(Duration::from_secs(10)), + )); + let service = HttpService::new( + registry.clone(), + ReadRuntimeIdentity { + package_revision: identity.activation_id.clone(), + schema_fingerprint: identity.schema_fingerprint.clone(), + }, + records, + Arc::new(AlwaysReady), + cursors, + ) + .with_postgres_mutations(mutations.clone()); + let idp = MockIdp::start().await; + let issuer = AuthenticatorIssuer::new( + "fixture", + oidc_verifier_config(idp.issuer(), vec![AUDIENCE.into()]), + Arc::new(JwksFetcher::new_with_fetch_url_policy( + idp.jwks_uri(), + JwksFetcherConfig::defaults(), + FetchUrlPolicy::https_or_loopback(), + )), + ) + .with_declared_kinds(DeclaredKinds::Issuer(ActorKind::Human)); + let authenticator = Arc::new( + RegistryAuthenticator::with_issuers( + ®istry, + vec![issuer], + AuthorityClaimConfig::new("sub", None), + ) + .unwrap(), + ); + let development = authenticated_router( + Arc::new( + service + .clone() + .with_declared_posture_for_test(DeclaredPosture { + posture: Posture::Development, + source: PostureSource::Flag, + }), + ), + authenticator.clone(), + ); + let service = Arc::new(service); + let app = authenticated_router(service.clone(), authenticator.clone()); + let steward = mint(&idp, "steward", "records:manage membership:use", &[]); + let mut keys = Vec::new(); + for name in ["allowed", "second", "inactive", "tombstoned", "foreign"] { + keys.push( + request( + &app, + &steward, + Method::POST, + "/v1/records/organizations", + MEMBERSHIP_WRITER, + json!({"data":{"name":name,"owner":MEMBER}}), + None, + ) + .await + .success(StatusCode::CREATED) + .record_id(), + ); + } + let [allowed, second, inactive, tombstoned, foreign]: [String; 5] = + keys.try_into().unwrap(); + let mut membership = None; + let mut second_membership = None; + for (organization, active) in [ + (&allowed, true), + (&second, true), + (&inactive, false), + (&tombstoned, true), + ] { + let result = request( + &app, + &steward, + Method::POST, + "/v1/records/memberships", + MEMBERSHIP_WRITER, + json!({"data":{"organization":organization,"principal":MEMBER,"active":active}}), + None, + ) + .await + .success(StatusCode::CREATED); + if organization == &allowed { + membership = Some(result.record_id()); + } else if organization == &second { + second_membership = Some(result.record_id()); + } else if organization == &tombstoned { + request( + &app, + &steward, + Method::DELETE, + &format!("/v1/records/memberships/{}", result.record_id()), + MEMBERSHIP_WRITER, + Value::Null, + Some(result.etag()), + ) + .await + .success(StatusCode::OK); + } + } + Self { + database, + registry, + identity, + app, + service, + authenticator, + development, + mutations, + idp, + keys: Keys { + allowed, + second, + inactive, + tombstoned, + foreign, + membership: membership.unwrap(), + second_membership: second_membership.unwrap(), + }, + } + } + + fn member(&self) -> String { + mint(&self.idp, MEMBER, "", &[]) + } + + fn steward(&self) -> String { + mint(&self.idp, "steward", "records:manage membership:use", &[]) + } + + fn claimed(&self) -> String { + mint( + &self.idp, + MEMBER, + "records:claim", + &[&self.keys.allowed, &self.keys.second], + ) + } + + async fn seed(&self, key: Option<&str>, label: &str) -> Reply { + request( + &self.app, + &self.steward(), + Method::POST, + RECORDS, + MEMBERSHIP_WRITER, + json!({"data":{"organization":key,"label":label}}), + None, + ) + .await + .success(StatusCode::CREATED) + } + + async fn durable_state(&self) -> Value { + let entity = &self.registry.entities()["facility"]; + self.database.admin.query_one( + &format!( + "SELECT jsonb_build_array( + (SELECT jsonb_agg(to_jsonb(t) ORDER BY record_id) FROM registry_data.\"{}\" t), + (SELECT count(*) FROM registry_internal.registry_revisions), + (SELECT count(*) FROM registry_internal.registry_outbox), + (SELECT count(*) FROM registry_internal.registry_idempotency), + (SELECT count(*) FROM registry_internal.registry_generated_identifier_reservations), + (SELECT jsonb_agg(to_jsonb(c) ORDER BY entity_id, field_id, scope_values) + FROM registry_internal.registry_generated_identifier_counters c), + (SELECT jsonb_agg(to_jsonb(m) ORDER BY record_id) FROM {} m), + (SELECT count(*) FROM {}))", + entity.physical_table, + table(self, "membership"), + table(self, "organization"), + ), + &[], + ).await.unwrap().get(0) + } + + async fn proposal_markers(&self, proposal: &Reply) -> (i64, Option) { + let id = Uuid::parse_str(proposal.body["id"].as_str().unwrap()).unwrap(); + let row = self.database.admin.query_one( + "SELECT workflow_revision,blocked_reason FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ).await.unwrap(); + (row.get(0), row.get(1)) + } +} + +fn event_destinations( + registry: &CompiledRegistry, + signing_key: &[u8], +) -> registry_breg::event_destination::ActivatedEventDestinationRegistry { + let directory = tempfile::tempdir_in(std::env::temp_dir().canonicalize().unwrap()).unwrap(); + write_test_secret( + &directory.path().join("events"), + hex::encode(signing_key).as_bytes(), + ); + let config = runtime_fixture(directory.path()); + let config = format!( + "{config} +destinations: + hooks: + record-events: + origin: https://events.example.test/ + path: /records + networkProfile: production-https + dnsFamily: dual-stack-strict + allowedPrivateCidrs: [] + hmacSha256KeyRef: secret:file/events + classificationCeiling: internal + deliveryCeilings: + attemptTimeoutMilliseconds: 2000 + maximumAttempts: 2 +" + ); + registry_breg::runtime_config::parse_runtime_config(&config, production_posture()) + .unwrap() + .activate_event_destinations(registry) + .unwrap() +} + +fn write_test_secret(path: &std::path::Path, bytes: &[u8]) { + std::fs::write(path, bytes).unwrap(); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600)).unwrap(); + } +} + +fn runtime_fixture(secret_root: &std::path::Path) -> String { + include_str!("../../../../products/breg/examples/minimal/runtime.example.yaml") + .replace("/var/lib/breg/secrets", secret_root.to_str().unwrap()) +} + +fn production_posture() -> DeclaredPosture { + DeclaredPosture { + posture: Posture::Production, + source: PostureSource::Flag, + } +} + +fn mint(idp: &MockIdp, principal: &str, scope: &str, organizations: &[&str]) -> String { + let mut claims = json!({"aud":AUDIENCE,"sub":principal}); + if !scope.is_empty() { + claims["scope"] = json!(scope); + } + if !organizations.is_empty() { + claims["organization"] = json!(organizations); + } + idp.mint_token(claims) +} + +struct Reply { + status: StatusCode, + headers: HeaderMap, + bytes: Vec, + body: Value, +} + +impl Reply { + fn success(self, expected: StatusCode) -> Self { + assert_eq!(self.status, expected, "{}", self.body); + self + } + + fn problem(&self, status: StatusCode, code: &str) { + assert_eq!(self.status, status, "{}", self.body); + assert_eq!(self.body["code"], code); + if status == StatusCode::PRECONDITION_FAILED && code == "precondition.failed" { + assert!(self.body.get("failedCheck").is_none()); + assert!(self.body.get("guardReason").is_none()); + } + } + + fn record_id(&self) -> String { + self.body["data"]["recordId"].as_str().unwrap().to_owned() + } + + fn etag(&self) -> &str { + self.headers["etag"].to_str().unwrap() + } + + fn normalized_bytes(&self) -> Vec { + let trace = self.body["traceId"].as_str().unwrap(); + let bytes = std::str::from_utf8(&self.bytes).unwrap(); + bytes.replace(trace, &"0".repeat(trace.len())).into_bytes() + } + + fn golden(&self) -> Value { + let headers: std::collections::BTreeMap<_, _> = self + .headers + .iter() + .map(|(key, value)| (key.as_str(), value.to_str().unwrap())) + .collect(); + json!({ + "status":self.status.as_u16(), + "headers":headers, + "body":serde_json::from_slice::(&self.normalized_bytes()).unwrap() + }) + } + + fn assert_same_problem_except_check(&self, other: &Self) { + let without_check = |reply: &Self| { + let mut answer = reply.golden(); + answer["body"] + .as_object_mut() + .unwrap() + .remove("failedCheck"); + answer["headers"] + .as_object_mut() + .unwrap() + .remove("content-length"); + answer + }; + assert_eq!(without_check(self), without_check(other)); + } + + fn assert_same_problem(&self, other: &Self) { + assert_eq!(self.status, other.status); + assert_eq!(self.headers, other.headers); + assert_eq!(self.normalized_bytes(), other.normalized_bytes()); + } +} + +async fn request( + app: &axum::Router, + token: &str, + method: Method, + path: &str, + profile: &str, + body: Value, + if_match: Option<&str>, +) -> Reply { + request_with_key( + app, + token, + method, + path, + profile, + body, + if_match, + &Uuid::new_v4().to_string(), + ) + .await +} + +#[allow(clippy::too_many_arguments)] // Each value corresponds to a request member. +async fn request_with_key( + app: &axum::Router, + token: &str, + method: Method, + path: &str, + profile: &str, + body: Value, + if_match: Option<&str>, + key: &str, +) -> Reply { + let content_type = if method == Method::PATCH { + "application/json-patch+json" + } else { + "application/json" + }; + let mut builder = Request::builder() + .method(method) + .uri(format!("{path}?accessProfile={profile}")) + .header("authorization", format!("Bearer {token}")); + if !path.contains("/ingestion-runs") { + builder = builder.header("idempotency-key", key); + } + if !body.is_null() { + builder = builder.header("content-type", content_type); + } + if let Some(value) = if_match { + builder = builder.header("if-match", value); + } + let body = if body.is_null() { + Body::empty() + } else { + Body::from(body.to_string()) + }; + let (parts, body) = app + .clone() + .oneshot(builder.body(body).unwrap()) + .await + .unwrap() + .into_parts(); + let bytes = to_bytes(body, 1024 * 1024).await.unwrap().to_vec(); + let mut headers = parts.headers; + for name in ["traceparent", "x-request-id", "date"] { + headers.remove(name); + } + Reply { + status: parts.status, + headers, + body: if bytes.is_empty() { + Value::Null + } else { + serde_json::from_slice(&bytes).unwrap() + }, + bytes, + } +} + +fn record(id: &str) -> String { + format!("{RECORDS}/{id}") +} + +fn patch(field: &str, value: impl Into) -> Value { + json!([{"op":"replace","path":format!("/data/{field}"),"value":value.into()}]) +} + +async fn action(app: &axum::Router, token: &str, path: &str, profile: &str, input: Value) -> Reply { + request( + app, + token, + Method::POST, + &format!("/v1/actions/{path}"), + profile, + json!({"input":input}), + None, + ) + .await +} + +#[tokio::test] +async fn a_member_writes_in_their_key() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let new = |key: &str, label: &str| json!({"data":{"organization":key,"label":label}}); + let before = fixture.durable_state().await; + let created = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + new(&fixture.keys.allowed, "direct-create"), + None, + ) + .await + .success(StatusCode::CREATED); + assert_eq!(created.body["data"]["revisionId"], "1"); + let path = record(&created.record_id()); + let same_key = request( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("label", "direct-patch"), + Some(created.etag()), + ) + .await + .success(StatusCode::OK); + assert_eq!(same_key.body["data"]["revisionId"], "2"); + let cross_key = request( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("organization", fixture.keys.second.as_str()), + Some(same_key.etag()), + ) + .await + .success(StatusCode::OK); + assert_eq!(cross_key.body["data"]["revisionId"], "3"); + assert_eq!( + cross_key.body["data"]["domainData"]["organization"], + fixture.keys.second + ); + let deleted = request( + &fixture.app, + &member, + Method::DELETE, + &path, + MEMBER, + Value::Null, + Some(cross_key.etag()), + ) + .await + .success(StatusCode::OK); + assert_eq!(deleted.body["data"]["revisionId"], "4"); + + let batch = request( + &fixture.app, &member, Method::POST, &format!("{RECORDS}:batch"), MEMBER, + json!({"items":[ + {"operation":"create","data":{"organization":fixture.keys.second,"label":"batch-create"}}, + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"open"}} + ]}), None, + ).await.success(StatusCode::OK); + assert_eq!(batch.body["results"].as_array().unwrap().len(), 2); + let open = batch.body["results"][1]["recordId"].as_str().unwrap(); + let linked = action( + &fixture.app, + &member, + "register-facility", + MEMBER, + json!({"organization":fixture.keys.allowed,"related":open,"label":"action-create"}), + ) + .await + .success(StatusCode::OK); + assert_eq!(linked.body["results"]["register"]["revision"], 1); + let linked_id = linked.body["results"]["register"]["recordId"] + .as_str() + .unwrap(); + let read = request( + &fixture.app, + &member, + Method::GET, + &record(linked_id), + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(read.body["data"]["domainData"]["related"], open); + let closed = action( + &fixture.app, + &member, + "close-facility", + MEMBER, + json!({"facility":open}), + ) + .await + .success(StatusCode::OK); + assert_eq!(closed.body["results"]["close"]["revision"], 2); + + let (run_path, chunk) = + announce_ingestion(&fixture, &member, &fixture.keys.allowed, "ingested").await; + let submitted = request( + &fixture.app, + &member, + Method::POST, + &format!("{run_path}/chunks"), + MEMBER, + chunk, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(submitted.body["run"]["status"], "complete"); + assert_eq!(submitted.body["run"]["committedItems"], 1); + let after = fixture.durable_state().await; + assert_eq!(after[1].as_i64().unwrap() - before[1].as_i64().unwrap(), 9); + assert_eq!(after[2].as_i64().unwrap() - before[2].as_i64().unwrap(), 9); + fixture.database.cleanup().await; +} + +async fn announce_ingestion( + fixture: &Fixture, + token: &str, + key: &str, + label: &str, +) -> (String, Value) { + let items = json!([{"operation":"create","data":{"organization":key,"label":label}}]); + let mut source = registry_platform_canonical_json::canonicalize_json(&items[0]).unwrap(); + source.push(b'\n'); + let prefix = hex::encode(Sha256::digest(&source)); + let digest = hex::encode(Sha256::digest( + registry_platform_canonical_json::canonicalize_json(&json!({"items":items})).unwrap(), + )); + let created = request( + &fixture.app, + token, + Method::POST, + &format!("{RECORDS}/ingestion-runs"), + MEMBER, + json!({ + "operation":"create","profileId":MEMBER, + "packageRevision":fixture.identity.package_digest, + "schemaFingerprint":fixture.identity.schema_fingerprint, + "inputDigest":prefix,"inputLength":source.len(),"itemCount":1,"chunkCount":1, + "chunkAlgorithmVersion":"greedy-canonical-http-batch-v1" + }), + None, + ) + .await + .success(StatusCode::CREATED); + let run_id = created.body["run"]["runId"].as_str().unwrap(); + ( + format!("{RECORDS}/ingestion-runs/{run_id}"), + json!({"chunkIndex":0,"items":items,"digest":digest,"prefixDigest":prefix}), + ) +} + +#[tokio::test] +async fn membership_refusals_match_the_claim_boundary_answer_at_each_step() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let claimed = fixture.claimed(); + let unknown = Uuid::new_v4().to_string(); + let outside = fixture.seed(Some(&fixture.keys.foreign), "foreign").await; + let inactive = fixture.seed(Some(&fixture.keys.inactive), "inactive").await; + let removed = fixture + .seed(Some(&fixture.keys.tombstoned), "removed") + .await; + let null = fixture.seed(None, "null-key").await; + let visible = fixture.seed(Some(&fixture.keys.allowed), "visible").await; + let before = fixture.durable_state().await; + let outside_id = outside.record_id(); + let mut answers = std::collections::BTreeMap::new(); + for (posture, app) in [ + ("production", &fixture.app), + ("development", &fixture.development), + ] { + for id in [ + outside_id.clone(), + inactive.record_id(), + removed.record_id(), + null.record_id(), + ] { + for (method, body, status, code) in [ + ( + Method::GET, + Value::Null, + StatusCode::NOT_FOUND, + "resource.not-found", + ), + ( + Method::PATCH, + patch("label", "attempted-patch"), + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ( + Method::DELETE, + Value::Null, + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ] { + let etag = (method != Method::GET).then_some(outside.etag()); + let refusal = request( + app, + &member, + method.clone(), + &record(&id), + MEMBER, + body.clone(), + etag, + ) + .await; + let claim_refusal = request( + app, + &claimed, + method.clone(), + &record(&outside_id), + CLAIMED, + body.clone(), + etag, + ) + .await; + let missing = + request(app, &member, method, &record(&unknown), MEMBER, body, etag).await; + refusal.problem(status, code); + refusal.assert_same_problem(&claim_refusal); + refusal.assert_same_problem(&missing); + } + for (endpoint, status, code) in [ + ( + "move-facility/target-conditions", + StatusCode::NOT_FOUND, + "resource.not-found", + ), + ( + "close-facility", + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ] { + let refusal = action(app, &member, endpoint, MEMBER, json!({"facility":id})).await; + let claim_refusal = action( + app, + &claimed, + endpoint, + CLAIMED, + json!({"facility":outside_id}), + ) + .await; + let missing = + action(app, &member, endpoint, MEMBER, json!({"facility":unknown})).await; + refusal.problem(status, code); + refusal.assert_same_problem(&claim_refusal); + refusal.assert_same_problem(&missing); + } + let availability = + |facility: &str| json!({"targetInput":"facility","input":{"facility":facility}}); + let path = "/v1/actions/close-facility/availability"; + let refusal = request( + app, + &member, + Method::POST, + path, + "observer", + availability(&id), + None, + ) + .await; + let claim_refusal = request( + app, + &claimed, + Method::POST, + path, + "claim-observer", + availability(&outside_id), + None, + ) + .await; + let missing = request( + app, + &member, + Method::POST, + path, + "observer", + availability(&unknown), + None, + ) + .await; + refusal.problem(StatusCode::NOT_FOUND, "resource.not-found"); + missing.problem(StatusCode::NOT_FOUND, "resource.not-found"); + answers.insert(format!("{posture}-availability"), refusal.golden()); + answers.insert( + format!("{posture}-availability-claim"), + claim_refusal.golden(), + ); + answers.insert(format!("{posture}-availability-missing"), missing.golden()); + if posture == "development" { + assert_eq!(refusal.body["failedCheck"], "membership"); + assert_eq!(claim_refusal.body["failedCheck"], "row-boundary"); + refusal.assert_same_problem_except_check(&claim_refusal); + assert_eq!(missing.body["failedCheck"], "visibility"); + } else { + refusal.assert_same_problem(&missing); + refusal.assert_same_problem(&claim_refusal); + } + let undisclosed = request( + app, + &member, + Method::POST, + path, + "limited", + availability(&id), + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(undisclosed.body["availability"]["available"], Value::Null); + assert_eq!(undisclosed.body["availability"]["reason"], "not-disclosed"); + } + + let create = |id: Option<&str>| json!({"data":{"organization":id,"label":"denied-create"}}); + let claim_refusal = request( + app, + &claimed, + Method::POST, + RECORDS, + CLAIMED, + create(Some(&fixture.keys.foreign)), + None, + ) + .await; + let missing = request( + app, + &member, + Method::POST, + RECORDS, + MEMBER, + create(Some(&unknown)), + None, + ) + .await; + answers.insert(format!("{posture}-create-claim"), claim_refusal.golden()); + answers.insert(format!("{posture}-create-missing"), missing.golden()); + for body in [ + create(Some(&fixture.keys.foreign)), + create(Some(&fixture.keys.inactive)), + create(Some(&fixture.keys.tombstoned)), + create(None), + json!({"data":{"label":"missing-optional-key"}}), + ] { + let refusal = request(app, &member, Method::POST, RECORDS, MEMBER, body, None).await; + refusal.problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + if posture == "development" { + assert_eq!(refusal.body["failedCheck"], "membership"); + assert_eq!(claim_refusal.body["failedCheck"], "row-boundary"); + refusal.assert_same_problem_except_check(&claim_refusal); + } else { + refusal.assert_same_problem(&claim_refusal); + } + refusal.assert_same_problem(&missing); + } + + let denied = json!({"organization":fixture.keys.foreign,"label":"denied-action"}); + let observed = action(app, &member, "register-facility", MEMBER, denied.clone()).await; + let twin = action(app, &claimed, "register-facility", CLAIMED, denied).await; + observed.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + observed.assert_same_problem(&twin); + answers.insert( + format!("{posture}-observed-precondition"), + observed.golden(), + ); + + let guard = |id: &str| json!({"facility":id}); + let visible_id = visible.record_id(); + let disclosed = action( + app, + &member, + "close-facility", + "observer", + guard(&visible_id), + ) + .await; + disclosed.problem(StatusCode::PRECONDITION_FAILED, "action.guard-failed"); + assert_eq!(disclosed.body["guardReason"], "facility-not-open"); + let claim_disclosed = + action(app, &claimed, "close-facility", CLAIMED, guard(&visible_id)).await; + disclosed.assert_same_problem(&claim_disclosed); + let concealed = action( + app, + &member, + "close-facility", + "limited", + guard(&visible_id), + ) + .await; + let missing = action(app, &member, "close-facility", "limited", guard(&unknown)).await; + concealed.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + concealed.assert_same_problem(&missing); + answers.insert( + format!("{posture}-generic-precondition"), + concealed.golden(), + ); + } + let answers = serde_json::to_value(answers).unwrap(); + let path = concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/golden/membership_refusals.json" + ); + if std::env::var_os("REGISTRY_BREG_WRITE_GOLDEN").is_some() { + std::fs::write( + path, + format!("{}\n", serde_json::to_string_pretty(&answers).unwrap()), + ) + .unwrap(); + } else { + let recorded: Value = serde_json::from_slice(&std::fs::read(path).unwrap()).unwrap(); + assert_eq!(answers, recorded); + } + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn availability_checks_the_action_boundary_before_conditional_field_disclosure() { + let mut project = membership_write_project::project(); + project["recordTypes"]["facility"] + .as_object_mut() + .unwrap() + .remove("constraints"); + project["recordTypes"]["facility"]["disclosureConditions"] = json!({ + "withhold-organization":{ + "when":[{"type":"field-equals","field":"label","value":"sealed"}], + "withhold":"fields","fields":["organization"], + "exemptProfiles":["member","claimed","steward","claim-observer"] + } + }); + let fixture = + Fixture::configured(Duration::from_secs(2), project, vec![], |service| service).await; + let member = fixture.member(); + let inside = fixture.seed(Some(&fixture.keys.allowed), "sealed").await; + let outside = fixture.seed(Some(&fixture.keys.foreign), "sealed").await; + let before = fixture.durable_state().await; + let path = "/v1/actions/close-facility/availability"; + let input = |id| json!({"targetInput":"facility","input":{"facility":id}}); + let refused = request( + &fixture.app, + &member, + Method::POST, + path, + "observer", + input(outside.record_id()), + None, + ) + .await; + let missing = request( + &fixture.app, + &member, + Method::POST, + path, + "observer", + input(Uuid::new_v4().to_string()), + None, + ) + .await; + refused.problem(StatusCode::NOT_FOUND, "resource.not-found"); + refused.assert_same_problem(&missing); + + // The same disclosure condition continues to withhold details on a target + // covered by the selected Action grant. + let observed = request( + &fixture.app, + &member, + Method::POST, + path, + "observer", + input(inside.record_id()), + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(observed.body["availability"]["reason"], "not-disclosed"); + assert_eq!( + observed.body["availability"]["observedRevision"], + Value::Null + ); + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn patch_validation_and_tests_precede_proposed_membership_denial() { + let mut project = membership_write_project::project(); + project["recordTypes"]["facility"]["fields"][0]["required"] = json!(true); + let fixture = + Fixture::configured(Duration::from_secs(2), project, vec![], |service| service).await; + let member = fixture.member(); + let claimed = fixture.claimed(); + let row = fixture + .seed(Some(&fixture.keys.allowed), "patch-precedence") + .await; + let path = record(&row.record_id()); + let before = fixture.durable_state().await; + let foreign = &fixture.keys.foreign; + let cases = [ + (patch("organization", "invalid-reference"), Some("/0/value")), + (patch("organization", Value::Null), Some("/0/value")), + ( + json!([{"op":"remove","path":"/data/organization"}]), + Some("/0/op"), + ), + ( + json!([ + {"op":"replace","path":"/data/organization","value":foreign}, + {"op":"replace","path":"/data/label","value":false} + ]), + Some("/1/value"), + ), + ( + json!([ + {"op":"test","path":"/data/label","value":"different-label"}, + {"op":"replace","path":"/data/organization","value":foreign} + ]), + None, + ), + ]; + for app in [&fixture.app, &fixture.development] { + let member_get = request(app, &member, Method::GET, &path, MEMBER, Value::Null, None) + .await + .success(StatusCode::OK); + let claim_get = request( + app, + &claimed, + Method::GET, + &path, + CLAIMED, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + for (body, field_path) in &cases { + let expected = request( + app, + &claimed, + Method::PATCH, + &path, + CLAIMED, + body.clone(), + Some(claim_get.etag()), + ) + .await; + let actual = request( + app, + &member, + Method::PATCH, + &path, + MEMBER, + body.clone(), + Some(member_get.etag()), + ) + .await; + if let Some(field_path) = field_path { + expected.problem(StatusCode::BAD_REQUEST, "request.invalid"); + assert_eq!(expected.body["fieldPath"], *field_path); + } else { + expected.problem(StatusCode::CONFLICT, "mutation.conflict"); + } + actual.assert_same_problem(&expected); + } + } + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_patch_moving_a_row_to_a_key_the_caller_is_not_a_member_of_is_refused() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let claimed = fixture.claimed(); + let row = fixture.seed(Some(&fixture.keys.allowed), "movable").await; + let path = record(&row.record_id()); + let before = fixture.durable_state().await; + let mut results = Vec::new(); + let unknown = Uuid::new_v4().to_string(); + for (profile, token, key) in [ + (MEMBER, &member, &fixture.keys.foreign), + (CLAIMED, &claimed, &fixture.keys.foreign), + (MEMBER, &member, &unknown), + ] { + let get = request( + &fixture.app, + token, + Method::GET, + &path, + profile, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + results.push( + request( + &fixture.app, + token, + Method::PATCH, + &path, + profile, + patch("organization", key.as_str()), + Some(get.etag()), + ) + .await, + ); + } + results[0].problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + results[0].assert_same_problem(&results[1]); + results[0].assert_same_problem(&results[2]); + let condition = action( + &fixture.app, + &member, + "move-facility/target-conditions", + MEMBER, + json!({"facility":row.record_id()}), + ) + .await + .success(StatusCode::OK); + for key in [&fixture.keys.foreign, &unknown] { + request( + &fixture.app, + &member, + Method::POST, + "/v1/actions/move-facility", + MEMBER, + json!({ + "input":{"organization":key,"facility":row.record_id()}, + "preconditions":condition.body["preconditions"] + }), + None, + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + } + let get = request( + &fixture.app, + &member, + Method::GET, + &path, + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + let removed_key = request( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + json!([{"op":"remove","path":"/data/organization"}]), + Some(get.etag()), + ) + .await; + removed_key.assert_same_problem(&results[0]); + assert_eq!(fixture.durable_state().await, before); + request( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("label", "after-condition"), + Some(get.etag()), + ) + .await + .success(StatusCode::OK); + let after_edit = fixture.durable_state().await; + let stale = request( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("organization", fixture.keys.foreign.as_str()), + Some(get.etag()), + ) + .await; + stale.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, after_edit); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_membership_refusal_never_answers_service_unavailable() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let row = fixture + .seed(Some(&fixture.keys.allowed), "existing-label") + .await; + let outside = fixture + .seed(Some(&fixture.keys.foreign), "outside-label") + .await; + let before = fixture.durable_state().await; + let refused_create = json!({"operation":"create","data":{"organization":fixture.keys.foreign,"label":"existing-label"}}); + let missing_patch = json!({ + "operation":"patch","recordId":Uuid::new_v4(),"ifMatch":row.etag(), + "patch":patch("label", "missing") + }); + for (items, status, code) in [ + ( + json!([refused_create, missing_patch]), + StatusCode::FORBIDDEN, + "write.outside-boundary", + ), + ( + json!([missing_patch, refused_create]), + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + ), + ( + json!([ + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"rolled-back"}}, + refused_create + ]), + StatusCode::FORBIDDEN, + "write.outside-boundary", + ), + ] { + request( + &fixture.app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + json!({"items":items}), + None, + ) + .await + .problem(status, code); + assert_eq!(fixture.durable_state().await, before); + } + request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":refused_create["data"]}), + None, + ) + .await + .problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + + for input in [ + json!({"organization":fixture.keys.foreign,"label":"existing-label"}), + json!({"organization":fixture.keys.allowed,"related":outside.record_id(),"label":"existing-label"}), + ] { + action(&fixture.app, &member, "register-facility", MEMBER, input) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + } + action( + &fixture.app, + &member, + "register-pair", + MEMBER, + json!({"first":fixture.keys.allowed,"second":fixture.keys.foreign}), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + + let (run_path, chunk) = + announce_ingestion(&fixture, &member, &fixture.keys.foreign, "resumable").await; + let chunk_path = format!("{run_path}/chunks"); + request( + &fixture.app, + &member, + Method::POST, + &chunk_path, + MEMBER, + chunk.clone(), + None, + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + let open = request( + &fixture.app, + &member, + Method::GET, + &run_path, + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(open.body["run"]["status"], "open"); + assert_eq!(open.body["run"]["nextChunkIndex"], 0); + request( + &fixture.app, + &fixture.steward(), + Method::POST, + "/v1/records/memberships", + MEMBERSHIP_WRITER, + json!({"data":{"organization":fixture.keys.foreign,"principal":MEMBER,"active":true}}), + None, + ) + .await + .success(StatusCode::CREATED); + let resumed = request( + &fixture.app, + &member, + Method::POST, + &chunk_path, + MEMBER, + chunk, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(resumed.body["run"]["status"], "complete"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_fresh_principal_with_no_membership_lists_empty_and_cannot_write() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let guest = mint(&fixture.idp, "fresh", "", &[]); + let row = fixture.seed(Some(&fixture.keys.allowed), "open").await; + let path = record(&row.record_id()); + let listed = request( + &fixture.app, + &guest, + Method::GET, + RECORDS, + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(listed.body["items"], json!([])); + request( + &fixture.app, + &guest, + Method::GET, + &path, + MEMBER, + Value::Null, + None, + ) + .await + .problem(StatusCode::NOT_FOUND, "resource.not-found"); + request( + &fixture.app, + &guest, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":"fresh"}}), + None, + ) + .await + .problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + for (method, body) in [ + (Method::PATCH, patch("label", "fresh")), + (Method::DELETE, Value::Null), + ] { + request( + &fixture.app, + &guest, + method, + &path, + MEMBER, + body, + Some(row.etag()), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + } + action( + &fixture.app, + &guest, + "close-facility", + MEMBER, + json!({"facility":row.record_id()}), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + fixture.database.cleanup().await; +} + +async fn wait_for_blocker(database: &TestDatabase, blocker: i32) -> i32 { + tokio::time::timeout(Duration::from_secs(5), async { + loop { + if let Some(row) = database.admin.query_opt( + "SELECT pid FROM pg_catalog.pg_stat_activity + WHERE datname = current_database() AND $1 = ANY(pg_catalog.pg_blocking_pids(pid))", + &[&blocker], + ).await.unwrap() { + return row.get(0); + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }).await.expect("the expected transaction reached its lock wait") +} + +fn table(fixture: &Fixture, entity: &str) -> String { + format!( + "registry_data.\"{}\"", + fixture.registry.entities()[entity].physical_table + ) +} + +async fn hold_row(transaction: &tokio_postgres::Transaction<'_>, table: &str, id: &str) -> i32 { + transaction + .query_one( + &format!("SELECT pg_backend_pid() FROM {table} WHERE record_id=$1 FOR UPDATE"), + &[&Uuid::parse_str(id).unwrap()], + ) + .await + .unwrap() + .get(0) +} + +fn spawn_create(fixture: &Fixture, key: &str, label: &str) -> tokio::task::JoinHandle { + let app = fixture.app.clone(); + let token = fixture.member(); + let body = json!({"data":{"organization":key,"label":label}}); + tokio::spawn( + async move { request(&app, &token, Method::POST, RECORDS, MEMBER, body, None).await }, + ) +} + +#[tokio::test] +async fn a_write_holding_the_lock_makes_the_removal_wait() { + assert_write_makes_removal_wait(false).await; +} + +#[tokio::test] +async fn record_write_first_makes_the_removal_wait() { + assert_write_makes_removal_wait(true).await; +} + +async fn assert_write_makes_removal_wait(use_steward_api: bool) { + let lock_timeout = Duration::from_secs(10); + let fixture = if use_steward_api { + // An ordinary steward Patch uses the PostgreSQL role default. Use + // READ COMMITTED for both HTTP requests so they can commit in order. + Fixture::configured_with_isolation( + lock_timeout, + membership_write_project::project(), + Vec::new(), + "read committed", + |service| service, + ) + .await + } else { + Fixture::create(lock_timeout).await + }; + let row = fixture + .seed(Some(&fixture.keys.allowed), "before-write") + .await; + let path = record(&row.record_id()); + let member = fixture.member(); + let member_row = request( + &fixture.app, + &member, + Method::GET, + &path, + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + let (mut admin, admin_connection) = fixture.database.connect_admin().await; + let blocker = admin.transaction().await.unwrap(); + let blocker_pid = hold_row(&blocker, &table(&fixture, "facility"), &row.record_id()).await; + let app = fixture.app.clone(); + let writer = tokio::spawn(async move { + request( + &app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("label", "committed-before-removal"), + Some(member_row.etag()), + ) + .await + }); + let writer_pid = wait_for_blocker(&fixture.database, blocker_pid).await; + let removal = if use_steward_api { + let path = format!("/v1/records/memberships/{}", fixture.keys.membership); + let app = fixture.app.clone(); + let steward = fixture.steward(); + let current = request( + &app, + &steward, + Method::GET, + &path, + MEMBERSHIP_WRITER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + tokio::spawn(async move { + let revoked = request( + &app, + &steward, + Method::PATCH, + &path, + MEMBERSHIP_WRITER, + patch("active", false), + Some(current.etag()), + ) + .await + .success(StatusCode::OK); + assert_eq!(revoked.body["data"]["domainData"]["active"], false); + }) + } else { + // A separate READ COMMITTED transaction isolates the membership wait + // from the ordinary mutation journal's revision clock. The bounded + // writer still uses the runtime role's REPEATABLE READ default. + let (remover, removal_connection) = fixture.database.connect_admin().await; + let membership = &fixture.registry.entities()["membership"]; + let sql = format!( + "UPDATE {} SET \"{}\"=false WHERE record_id=$1", + table(&fixture, "membership"), + membership.fields["active"].physical_name, + ); + let membership_id = Uuid::parse_str(&fixture.keys.membership).unwrap(); + tokio::spawn(async move { + assert_eq!(remover.execute(&sql, &[&membership_id]).await.unwrap(), 1); + removal_connection.abort(); + }) + }; + wait_for_blocker(&fixture.database, writer_pid).await; + blocker.commit().await.unwrap(); + writer.await.unwrap().success(StatusCode::OK); + removal.await.unwrap(); + admin_connection.abort(); + request( + &fixture.app, + &fixture.member(), + Method::GET, + &record(&row.record_id()), + MEMBER, + Value::Null, + None, + ) + .await + .problem(StatusCode::NOT_FOUND, "resource.not-found"); + let committed = request( + &fixture.app, + &fixture.steward(), + Method::GET, + &record(&row.record_id()), + MEMBERSHIP_WRITER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!( + committed.body["data"]["domainData"]["label"], + "committed-before-removal" + ); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn record_removal_first_refuses_the_write() { + let fixture = Fixture::create(Duration::from_secs(10)).await; + let before = fixture.durable_state().await; + let app = fixture.app.clone(); + let member = fixture.member(); + let body = + json!({"data":{"organization":fixture.keys.allowed,"label":"revoked-before-create"}}); + after_steward_removal(&fixture, async move { + request(&app, &member, Method::POST, RECORDS, MEMBER, body, None).await + }) + .await + .problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + // The steward records its own removal. The refused writer creates no facility. + assert_eq!(fixture.durable_state().await[0], before[0]); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_lock_wait_past_lock_timeout_answers_service_unavailable() { + let fixture = Fixture::create(Duration::from_millis(250)).await; + let (mut admin, connection) = fixture.database.connect_admin().await; + let blocker = admin.transaction().await.unwrap(); + hold_row( + &blocker, + &table(&fixture, "membership"), + &fixture.keys.membership, + ) + .await; + let before = fixture.durable_state().await; + spawn_create(&fixture, &fixture.keys.allowed, "bounded-lock-wait") + .await + .unwrap() + .problem(StatusCode::SERVICE_UNAVAILABLE, "service.unavailable"); + assert_eq!(fixture.durable_state().await, before); + blocker.rollback().await.unwrap(); + spawn_create(&fixture, &fixture.keys.allowed, "bounded-lock-wait") + .await + .unwrap() + .success(StatusCode::CREATED); + connection.abort(); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn an_action_cannot_invalidate_its_own_membership_proof() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let maintainer = mint(&fixture.idp, MEMBER, "records:retire", &[]); + let before = fixture.durable_state().await; + for action_id in [ + "register-and-retire-membership", + "retire-membership-and-register", + ] { + action( + &fixture.app, &maintainer, action_id, "maintainer", + json!({"organization":fixture.keys.allowed,"membership":fixture.keys.membership,"label":"rolled-back-action"}), + ).await.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + } + + action( + &fixture.app, + &maintainer, + "register-in-created-organization", + "maintainer", + json!({"label":"reserved-reference"}), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn package_admission_precedes_sorted_membership_locks() { + let fixture = Fixture::create(Duration::from_secs(10)).await; + let (mut admin, connection) = fixture.database.connect_admin().await; + let package = admin.transaction().await.unwrap(); + let package_key = RegistryLockKey::derive(PACKAGE).unwrap().get(); + package + .query_one("SELECT pg_advisory_xact_lock($1)", &[&package_key]) + .await + .unwrap(); + let package_pid = package + .query_one("SELECT pg_backend_pid()", &[]) + .await + .unwrap() + .get(0); + + let membership_table = table(&fixture, "membership"); + let key_column = + &fixture.registry.entities()["membership"].fields["organization"].physical_name; + let key_for = |key: &str| Uuid::parse_str(key).unwrap(); + let mut keys = [ + key_for(&fixture.keys.allowed), + key_for(&fixture.keys.second), + ]; + keys.sort(); + let (mut last, last_connection) = fixture.database.connect_admin().await; + let last = last.transaction().await.unwrap(); + let last_pid = last.query_one( + &format!("SELECT pg_backend_pid() FROM {membership_table} WHERE \"{key_column}\"=$1 FOR UPDATE"), + &[&keys[1]], + ).await.unwrap().get(0); + + let app = fixture.app.clone(); + let member = fixture.member(); + let batch = + tokio::spawn(async move { + request( + &app, &member, Method::POST, &format!("{RECORDS}:batch"), MEMBER, + json!({"items":[ + {"operation":"create","data":{"organization":keys[1],"label":"lock-order-last"}}, + {"operation":"create","data":{"organization":keys[0],"label":"lock-order-first"}} + ]}), None, + ).await + }); + let writer_pid = wait_for_blocker(&fixture.database, package_pid).await; + let nowait = + format!("SELECT 1 FROM {membership_table} WHERE \"{key_column}\"=$1 FOR UPDATE NOWAIT"); + fixture + .database + .admin + .query_one(&nowait, &[&keys[0]]) + .await + .unwrap(); + package.commit().await.unwrap(); + assert_eq!( + wait_for_blocker(&fixture.database, last_pid).await, + writer_pid + ); + let error = fixture + .database + .admin + .query_one(&nowait, &[&keys[0]]) + .await + .unwrap_err(); + assert_eq!( + error.code(), + Some(&tokio_postgres::error::SqlState::LOCK_NOT_AVAILABLE) + ); + last.commit().await.unwrap(); + batch.await.unwrap().success(StatusCode::OK); + last_connection.abort(); + connection.abort(); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn action_rechecks_drifted_keys_for_current_revision_and_unconditioned_links() { + let fixture = Fixture::create(Duration::from_secs(10)).await; + for is_link in [false, true] { + let row = fixture.seed(Some(&fixture.keys.allowed), "open").await; + let (mut target_owner, target_connection) = fixture.database.connect_admin().await; + let move_key = target_owner.transaction().await.unwrap(); + let facility = &fixture.registry.entities()["facility"]; + let organization = &facility.fields["organization"].physical_name; + let target_pid = move_key + .query_one( + &format!( + "UPDATE {} SET \"{organization}\"=$1, record_revision=record_revision+1 + WHERE record_id=$2 RETURNING pg_backend_pid()", + table(&fixture, "facility") + ), + &[ + &Uuid::parse_str(&fixture.keys.second).unwrap(), + &Uuid::parse_str(&row.record_id()).unwrap(), + ], + ) + .await + .unwrap() + .get(0); + + let membership = &fixture.registry.entities()["membership"]; + let key = &membership.fields["organization"].physical_name; + let active = &membership.fields["active"].physical_name; + let (mut membership_owner, membership_connection) = fixture.database.connect_admin().await; + let disabling_destination = membership_owner.transaction().await.unwrap(); + let destination_pid = disabling_destination + .query_one( + &format!( + "UPDATE {} SET \"{active}\"=false WHERE \"{key}\"=$1 RETURNING pg_backend_pid()", + table(&fixture, "membership") + ), + &[&Uuid::parse_str(&fixture.keys.second).unwrap()], + ) + .await + .unwrap() + .get(0); + let app = fixture.app.clone(); + let member = fixture.member(); + let source = fixture.keys.allowed.clone(); + let target = row.record_id(); + let requested = tokio::spawn(async move { + if is_link { + action( + &app, + &member, + "register-facility", + MEMBER, + json!({"organization":source,"related":target,"label":"linked-after-move"}), + ) + .await + } else { + action( + &app, + &member, + "close-facility", + MEMBER, + json!({"facility":target}), + ) + .await + } + }); + let writer_pid = wait_for_blocker(&fixture.database, target_pid).await; + move_key.commit().await.unwrap(); + assert_eq!( + wait_for_blocker(&fixture.database, destination_pid).await, + writer_pid + ); + disabling_destination.commit().await.unwrap(); + requested + .await + .unwrap() + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + let steward = fixture.steward(); + let path = record(&row.record_id()); + let get = request( + &fixture.app, + &steward, + Method::GET, + &path, + MEMBERSHIP_WRITER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(get.body["data"]["domainData"]["label"], "open"); + assert_eq!(get.body["data"]["revisionId"], "2"); + fixture + .database + .admin + .execute( + &format!( + "UPDATE {} SET \"{active}\"=true WHERE \"{key}\"=$1", + table(&fixture, "membership") + ), + &[&Uuid::parse_str(&fixture.keys.second).unwrap()], + ) + .await + .unwrap(); + request( + &fixture.app, + &steward, + Method::PATCH, + &path, + MEMBERSHIP_WRITER, + patch("label", format!("moved-{is_link}")), + Some(get.etag()), + ) + .await + .success(StatusCode::OK); + target_connection.abort(); + membership_connection.abort(); + } + fixture.database.cleanup().await; +} + +fn with_evidence() -> (Value, Vec) { + let mut project = membership_write_project::project(); + project["evidenceProviders"] = json!({ + "farmer-registry":{ + "contracts":"evidence/farmer-contracts.json", + "subjectResolution":"trusted-provider-exact-selector" + } + }); + let original = project["actions"]["register-facility"].clone(); + let grant = project["accessProfiles"]["member"]["permissions"]["actions"][0].clone(); + for id in [ + "register-with-commit-evidence", + "register-with-function-evidence", + ] { + let mut action = original.clone(); + action["inputs"] = json!([ + original["inputs"][0].clone(), + original["inputs"][2].clone(), + {"id":"farmer-number","type":"string","minimumLength":3,"maximumLength":77, + "required":true,"classification":"internal"} + ]); + let mut permission = grant.clone(); + permission["action"] = json!(id); + if id == "register-with-commit-evidence" { + action["plan"]["effects"][0]["set"] + .as_object_mut() + .unwrap() + .remove("related"); + action["commitGuards"] = json!({"evidence":[{ + "id":"farmer-status","provider":"farmer-registry", + "requirement":"urn:example:farmer:status-v1", + "subjects":{"farmer":{"profile":"farmer-number-v1", + "selectors":{"farmer-number":{"type":"input","input":"farmer-number"}}}}, + "requires":[{"output":"active","equals":true}], "maximumObservationAgeSeconds":60 + }]}); + } else { + action["plan"] = json!({"type":"scripted","actionPlan":"register-with-evidence", + "inputs":["organization","label","farmer-number"], + "writes":[{"id":"register","target":{"recordType":"facility"},"operation":"create", + "fields":["organization","label"]}] + }); + action["evidence"] = json!([{ + "id":"farmer-status","provider":"farmer-registry", + "requirement":"urn:example:farmer:status-v1", + "subjects":{"farmer":{"profile":"farmer-number-v1"}}, + "outputs":["active"],"maximumObservationAgeSeconds":60 + }]); + } + project["actions"][id] = action; + project["accessProfiles"]["member"]["permissions"]["actions"] + .as_array_mut() + .unwrap() + .push(permission); + } + project["actionPlans"] = json!({ + "register-with-evidence":{ + "runtime":"rhai","source":"scripts/register-with-evidence.rhai", + "entrypoint":"plan","abi":"registry.action-plan/v1","capabilities":["evidence"] + } + }); + let assets = [ + ( + "evidence/farmer-contracts.json", + include_bytes!("../../../../products/breg/acceptance/farmer-landholding-evidence/evidence/farmer-contracts.json").as_slice(), + ), + ( + "scripts/register-with-evidence.rhai", + br#"fn plan(ctx) { + let subjects = #{farmer: #{"farmer-number": ctx.inputs["farmer-number"]}}; + evidence::resolve("farmer-status", subjects); + #{effects: [#{id:"register", set: #{ + organization: #{fromInput:"organization"}, label: ctx.inputs["label"] + }}]} + }"#.as_slice(), + ), + ].into_iter().map(|(path, bytes)| ModuleAssetSource { + module: None, path: path.to_owned(), bytes: bytes.to_vec(), + }).collect(); + (project, assets) +} + +#[tokio::test] +async fn evidence_admission_refuses_unsatisfiable_membership_and_replays_without_acquisition() { + use registry_breg::action_evidence::ActionEvidenceEvaluator; + use registry_platform_crypto::{generate_private_jwk, GeneratedKeyAlgorithm}; + + let key = generate_private_jwk(GeneratedKeyAlgorithm::Es256).unwrap(); + let provider = super::action_evidence_provider::EvidenceProvider::start_with_key(key).await; + let (project, assets) = with_evidence(); + let fixture = Fixture::configured(Duration::from_secs(2), project, assets, |service| { + service.with_evidence_evaluator(Arc::new(ActionEvidenceEvaluator::new(provider.client()))) + }) + .await; + let member = fixture.member(); + let before = fixture.durable_state().await; + for action_id in [ + "register-with-commit-evidence", + "register-with-function-evidence", + ] { + let input = |organization: &str| { + json!({ + "organization":organization,"label":action_id,"farmerNumber":"DEMO-1" + }) + }; + let calls = provider.calls(); + action( + &fixture.app, + &member, + action_id, + MEMBER, + input(&fixture.keys.foreign), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(provider.calls(), calls); + if calls == 0 { + assert_eq!(fixture.durable_state().await, before); + } + let body = json!({"input":input(&fixture.keys.allowed)}); + let path = format!("/v1/actions/{action_id}"); + let first = request_with_key( + &fixture.app, + &member, + Method::POST, + &path, + MEMBER, + body.clone(), + None, + action_id, + ) + .await + .success(StatusCode::OK); + assert_eq!(provider.calls(), calls + 1); + let replay = request_with_key( + &fixture.app, + &member, + Method::POST, + &path, + MEMBER, + body, + None, + action_id, + ) + .await + .success(StatusCode::OK); + assert_eq!(first.bytes, replay.bytes); + assert_eq!(provider.calls(), calls + 1); + } + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn evidence_admission_requires_a_permitted_value_for_the_only_patch_field() { + use registry_breg::action_evidence::ActionEvidenceEvaluator; + use registry_platform_crypto::{generate_private_jwk, GeneratedKeyAlgorithm}; + + let (mut project, mut assets) = with_evidence(); + let action_id = "move-with-evidence"; + let mut action_source = project["actions"]["move-facility"].clone(); + action_source["inputs"] + .as_array_mut() + .unwrap() + .push(project["actions"]["register-with-function-evidence"]["inputs"][2].clone()); + action_source["evidence"] = + project["actions"]["register-with-function-evidence"]["evidence"].clone(); + action_source["plan"] = json!({ + "type":"scripted","actionPlan":action_id,"inputs":["facility","organization","farmer-number"], + "writes":[{"id":"move","target":{"fromInput":"facility"},"operation":"patch", + "fields":["organization"]}] + }); + project["actions"][action_id] = action_source; + let member_actions = project["accessProfiles"]["member"]["permissions"]["actions"] + .as_array_mut() + .unwrap(); + let mut grant = member_actions + .iter() + .find(|grant| grant["action"] == "move-facility") + .unwrap() + .clone(); + grant["action"] = json!(action_id); + member_actions.push(grant); + let script = "scripts/move-with-evidence.rhai"; + project["actionPlans"][action_id] = json!({ + "runtime":"rhai","source":script,"entrypoint":"plan", + "abi":"registry.action-plan/v1","capabilities":["evidence"] + }); + assets.push(ModuleAssetSource { + module: None, + path: script.to_owned(), + bytes: br#"fn plan(ctx) { + let subjects = #{farmer: #{"farmer-number": ctx.inputs["farmer-number"]}}; + evidence::resolve("farmer-status", subjects); + #{effects: [#{id:"move", set: #{organization: #{fromInput:"organization"}}}]} + }"# + .to_vec(), + }); + + let key = generate_private_jwk(GeneratedKeyAlgorithm::Es256).unwrap(); + let provider = super::action_evidence_provider::EvidenceProvider::start_with_key(key).await; + let fixture = Fixture::configured(Duration::from_secs(2), project, assets, |service| { + service.with_evidence_evaluator(Arc::new(ActionEvidenceEvaluator::new(provider.client()))) + }) + .await; + let member = fixture.member(); + let row = fixture + .seed(Some(&fixture.keys.allowed), "evidence-move") + .await; + let id = row.record_id(); + let conditions = action( + &fixture.app, + &member, + "move-with-evidence/target-conditions", + MEMBER, + json!({"facility":id}), + ) + .await + .success(StatusCode::OK); + let body = |organization| { + json!({ + "input":{"facility":id,"organization":organization,"farmerNumber":"DEMO-1"}, + "preconditions":conditions.body["preconditions"] + }) + }; + let path = "/v1/actions/move-with-evidence"; + let before = fixture.durable_state().await; + request( + &fixture.app, + &member, + Method::POST, + path, + MEMBER, + body(&fixture.keys.foreign), + None, + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(provider.calls(), 0); + assert_eq!(fixture.durable_state().await, before); + request( + &fixture.app, + &member, + Method::POST, + path, + MEMBER, + body(&fixture.keys.second), + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(provider.calls(), 1); + fixture.database.cleanup().await; +} + +const MEMBERSHIP_FILE: &[u8] = b"fixture attachment"; +const FILE_ACTION: &str = "/v1/actions/register-facility"; + +fn membership_file_project(with_proposal: bool) -> Value { + let mut project = if with_proposal { + membership_write_project::proposal_project() + } else { + membership_write_project::project() + }; + let slot = json!({ + "id":"support","maximumBytes":4096,"contentTypes":["text/plain"], + "classification":"restricted" + }); + let mut record_slot = slot.clone(); + record_slot["writeOnce"] = json!(true); + project["recordTypes"]["facility"]["attachments"] = json!([record_slot]); + let promotion = json!({"support":{"fromAttachment":"support"}}); + project["actions"]["register-facility"]["plan"]["effects"][0]["attachments"] = + promotion.clone(); + if with_proposal { + // A shared sequence would serialize the creates before the file work. + project["recordTypes"]["facility"]["fields"] + .as_array_mut() + .unwrap() + .retain(|field| field["id"] != "number"); + for profile in project["accessProfiles"] + .as_object_mut() + .unwrap() + .values_mut() + { + if let Some(grants) = profile + .pointer_mut("/permissions/records") + .and_then(Value::as_array_mut) + { + for grant in grants + .iter_mut() + .filter(|grant| grant["recordType"] == "facility") + { + if let Some(fields) = grant["readableFields"].as_array_mut() { + fields.retain(|field| field != "number"); + } + } + } + } + let mut proposal_slot = slot; + proposal_slot["required"] = json!(true); + project["actions"]["propose-facility"]["execution"]["proposal"]["attachments"] = + json!([proposal_slot]); + project["actions"]["propose-facility"]["plan"]["effects"][0]["attachments"] = promotion; + for profile in ["member", "claimed"] { + let grants = project["accessProfiles"][profile]["permissions"]["proposals"] + .as_array_mut() + .unwrap(); + let grant = grants + .iter_mut() + .find(|grant| grant["action"] == "propose-facility") + .unwrap(); + grant["readableAttachments"] = json!(["support"]); + grant["writableAttachments"] = json!(["support"]); + } + } + project +} + +#[derive(Default)] +struct MembershipPutObserver { + entered: tokio::sync::Notify, + resume: tokio::sync::Notify, +} + +struct MembershipS3 { + storage: registry_breg::attachment_storage::AttachmentStorage, + requests: Arc, + puts: Arc, + server: tokio::task::JoinHandle<()>, +} + +impl Drop for MembershipS3 { + fn drop(&mut self) { + self.server.abort(); + } +} + +async fn membership_s3(put_observer: Option>) -> MembershipS3 { + use std::sync::atomic::{AtomicUsize, Ordering}; + + let requests = Arc::new(AtomicUsize::new(0)); + let calls = requests.clone(); + let puts = Arc::new(AtomicUsize::new(0)); + let put_count = puts.clone(); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let endpoint = format!("http://{}", listener.local_addr().unwrap()); + let server = tokio::spawn(async move { + let bytes = Arc::new(tokio::sync::Mutex::new(Vec::new())); + let app = axum::Router::new().fallback(move | + method: Method, uri: axum::extract::OriginalUri, body: axum::body::Bytes, + | { + let calls = calls.clone(); + let bytes = bytes.clone(); + let put_count = put_count.clone(); + let put_observer = put_observer.clone(); + async move { + calls.fetch_add(1, Ordering::SeqCst); + match method { + Method::GET if uri.query().is_some() => ( + StatusCode::OK, + b"".to_vec(), + ), + Method::PUT => { + put_count.fetch_add(1, Ordering::SeqCst); + if let Some(observer) = put_observer { + observer.entered.notify_one(); + observer.resume.notified().await; + } + *bytes.lock().await = body.to_vec(); + (StatusCode::OK, Vec::new()) + } + Method::GET => (StatusCode::OK, bytes.lock().await.clone()), + _ => (StatusCode::METHOD_NOT_ALLOWED, Vec::new()), + } + } + }); + axum::serve(listener, app).await.unwrap(); + }); + let directory = tempfile::tempdir_in(std::env::temp_dir().canonicalize().unwrap()).unwrap(); + for name in ["access", "key"] { + write_test_secret( + &directory.path().join(name), + Uuid::new_v4().simple().to_string().as_bytes(), + ); + } + let config = runtime_fixture(directory.path()); + let config = format!( + "{config}\nattachmentStorage:\n type: s3\n url: {endpoint}\n bucket: member-files\n region: us-east-1\n accessKeyIdRef: secret:file/access\n secretAccessKeyRef: secret:file/key\n" + ); + let config = registry_breg::runtime_config::parse_runtime_config( + &config, + DeclaredPosture { + posture: Posture::Production, + source: PostureSource::Flag, + }, + ) + .unwrap(); + let storage = config.activate_attachment_storage(PACKAGE).await.unwrap(); + MembershipS3 { + storage, + requests, + puts, + server, + } +} + +fn membership_file_body(organization: &str, label: &str) -> Value { + use base64::{engine::general_purpose::STANDARD, Engine as _}; + + json!({ + "input":{"organization":organization,"label":label}, + "attachments":{"support":{"contentType":"text/plain", + "sha256":hex::encode(Sha256::digest(MEMBERSHIP_FILE)), + "content":STANDARD.encode(MEMBERSHIP_FILE) + }} + }) +} + +#[tokio::test] +async fn a_membership_refusal_leaves_s3_staging_unchanged() { + use std::sync::atomic::Ordering; + + let s3 = membership_s3(None).await; + let fixture = Fixture::configured( + Duration::from_secs(2), + membership_file_project(false), + vec![], + |service| service.with_attachment_storage(s3.storage.clone()), + ) + .await; + + let durable_before = fixture.durable_state().await; + let calls_before = s3.requests.load(Ordering::SeqCst); + request( + &fixture.app, + &fixture.member(), + Method::POST, + FILE_ACTION, + MEMBER, + membership_file_body(&fixture.keys.foreign, "attachment-refusal"), + None, + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(s3.requests.load(Ordering::SeqCst), calls_before); + assert_eq!(fixture.durable_state().await, durable_before); + let row = fixture + .database + .admin + .query_one( + "SELECT (SELECT count(*) FROM registry_internal.registry_attachment_blobs), + (SELECT count(*) FROM registry_internal.registry_record_attachments)", + &[], + ) + .await + .unwrap(); + assert_eq!((row.get::<_, i64>(0), row.get::<_, i64>(1)), (0, 0)); + let valid_body = membership_file_body(&fixture.keys.allowed, "attachment-accepted"); + let token = fixture.member(); + let endpoint = FILE_ACTION; + let first = request_with_key( + &fixture.app, + &token, + Method::POST, + endpoint, + MEMBER, + valid_body.clone(), + None, + "attachment-accepted", + ) + .await + .success(StatusCode::OK); + let calls_after_write = s3.requests.load(Ordering::SeqCst); + assert!(calls_after_write > calls_before); + let replay = request_with_key( + &fixture.app, + &token, + Method::POST, + endpoint, + MEMBER, + valid_body, + None, + "attachment-accepted", + ) + .await + .success(StatusCode::OK); + assert_eq!(first.bytes, replay.bytes); + assert_eq!(s3.requests.load(Ordering::SeqCst), calls_after_write); + let state: String = fixture + .database + .admin + .query_one( + "SELECT state FROM registry_internal.registry_attachment_blobs", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(state, "live"); + fixture.database.cleanup().await; +} + +async fn membership_file_action(fixture: &Fixture, token: &str, body: &Value, key: &str) -> Reply { + request_with_key( + &fixture.app, + token, + Method::POST, + FILE_ACTION, + MEMBER, + body.clone(), + None, + key, + ) + .await +} + +async fn file_commit_state(fixture: &Fixture) -> (i64, i64, i64, i64) { + let row = fixture + .database + .admin + .query_one( + "SELECT latest_position, + (SELECT count(*) FROM registry_internal.registry_record_attachments), + (SELECT count(*) FROM registry_internal.registry_idempotency), + (SELECT count(*) FROM registry_internal.registry_proposal_applications) + FROM registry_internal.registry_commit_head", + &[], + ) + .await + .unwrap(); + (row.get(0), row.get(1), row.get(2), row.get(3)) +} + +async fn assert_file_commit_members( + fixture: &Fixture, + previous_position: i64, + expected: i64, +) -> Vec { + let hash = hex::encode(Sha256::digest(MEMBERSHIP_FILE)); + let rows = fixture + .database + .admin + .query( + "SELECT m.record_id::text, m.record_revision, m.commit_position, a.sha256, b.state + FROM registry_internal.registry_revision_commit_members m + JOIN registry_internal.registry_record_attachments a + ON (a.entity_id, a.record_id, a.attached_revision) = + (m.entity_id, m.record_id, m.record_revision) + JOIN registry_internal.registry_attachment_blobs b ON b.sha256 = a.sha256 + WHERE m.entity_id = 'facility' AND a.slot_id = 'support' AND a.erased_at IS NULL + AND m.commit_position > $1 + ORDER BY m.commit_position", + &[&previous_position], + ) + .await + .unwrap(); + assert_eq!(rows.len() as i64, expected); + rows.iter() + .enumerate() + .map(|(index, row)| { + assert_eq!(row.get::<_, i64>(1), 1); + assert_eq!(row.get::<_, i64>(2), previous_position + index as i64 + 1); + assert_eq!(row.get::<_, String>(3), hash); + assert_eq!(row.get::<_, String>(4), "live"); + row.get(0) + }) + .collect() +} + +#[tokio::test] +async fn membership_file_action_commits_and_replays_with_one_ordinary_connection() { + use std::sync::atomic::Ordering; + + let observer = Arc::new(MembershipPutObserver::default()); + let s3 = membership_s3(Some(observer.clone())).await; + let fixture = Fixture::configured_with_pool( + Duration::from_secs(2), + membership_file_project(false), + vec![], + "repeatable read", + 1, + |service| service.with_attachment_storage(s3.storage.clone()), + ) + .await; + let token = fixture.member(); + let before = file_commit_state(&fixture).await; + let durable_before = fixture.durable_state().await; + let body = membership_file_body(&fixture.keys.allowed, "one-connection"); + let key = "one-connection-file"; + let (reply, ()) = tokio::time::timeout(Duration::from_secs(12), async { + tokio::join!( + membership_file_action(&fixture, &token, &body, key), + async { + observer.entered.notified().await; + let state: String = fixture + .database + .admin + .query_one( + "SELECT state FROM registry_internal.registry_attachment_blobs", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(state, "staged"); + assert_eq!(file_commit_state(&fixture).await, before); + assert_eq!(fixture.durable_state().await, durable_before); + observer.resume.notify_one(); + }, + ) + }) + .await + .expect("the single ordinary connection and staging connection settle"); + let reply = reply.success(StatusCode::OK); + let committed = (before.0 + 1, before.1 + 1, before.2 + 1, before.3); + assert_eq!(file_commit_state(&fixture).await, committed); + let ids = assert_file_commit_members(&fixture, before.0, 1).await; + assert_eq!(reply.body["results"]["register"]["recordId"], ids[0]); + assert_eq!(s3.puts.load(Ordering::SeqCst), 1); + + let replay = tokio::time::timeout( + Duration::from_secs(5), + membership_file_action(&fixture, &token, &body, key), + ) + .await + .expect("the receipt replays without waiting for another PUT") + .success(StatusCode::OK); + assert_eq!(replay.bytes, reply.bytes); + assert_eq!(file_commit_state(&fixture).await, committed); + assert_eq!(s3.puts.load(Ordering::SeqCst), 1); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn membership_file_action_rolls_back_after_a_completed_put() { + use registry_breg::mutation::MutationFaultPoint; + use std::sync::atomic::Ordering; + + let s3 = membership_s3(None).await; + let fixture = Fixture::configured( + Duration::from_secs(2), + membership_file_project(false), + vec![], + |service| service.with_attachment_storage(s3.storage.clone()), + ) + .await; + let faulted = Arc::new( + (*fixture.mutations) + .clone() + .with_fault_for_test(MutationFaultPoint::BeforeCommit), + ); + let faulted_app = authenticated_router( + Arc::new((*fixture.service).clone().with_postgres_mutations(faulted)), + fixture.authenticator.clone(), + ); + let before = file_commit_state(&fixture).await; + let durable_before = fixture.durable_state().await; + let body = membership_file_body(&fixture.keys.allowed, "rolled-back-file"); + let token = fixture.member(); + let key = "rolled-back-file"; + let reply = request_with_key( + &faulted_app, + &token, + Method::POST, + FILE_ACTION, + MEMBER, + body.clone(), + None, + key, + ) + .await; + assert_eq!( + reply.status, + StatusCode::SERVICE_UNAVAILABLE, + "{}", + reply.body + ); + assert_eq!(s3.puts.load(Ordering::SeqCst), 1); + assert_eq!(file_commit_state(&fixture).await, before); + assert_eq!(fixture.durable_state().await, durable_before); + let state: String = fixture + .database + .admin + .query_one( + "SELECT state FROM registry_internal.registry_attachment_blobs", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(state, "staged"); + let retry = membership_file_action(&fixture, &token, &body, key) + .await + .success(StatusCode::OK); + let committed = (before.0 + 1, before.1 + 1, before.2 + 1, before.3); + assert_eq!(file_commit_state(&fixture).await, committed); + let ids = assert_file_commit_members(&fixture, before.0, 1).await; + assert_eq!(retry.body["results"]["register"]["recordId"], ids[0]); + assert_eq!(s3.puts.load(Ordering::SeqCst), 2); + let replay = membership_file_action(&fixture, &token, &body, key) + .await + .success(StatusCode::OK); + assert_eq!(retry.bytes, replay.bytes); + assert_eq!(file_commit_state(&fixture).await, committed); + assert_eq!(s3.puts.load(Ordering::SeqCst), 2); + drop(faulted_app); + + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn database_membership_file_action_records_bytes_with_its_revision() { + let fixture = Fixture::configured( + Duration::from_secs(2), + membership_file_project(false), + vec![], + |service| service, + ) + .await; + let before = file_commit_state(&fixture).await; + let body = membership_file_body(&fixture.keys.allowed, "database-file"); + let reply = membership_file_action(&fixture, &fixture.member(), &body, "database-file") + .await + .success(StatusCode::OK); + assert_eq!( + file_commit_state(&fixture).await, + (before.0 + 1, before.1 + 1, before.2 + 1, before.3) + ); + let ids = assert_file_commit_members(&fixture, before.0, 1).await; + assert_eq!(reply.body["results"]["register"]["recordId"], ids[0]); + let content: Vec = fixture.database.admin.query_one( + "SELECT content FROM registry_internal.registry_attachment_blobs WHERE backend_id = 'database'", + &[], + ).await.unwrap().get(0); + assert_eq!(content, MEMBERSHIP_FILE); + fixture.database.cleanup().await; +} + +async fn freeze_membership_file_proposal(fixture: &Fixture, token: &str) -> Reply { + let draft = action( + &fixture.app, + token, + "propose-facility/proposals", + MEMBER, + json!({"organization":fixture.keys.allowed,"label":"proposed-file"}), + ) + .await + .success(StatusCode::CREATED); + let id = draft.body["id"].as_str().unwrap(); + let upload_etag = draft.body["attachments"]["support"]["links"]["upload"]["ifMatch"] + .as_str() + .expect("the authorized draft exposes an upload precondition"); + let upload = Request::builder() + .method(Method::PATCH) + .uri(format!( + "/v1/proposals/{id}/attachments/support?accessProfile={MEMBER}" + )) + .header("authorization", format!("Bearer {token}")) + .header("idempotency-key", "upload-shared-membership-file") + .header("if-match", upload_etag) + .header("content-type", "text/plain") + .body(Body::from(MEMBERSHIP_FILE)) + .unwrap(); + let (parts, body) = fixture + .app + .clone() + .oneshot(upload) + .await + .unwrap() + .into_parts(); + let bytes = to_bytes(body, 1024 * 1024).await.unwrap().to_vec(); + let uploaded = Reply { + status: parts.status, + headers: parts.headers, + body: serde_json::from_slice(&bytes).unwrap(), + bytes, + } + .success(StatusCode::OK); + proposal_transition(&fixture.app, token, MEMBER, &uploaded, "submit", json!({})) + .await + .success(StatusCode::OK) +} + +// Run this ordinary overlap against the repaired candidate. The barrier +// releases both requests at entry, with no coordination inside either path. +#[tokio::test] +async fn membership_file_action_and_apply_settle_with_one_shared_blob() { + use std::sync::atomic::Ordering; + + let s3 = membership_s3(None).await; + let fixture = Fixture::configured_with_isolation( + Duration::from_secs(5), + membership_file_project(true), + vec![], + "read committed", + |service| service.with_attachment_storage(s3.storage.clone()), + ) + .await; + let token = fixture.member(); + let submitted = freeze_membership_file_proposal(&fixture, &token).await; + let body = membership_file_body(&fixture.keys.second, "immediate-file"); + let before = file_commit_state(&fixture).await; + let puts_before = s3.puts.load(Ordering::SeqCst); + assert_eq!(puts_before, 1); + + let barrier = tokio::sync::Barrier::new(2); + let (applied, invoked) = tokio::time::timeout(Duration::from_secs(12), async { + tokio::join!( + async { + barrier.wait().await; + proposal_apply_with_key(&fixture.app, &token, &submitted, "apply-shared-file").await + }, + async { + barrier.wait().await; + membership_file_action(&fixture, &token, &body, "invoke-shared-file").await + }, + ) + }) + .await + .expect("both authorized requests settle"); + let applied = applied.success(StatusCode::OK); + let invoked = invoked.success(StatusCode::OK); + assert_eq!(applied.body["state"], "applied"); + let committed = (before.0 + 2, before.1 + 2, before.2 + 2, before.3 + 1); + assert_eq!(file_commit_state(&fixture).await, committed); + let ids = assert_file_commit_members(&fixture, before.0, 2).await; + assert_ne!(ids[0], ids[1]); + let immediate_id = invoked.body["results"]["register"]["recordId"] + .as_str() + .unwrap(); + assert!(ids.iter().any(|id| id == immediate_id)); + for id in ids { + let result = request( + &fixture.app, + &token, + Method::GET, + &record(&id), + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + let label = if id == immediate_id { + "immediate-file" + } else { + "proposed-file" + }; + assert_eq!(result.body["data"]["domainData"]["label"], label); + } + let blobs: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_attachment_blobs", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(blobs, 1); + assert_eq!( + s3.puts.load(Ordering::SeqCst), + puts_before + 1, + "only the Action uploads bytes" + ); + + let apply_replay = + proposal_apply_with_key(&fixture.app, &token, &submitted, "apply-shared-file") + .await + .success(StatusCode::OK); + let action_replay = membership_file_action(&fixture, &token, &body, "invoke-shared-file") + .await + .success(StatusCode::OK); + assert_eq!(apply_replay.bytes, applied.bytes); + assert_eq!(action_replay.bytes, invoked.bytes); + assert_eq!(file_commit_state(&fixture).await, committed); + assert_eq!(s3.puts.load(Ordering::SeqCst), puts_before + 1); + fixture.database.cleanup().await; +} + +async fn proposal_fixture() -> Fixture { + Fixture::configured_with_isolation( + Duration::from_secs(10), + membership_write_project::proposal_project(), + Vec::new(), + "read committed", + |service| service, + ) + .await +} + +async fn proposal_submit(fixture: &Fixture, name: &str, input: Value) -> Reply { + let token = fixture.member(); + let draft = action( + &fixture.app, + &token, + &format!("{name}/proposals"), + MEMBER, + input, + ) + .await + .success(StatusCode::CREATED); + proposal_transition(&fixture.app, &token, MEMBER, &draft, "submit", json!({})) + .await + .success(StatusCode::OK) +} + +async fn proposal_transition( + app: &axum::Router, + token: &str, + profile: &str, + current: &Reply, + transition: &str, + body: Value, +) -> Reply { + let id = current.body["id"].as_str().unwrap(); + request( + app, + token, + Method::POST, + &format!("/v1/proposals/{id}/{transition}"), + profile, + body, + Some(current.etag()), + ) + .await +} + +async fn proposal_apply(app: &axum::Router, token: &str, submitted: &Reply) -> Reply { + proposal_apply_with_key(app, token, submitted, &Uuid::new_v4().to_string()).await +} + +async fn proposal_apply_with_key( + app: &axum::Router, + token: &str, + submitted: &Reply, + key: &str, +) -> Reply { + request_with_key( + app, + token, + Method::POST, + &format!( + "/v1/proposals/{}/apply", + submitted.body["id"].as_str().unwrap() + ), + MEMBER, + json!({ + "submissionVersion":submitted.body["submissionVersion"], + "effectDigest":submitted.body["effectDigest"] + }), + Some(submitted.etag()), + key, + ) + .await +} + +#[tokio::test] +async fn a_member_proposes_and_applies_in_their_key() { + let fixture = proposal_fixture().await; + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.allowed,"label":"proposed"}), + ) + .await; + let applied = proposal_apply(&fixture.app, &fixture.member(), &submitted) + .await + .success(StatusCode::OK); + assert_eq!(applied.body["state"], "applied"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_removal_between_submit_and_apply_answers_precondition_failed() { + let fixture = proposal_fixture().await; + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.allowed,"label":"proposed"}), + ) + .await; + let steward = fixture.steward(); + let path = format!("/v1/records/memberships/{}", fixture.keys.membership); + let current = request( + &fixture.app, + &steward, + Method::GET, + &path, + MEMBERSHIP_WRITER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + request( + &fixture.app, + &steward, + Method::PATCH, + &path, + MEMBERSHIP_WRITER, + patch("active", false), + Some(current.etag()), + ) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + let member = fixture.member(); + let production = proposal_apply(&fixture.app, &member, &submitted).await; + production.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + let development = proposal_apply(&fixture.development, &member, &submitted).await; + development.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!( + production.normalized_bytes(), + development.normalized_bytes() + ); + assert_eq!(fixture.durable_state().await, before); + let id = submitted.body["id"].as_str().unwrap(); + for (app, check) in [ + (&fixture.app, Value::Null), + (&fixture.development, json!("membership")), + ] { + for path in [ + format!("/v1/proposals/{id}"), + format!("/v1/proposals/{id}/submissions/1"), + ] { + let read = request(app, &member, Method::GET, &path, MEMBER, Value::Null, None).await; + read.problem(StatusCode::NOT_FOUND, "resource.not-found"); + assert_eq!(read.body["failedCheck"], check); + } + let listed = request( + app, + &member, + Method::GET, + "/v1/proposals", + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(listed.body["items"], json!([])); + } + let recorded = fixture.database.admin.query_one( + "SELECT workflow_revision, blocked_reason FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&Uuid::parse_str(id).unwrap()], + ).await.unwrap(); + assert_eq!( + recorded.get::<_, i64>(0), + submitted.body["revision"].as_i64().unwrap() + ); + assert_eq!(recorded.get::<_, Option>(1), None); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_membership_refusals_match_the_claim_boundary_answer() { + let fixture = proposal_fixture().await; + let visible = fixture + .seed(Some(&fixture.keys.allowed), "proposal-visible") + .await; + let hidden = fixture + .seed(Some(&fixture.keys.foreign), "proposal-hidden") + .await; + for app in [&fixture.app, &fixture.development] { + let mut observed = Vec::new(); + for (profile, token) in [(MEMBER, fixture.member()), (CLAIMED, fixture.claimed())] { + let moved = |facility: &Reply| { + json!({ + "facility":facility.record_id(),"organization":fixture.keys.second, + }) + }; + let denied_start = action( + app, + &token, + "propose-move/proposals", + profile, + moved(&hidden), + ) + .await; + let draft = action( + app, + &token, + "propose-move/proposals", + profile, + moved(&visible), + ) + .await + .success(StatusCode::CREATED); + let denied_edit = proposal_transition( + app, + &token, + profile, + &draft, + "edit", + json!({"input":moved(&hidden)}), + ) + .await; + let pending = action( + app, + &token, + "propose-facility/proposals", + profile, + json!({"organization":fixture.keys.foreign,"label":"proposed-denied"}), + ) + .await + .success(StatusCode::CREATED); + let before_create = fixture.durable_state().await; + let denied_submit = + proposal_transition(app, &token, profile, &pending, "submit", json!({})).await; + assert_eq!(fixture.durable_state().await, before_create); + let pending_move = action( + app, + &token, + "propose-move/proposals", + profile, + json!({"facility":visible.record_id(),"organization":fixture.keys.foreign}), + ) + .await + .success(StatusCode::CREATED); + let before_move = fixture.durable_state().await; + let denied_move = + proposal_transition(app, &token, profile, &pending_move, "submit", json!({})).await; + assert_eq!(fixture.durable_state().await, before_move); + let refusals = [denied_start, denied_edit, denied_submit, denied_move]; + for refusal in &refusals { + refusal.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + } + observed.push(refusals); + } + for (membership, claim) in observed[0].iter().zip(&observed[1]) { + membership.assert_same_problem(claim); + } + } + fixture.database.cleanup().await; +} + +async fn steward_removal(fixture: &Fixture, membership_id: &str) -> tokio::task::JoinHandle { + let path = format!("/v1/records/memberships/{membership_id}"); + let app = fixture.app.clone(); + let steward = fixture.steward(); + let current = request( + &app, + &steward, + Method::GET, + &path, + MEMBERSHIP_WRITER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + tokio::spawn(async move { + request( + &app, + &steward, + Method::PATCH, + &path, + MEMBERSHIP_WRITER, + patch("active", false), + Some(current.etag()), + ) + .await + }) +} + +#[tokio::test] +async fn action_write_first_makes_the_removal_wait() { + assert_action_or_proposal_write_first(false).await; +} + +#[tokio::test] +async fn proposal_write_first_makes_the_removal_wait() { + assert_action_or_proposal_write_first(true).await; +} + +async fn assert_action_or_proposal_write_first(proposal: bool) { + let fixture = proposal_fixture().await; + let row = fixture.seed(Some(&fixture.keys.allowed), "open").await; + let record_id = row.record_id(); + let submitted = if proposal { + Some( + proposal_submit( + &fixture, + "propose-move", + json!({"facility":record_id,"organization":fixture.keys.second}), + ) + .await, + ) + } else { + None + }; + let (mut admin, connection) = fixture.database.connect_admin().await; + let blocker = admin.transaction().await.unwrap(); + let blocker_pid = hold_row(&blocker, &table(&fixture, "facility"), &record_id).await; + let app = fixture.app.clone(); + let token = fixture.member(); + let writer = tokio::spawn(async move { + match submitted { + Some(submitted) => proposal_apply(&app, &token, &submitted).await, + None => { + action( + &app, + &token, + "close-facility", + MEMBER, + json!({"facility":record_id}), + ) + .await + } + } + }); + let writer_pid = wait_for_blocker(&fixture.database, blocker_pid).await; + let removal = steward_removal(&fixture, &fixture.keys.membership).await; + wait_for_blocker(&fixture.database, writer_pid).await; + blocker.commit().await.unwrap(); + writer.await.unwrap().success(StatusCode::OK); + removal.await.unwrap().success(StatusCode::OK); + connection.abort(); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn action_removal_first_refuses_the_write() { + let fixture = Fixture::create(Duration::from_secs(10)).await; + let row = fixture.seed(Some(&fixture.keys.allowed), "open").await; + let app = fixture.app.clone(); + let member = fixture.member(); + after_steward_removal(&fixture, async move { + action( + &app, + &member, + "close-facility", + MEMBER, + json!({"facility":row.record_id()}), + ) + .await + }) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_removal_first_refuses_the_write() { + let fixture = Fixture::configured( + Duration::from_secs(10), + membership_write_project::proposal_project(), + Vec::new(), + |service| service, + ) + .await; + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.allowed,"label":"pending-removal"}), + ) + .await; + let app = fixture.app.clone(); + let member = fixture.member(); + after_steward_removal(&fixture, async move { + proposal_apply(&app, &member, &submitted).await + }) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + fixture.database.cleanup().await; +} + +async fn after_steward_removal( + fixture: &Fixture, + write: impl std::future::Future + Send + 'static, +) -> Reply { + let (mut admin, connection) = fixture.database.connect_admin().await; + let blocker = admin.transaction().await.unwrap(); + // The steward locks and updates the membership row before appending its + // commit. Hold the journal head to keep that update open while the caller + // reaches the membership lock. + let blocker_pid: i32 = blocker.query_one( + "SELECT pg_backend_pid() FROM registry_internal.registry_commit_head WHERE singleton FOR UPDATE", + &[], + ).await.unwrap().get(0); + let removal = steward_removal(fixture, &fixture.keys.membership).await; + let remover_pid = wait_for_blocker(&fixture.database, blocker_pid).await; + let writer = tokio::spawn(write); + wait_for_blocker(&fixture.database, remover_pid).await; + blocker.commit().await.unwrap(); + removal.await.unwrap().success(StatusCode::OK); + let reply = writer.await.unwrap(); + connection.abort(); + reply +} + +#[tokio::test] +async fn proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted() { + let fixture = proposal_fixture().await; + let row = fixture + .seed(Some(&fixture.keys.allowed), "move-proposal") + .await; + let submitted = proposal_submit( + &fixture, + "propose-move", + json!({"facility":row.record_id(),"organization":fixture.keys.second}), + ) + .await; + steward_removal(&fixture, &fixture.keys.second_membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + let before = fixture.durable_state().await; + let member = fixture.member(); + let claim = mint( + &fixture.idp, + MEMBER, + "records:claim", + &[&fixture.keys.allowed], + ); + let path = format!("/v1/proposals/{}", submitted.body["id"].as_str().unwrap()); + for (app, development) in [(&fixture.app, false), (&fixture.development, true)] { + let claimed_view = request(app, &claim, Method::GET, &path, CLAIMED, Value::Null, None) + .await + .success(StatusCode::OK); + let membership = proposal_apply(app, &member, &submitted).await; + let twin = proposal_transition( + app, + &claim, + CLAIMED, + &claimed_view, + "apply", + json!({ + "submissionVersion":submitted.body["submissionVersion"], + "effectDigest":submitted.body["effectDigest"], + }), + ) + .await; + membership.problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + twin.problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + if development { + assert_eq!(membership.body["failedCheck"], "membership"); + assert_eq!(twin.body["failedCheck"], "row-boundary"); + membership.assert_same_problem_except_check(&twin); + } else { + membership.assert_same_problem(&twin); + } + } + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_cannot_invalidate_its_own_membership_proof() { + let mut project = membership_write_project::project(); + let actions = [ + "register-and-retire-membership", + "retire-membership-and-register", + ]; + for id in actions { + let action = &mut project["actions"][id]; + action["execution"] = json!({"mode":"proposal","proposal":{ + "review":{"type":"none"},"application":{"mode":"manual"},"retention":{"mode":"operator-erase"} + }}); + } + let permissions = &mut project["accessProfiles"]["maintainer"]["permissions"]; + let mut proposals = Vec::new(); + for action in permissions["actions"].as_array_mut().unwrap() { + let id = action["action"].as_str().unwrap(); + if !actions.contains(&id) { + continue; + } + proposals.push(json!({"action":id,"operations":["get","submit","apply"], + "party":"owner","targets":action["targets"]})); + action["operations"] = json!(["start"]); + action.as_object_mut().unwrap().remove("results"); + } + permissions["proposals"] = json!(proposals); + let fixture = Fixture::configured(Duration::from_secs(10), project, Vec::new(), |service| { + service + }) + .await; + let maintainer = mint(&fixture.idp, MEMBER, "records:retire", &[]); + for id in actions { + let draft = action( + &fixture.app, &maintainer, &format!("{id}/proposals"), "maintainer", + json!({"organization":fixture.keys.allowed,"membership":fixture.keys.membership,"label":"proposal-rollback"}), + ).await.success(StatusCode::CREATED); + let submitted = proposal_transition( + &fixture.app, + &maintainer, + "maintainer", + &draft, + "submit", + json!({}), + ) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + let markers = fixture.proposal_markers(&submitted).await; + proposal_transition(&fixture.app, &maintainer, "maintainer", &submitted, "apply", json!({ + "submissionVersion":submitted.body["submissionVersion"],"effectDigest":submitted.body["effectDigest"] + })).await.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + assert_eq!(fixture.proposal_markers(&submitted).await, markers); + } + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn automatic_worker_keeps_system_authority_and_human_apply_has_a_source_lock() { + let mut project = membership_write_project::proposal_project(); + project["actions"]["propose-facility"]["execution"]["proposal"]["application"] = + json!({"mode":"automatic","maximumAttempts":3}); + let targets = + project["accessProfiles"]["member"]["permissions"]["proposals"][0]["targets"].clone(); + project["accessProfiles"]["human-recovery"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":["proposal:recover"], + "permissions":{"proposals":[{"action":"propose-facility","operations":["apply"], + "party":"owner","targets":targets}]} + }); + let fixture = Fixture::configured(Duration::from_secs(10), project, Vec::new(), |service| { + service + }) + .await; + let source = &fixture.registry.entities()["membership"].physical_table; + assert!(fixture + .database + .admin + .query_one( + "SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_policies + WHERE schemaname='registry_data' AND tablename=$1 AND cmd='UPDATE' + AND qual LIKE '%membership_lock_%' AND qual LIKE '%human-recovery%')", + &[source], + ) + .await + .unwrap() + .get::<_, bool>(0)); + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.allowed,"label":"system-application"}), + ) + .await; + steward_removal(&fixture, &fixture.keys.membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + assert!(fixture + .mutations + .run_automatic_proposal_once_for_test() + .await + .unwrap()); + let id = Uuid::parse_str(submitted.body["id"].as_str().unwrap()).unwrap(); + let state: String = fixture + .database + .admin + .query_one( + "SELECT state FROM registry_internal.registry_proposal_state WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap() + .get(0); + assert_eq!(state, "applied"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_apply_rechecks_the_locked_key_of_an_unconditioned_link() { + let mut project = membership_write_project::proposal_project(); + let immediate = project["actions"]["register-facility"].clone(); + let proposal = &mut project["actions"]["propose-facility"]; + proposal["inputs"] = immediate["inputs"].clone(); + proposal["plan"] = immediate["plan"].clone(); + for profile in ["member", "claimed"] { + project["accessProfiles"][profile]["permissions"]["proposals"][0]["readableInputs"] + .as_array_mut() + .unwrap() + .push(json!("related")); + } + let fixture = Fixture::configured(Duration::from_secs(10), project, Vec::new(), |service| { + service + }) + .await; + let row = fixture + .seed(Some(&fixture.keys.allowed), "link-target") + .await; + let linked = Uuid::parse_str(&row.record_id()).unwrap(); + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({ + "organization":fixture.keys.allowed,"related":linked,"label":"link-application" + }), + ) + .await; + let markers = fixture.proposal_markers(&submitted).await; + let (mut target_owner, connection) = fixture.database.connect_admin().await; + let moving = target_owner.transaction().await.unwrap(); + let organization = + &fixture.registry.entities()["facility"].fields["organization"].physical_name; + let blocker: i32 = moving + .query_one( + &format!( + "UPDATE {} SET \"{organization}\"=$1,record_revision=record_revision+1 + WHERE record_id=$2 RETURNING pg_backend_pid()", + table(&fixture, "facility") + ), + &[&Uuid::parse_str(&fixture.keys.second).unwrap(), &linked], + ) + .await + .unwrap() + .get(0); + let app = fixture.app.clone(); + let member = fixture.member(); + let apply = tokio::spawn(async move { + let reply = proposal_apply(&app, &member, &submitted).await; + (submitted, reply) + }); + wait_for_blocker(&fixture.database, blocker).await; + moving.commit().await.unwrap(); + let (submitted, reply) = apply.await.unwrap(); + reply.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.proposal_markers(&submitted).await, markers); + // A fresh Apply can admit the unconditioned Link under its current key. + proposal_apply(&fixture.app, &fixture.member(), &submitted) + .await + .success(StatusCode::OK); + connection.abort(); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_candidate_admission_precedes_all_effect_groups() { + let mut project = membership_write_project::proposal_project(); + project["actions"]["propose-move"]["inputs"] + .as_array_mut() + .unwrap() + .push(json!({ + "id":"initial","type":"reference","target":"organization","required":true, + "classification":"internal" + })); + for profile in [MEMBER, CLAIMED] { + project["accessProfiles"][profile]["permissions"]["proposals"][1]["readableInputs"] + .as_array_mut() + .unwrap() + .push(json!("initial")); + } + project["actions"]["propose-move"]["plan"]["effects"] + .as_array_mut() + .unwrap() + .insert( + 0, + json!({ + "id":"first","target":{"recordType":"facility"},"operation":"create", + "set":{"organization":{"fromInput":"initial"},"label":{"value":"reserved-label"}} + }), + ); + let fixture = Fixture::configured(Duration::from_secs(10), project, Vec::new(), |service| { + service + }) + .await; + let row = fixture + .seed(Some(&fixture.keys.allowed), "movable-base") + .await; + let submitted = proposal_submit(&fixture, "propose-move", json!({ + "facility":row.record_id(),"organization":fixture.keys.second,"initial":fixture.keys.allowed + })).await; + fixture + .seed(Some(&fixture.keys.allowed), "reserved-label") + .await; + steward_removal(&fixture, &fixture.keys.second_membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + let markers = fixture.proposal_markers(&submitted).await; + let before = fixture.durable_state().await; + proposal_apply(&fixture.app, &fixture.member(), &submitted) + .await + .problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + assert_eq!(fixture.proposal_markers(&submitted).await, markers); + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_guard_reason_requires_current_target_disclosure() { + let mut project = membership_write_project::proposal_project(); + project["actions"]["propose-move"]["commitGuards"]["targets"] + .as_array_mut() + .unwrap() + .push(json!({ + "input":"facility","field":"label","equals":"open","reason":"facility-not-open" + })); + let fixture = Fixture::configured(Duration::from_secs(10), project, Vec::new(), |service| { + service + }) + .await; + let row = fixture.seed(Some(&fixture.keys.allowed), "closed").await; + let member = fixture.member(); + let draft = action( + &fixture.app, + &member, + "propose-move/proposals", + MEMBER, + json!({ + "facility":row.record_id(),"organization":fixture.keys.second + }), + ) + .await + .success(StatusCode::CREATED); + let admitted = + proposal_transition(&fixture.app, &member, MEMBER, &draft, "submit", json!({})).await; + assert_eq!(admitted.body["guardReason"], "facility-not-open"); + steward_removal(&fixture, &fixture.keys.membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + proposal_transition( + &fixture.development, + &member, + MEMBER, + &draft, + "submit", + json!({}), + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn proposal_target_revision_change_keeps_the_rebase_recovery() { + let fixture = proposal_fixture().await; + let row = fixture + .seed(Some(&fixture.keys.allowed), "revision-base") + .await; + let submitted = proposal_submit( + &fixture, + "propose-move", + json!({ + "facility":row.record_id(),"organization":fixture.keys.second + }), + ) + .await; + request( + &fixture.app, + &fixture.steward(), + Method::PATCH, + &record(&row.record_id()), + MEMBERSHIP_WRITER, + patch("label", "revised-base"), + Some(row.etag()), + ) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + proposal_apply(&fixture.app, &fixture.member(), &submitted) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + assert_eq!(fixture.durable_state().await, before); + assert_eq!( + fixture.proposal_markers(&submitted).await.1.as_deref(), + Some("application-rebase") + ); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn membership_diagnostics_count_only_observed_denials() { + use registry_breg::metrics::{metrics_app, Metrics}; + use registry_platform_testing::CapturedDiagnosticLogs; + use std::collections::BTreeMap; + use tracing::instrument::WithSubscriber; + + // The request counters and log budgets are process-wide. Observe exact + // deltas in one test process with no other requests using the recorder. + const CHILD: &str = "BREG_TEST_MEMBERSHIP_DIAGNOSTICS_CHILD"; + if std::env::var_os(CHILD).is_none() { + let outcome = std::process::Command::new(std::env::current_exe().unwrap()) + .args([ + "--exact", + "membership_write_journeys::membership_diagnostics_count_only_observed_denials", + ]) + .env(CHILD, "1") + .output() + .unwrap(); + let stdout = String::from_utf8_lossy(&outcome.stdout); + assert!( + outcome.status.success() && stdout.contains("1 passed; 0 failed"), + "{stdout}" + ); + return; + } + + async fn counts() -> BTreeMap { + let response = metrics_app( + Arc::new(Metrics::without_pool_for_test()), + Posture::Production, + ) + .oneshot( + Request::builder() + .uri("/metrics") + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + let bytes = to_bytes(response.into_body(), 4 * 1024 * 1024) + .await + .unwrap(); + std::str::from_utf8(&bytes) + .unwrap() + .lines() + .filter_map(|line| { + let sample = line.strip_prefix("breg_request_refusals_total{check=\"")?; + let (label, value) = sample.split_once("\"} ").unwrap(); + Some((label.to_owned(), value.parse().unwrap())) + }) + .collect() + } + + let fixture = proposal_fixture().await; + let outside = fixture + .seed(Some(&fixture.keys.foreign), "outside-member-signal") + .await + .record_id(); + let submitted = proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.second,"label":"member-signal-value"}), + ) + .await; + proposal_submit( + &fixture, + "propose-facility", + json!({"organization":fixture.keys.second,"label":"second-member-signal"}), + ) + .await; + steward_removal(&fixture, &fixture.keys.second_membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + let member = fixture.member(); + let target = format!("{RECORDS}/{outside}"); + let proposal_id = submitted.body["id"].as_str().unwrap(); + let proposal = format!("/v1/proposals/{proposal_id}"); + let apply = format!("{proposal}/apply"); + for (method, path, profile, body, status, code, check) in [ + ( + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.foreign,"label":"member-signal-value"}}), + StatusCode::FORBIDDEN, + "write.outside-boundary", + Some("membership"), + ), + ( + Method::POST, + "/v1/actions/close-facility/availability", + "observer", + json!({"targetInput":"facility","input":{"facility":outside}}), + StatusCode::NOT_FOUND, + "resource.not-found", + Some("membership"), + ), + ( + Method::POST, + "/v1/actions/register-facility", + MEMBER, + json!({"input":{"organization":fixture.keys.foreign,"label":"member-signal-value"}}), + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + Some("membership"), + ), + ( + Method::GET, + target.as_str(), + MEMBER, + Value::Null, + StatusCode::NOT_FOUND, + "resource.not-found", + Some("visibility"), + ), + ( + Method::POST, + "/v1/actions/close-facility", + MEMBER, + json!({"input":{"facility":outside}}), + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + None, + ), + ( + Method::GET, + proposal.as_str(), + MEMBER, + Value::Null, + StatusCode::NOT_FOUND, + "resource.not-found", + Some("membership"), + ), + ( + Method::GET, + "/v1/proposals", + MEMBER, + Value::Null, + StatusCode::OK, + "", + None, + ), + ( + Method::POST, + apply.as_str(), + MEMBER, + json!({ + "submissionVersion":submitted.body["submissionVersion"], + "effectDigest":submitted.body["effectDigest"], + }), + StatusCode::PRECONDITION_FAILED, + "precondition.failed", + Some("membership"), + ), + ] { + let before = counts().await; + let capture = CapturedDiagnosticLogs::default(); + let etag = (path == apply).then_some(submitted.etag()); + let reply = request(&fixture.app, &member, method, path, profile, body, etag) + .with_subscriber(capture.subscriber()) + .await; + let trace = reply.body["traceId"].as_str().map(str::to_owned); + if status == StatusCode::OK { + assert_eq!(reply.success(status).body, json!({"items":[]})); + } else { + reply.problem(status, code); + } + let changed: BTreeMap<_, _> = counts() + .await + .into_iter() + .filter_map(|(label, value)| { + let delta = value - before[&label]; + (delta > 0).then_some((label, delta)) + }) + .collect(); + let expected = check + .into_iter() + .map(|label| (label.to_owned(), 1)) + .collect(); + assert_eq!(changed, expected, "{path}"); + let logs = capture.text(); + for value in [ + outside.as_str(), + fixture.keys.foreign.as_str(), + fixture.keys.second.as_str(), + proposal_id, + "member-signal-value", + "second-member-signal", + ] { + assert!( + !logs.contains(value), + "{path}: a compared value reached the logs" + ); + } + let checks: Vec<_> = logs + .lines() + .map(|line| serde_json::from_str::(line).unwrap()) + .filter(|event| event["fields"]["message"] == "request refused") + .map(|event| { + assert!(event["fields"]["trace_id"].as_str() == trace.as_deref()); + event["fields"]["failed_check"].as_str().unwrap().to_owned() + }) + .collect(); + assert_eq!( + checks, + check.into_iter().map(str::to_owned).collect::>(), + "{path}" + ); + } + fixture.database.cleanup().await; +} + +// ---- Organisation steward ---- +// +// A steward manages who belongs to the organisations a live stewardship record +// names for them, through two bounded Actions, and nothing else. + +const ORGANISATION_STEWARD: &str = "organisation-steward"; +const STEWARD_OF_ALLOWED: &str = "steward-of-allowed"; + +async fn steward_fixture() -> Fixture { + Fixture::configured( + Duration::from_secs(2), + membership_write_project::steward_project(), + Vec::new(), + |service| service, + ) + .await +} + +impl Fixture { + fn organisation_steward(&self, principal: &str) -> String { + mint(&self.idp, principal, "stewardship:manage", &[]) + } + + /// The registrar names `principal` a steward of `organization`. + async fn stewardship(&self, organization: &str, principal: &str) -> Reply { + request( + &self.app, + &self.steward(), + Method::POST, + "/v1/records/stewardships", + MEMBERSHIP_WRITER, + json!({"data":{"organization":organization,"principal":principal,"active":true}}), + None, + ) + .await + .success(StatusCode::CREATED) + } +} + +async fn appoint(fixture: &Fixture, token: &str, organization: &str, principal: &str) -> Reply { + action( + &fixture.app, + token, + "appoint-member", + ORGANISATION_STEWARD, + json!({"organization":organization,"principal":principal}), + ) + .await +} + +async fn remove(fixture: &Fixture, token: &str, membership: &str) -> Reply { + action( + &fixture.app, + token, + "remove-member", + ORGANISATION_STEWARD, + json!({"membership":membership}), + ) + .await +} + +/// A refusal for a record the caller does not reach must look like the +/// answer for a record that does not exist. +fn assert_concealed(outside: &Reply, missing: &Reply) { + assert!(outside.status.is_client_error(), "{}", outside.body); + assert_eq!( + (outside.status, &outside.body["code"]), + (missing.status, &missing.body["code"]), + "outside: {}\nmissing: {}", + outside.body, + missing.body + ); +} + +async fn facilities_seen_by(fixture: &Fixture, principal: &str) -> String { + request( + &fixture.app, + &mint(&fixture.idp, principal, "", &[]), + Method::GET, + RECORDS, + MEMBER, + Value::Null, + None, + ) + .await + .success(StatusCode::OK) + .body + .to_string() +} + +#[tokio::test] +async fn a_steward_appoints_and_removes_members_only_in_their_organisation() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + fixture + .seed(Some(&fixture.keys.allowed), "steward-facility") + .await; + + let appointed = appoint( + &fixture, + &steward, + &fixture.keys.allowed, + "appointed-member", + ) + .await + .success(StatusCode::OK); + let membership = appointed.body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + assert!(facilities_seen_by(&fixture, "appointed-member") + .await + .contains("steward-facility")); + + remove(&fixture, &steward, &membership) + .await + .success(StatusCode::OK); + assert!(!facilities_seen_by(&fixture, "appointed-member") + .await + .contains("steward-facility")); + + let missing = Uuid::new_v4().to_string(); + assert_concealed( + &appoint(&fixture, &steward, &fixture.keys.foreign, "outsider").await, + &appoint(&fixture, &steward, &missing, "outsider").await, + ); + assert_concealed( + &remove(&fixture, &steward, &fixture.keys.second_membership).await, + &remove(&fixture, &steward, &missing).await, + ); +} + +#[tokio::test] +async fn a_deactivated_steward_is_refused_on_the_next_request() { + let fixture = steward_fixture().await; + let stewardship = fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + appoint(&fixture, &steward, &fixture.keys.allowed, "first-member") + .await + .success(StatusCode::OK); + + request( + &fixture.app, + &fixture.steward(), + Method::PATCH, + &format!("/v1/records/stewardships/{}", stewardship.record_id()), + MEMBERSHIP_WRITER, + patch("active", false), + Some(stewardship.etag()), + ) + .await + .success(StatusCode::OK); + + assert_concealed( + &appoint(&fixture, &steward, &fixture.keys.allowed, "late-member").await, + &appoint( + &fixture, + &steward, + &Uuid::new_v4().to_string(), + "late-member", + ) + .await, + ); +} + +#[tokio::test] +async fn a_steward_writes_members_only_through_the_two_actions() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + for (path, data) in [ + ( + "/v1/records/memberships", + json!({"organization":fixture.keys.allowed,"principal":"direct","active":true}), + ), + ( + "/v1/records/stewardships", + json!({"organization":fixture.keys.allowed,"principal":"self-promoted","active":true}), + ), + ] { + request( + &fixture.app, + &steward, + Method::POST, + path, + ORGANISATION_STEWARD, + json!({"data":data}), + None, + ) + .await + .problem(StatusCode::FORBIDDEN, "profile.not-authorized"); + } +} + +#[tokio::test] +async fn a_member_read_still_works_beside_the_steward_policy_on_membership() { + // The nested probe: the member's facility read evaluates the membership + // source, which now carries the steward's own membership policy. + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + fixture + .seed(Some(&fixture.keys.allowed), "member-visible") + .await; + fixture + .seed(Some(&fixture.keys.foreign), "member-hidden") + .await; + let seen = facilities_seen_by(&fixture, MEMBER).await; + assert!(seen.contains("member-visible"), "{seen}"); + assert!(!seen.contains("member-hidden"), "{seen}"); + + let members = request( + &fixture.app, + &fixture.organisation_steward(STEWARD_OF_ALLOWED), + Method::GET, + "/v1/records/memberships", + ORGANISATION_STEWARD, + Value::Null, + None, + ) + .await + .success(StatusCode::OK) + .body + .to_string(); + assert!(members.contains(&fixture.keys.allowed), "{members}"); + assert!(!members.contains(&fixture.keys.second), "{members}"); + // The member's own facility read is unchanged after the steward's read. + assert_eq!(facilities_seen_by(&fixture, MEMBER).await, seen); +} + +#[tokio::test] +async fn a_steward_of_two_organisations_reaches_both_and_no_third() { + let fixture = steward_fixture().await; + for organization in [&fixture.keys.allowed, &fixture.keys.second] { + fixture.stewardship(organization, STEWARD_OF_ALLOWED).await; + } + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + for organization in [&fixture.keys.allowed, &fixture.keys.second] { + appoint(&fixture, &steward, organization, "shared-member") + .await + .success(StatusCode::OK); + } + assert_concealed( + &appoint(&fixture, &steward, &fixture.keys.foreign, "shared-member").await, + &appoint( + &fixture, + &steward, + &Uuid::new_v4().to_string(), + "shared-member", + ) + .await, + ); +} + +#[tokio::test] +async fn a_steward_reads_their_organisation_by_its_identifier_and_no_other() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let read = |id: String| { + let steward = steward.clone(); + let app = fixture.app.clone(); + async move { + request( + &app, + &steward, + Method::GET, + &format!("/v1/records/organizations/{id}"), + ORGANISATION_STEWARD, + Value::Null, + None, + ) + .await + } + }; + read(fixture.keys.allowed.clone()) + .await + .success(StatusCode::OK); + let outside = read(fixture.keys.foreign.clone()).await; + assert_eq!(outside.status, StatusCode::NOT_FOUND, "{}", outside.body); + assert_concealed(&outside, &read(Uuid::new_v4().to_string()).await); +} + +/// A principal's answers on every path a membership probe guards: a facility +/// read and list, a direct create and patch, and an Action on a facility +/// target. A list answers with the number of rows it returned. +async fn member_answers( + fixture: &Fixture, + principal: &str, + open: &str, + etag: &str, +) -> Vec<(StatusCode, Value)> { + let token = mint(&fixture.idp, principal, "", &[]); + let read = request( + &fixture.app, + &token, + Method::GET, + &record(open), + MEMBER, + Value::Null, + None, + ) + .await; + let create = request( + &fixture.app, + &token, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":format!("{principal}-create")}}), + None, + ) + .await; + let list = request( + &fixture.app, + &token, + Method::GET, + RECORDS, + MEMBER, + Value::Null, + None, + ) + .await; + let listed = ( + list.status, + json!(list.body["items"].as_array().map(Vec::len)), + ); + let patched = request( + &fixture.app, + &token, + Method::PATCH, + &record(open), + MEMBER, + patch("label", "open"), + Some(etag), + ) + .await; + let close = action( + &fixture.app, + &token, + "close-facility", + MEMBER, + json!({"facility":open}), + ) + .await; + let mut answers = [read, create, patched, close] + .into_iter() + .map(|reply| (reply.status, reply.body["code"].clone())) + .collect::>(); + answers.push(listed); + answers +} + +#[tokio::test] +async fn a_removed_member_gets_a_strangers_answer_on_every_membership_path() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let seeded = fixture.seed(Some(&fixture.keys.allowed), "open").await; + let open = seeded.record_id(); + let etag = seeded.etag().to_owned(); + let membership = appoint(&fixture, &steward, &fixture.keys.allowed, "removed-member") + .await + .success(StatusCode::OK) + .body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + let member = member_answers(&fixture, "removed-member", &open, &etag).await; + assert_eq!(member[0].0, StatusCode::OK, "{member:?}"); + assert_eq!(member[1].0, StatusCode::CREATED, "{member:?}"); + assert_eq!(member[4], (StatusCode::OK, json!(2)), "{member:?}"); + + remove(&fixture, &steward, &membership) + .await + .success(StatusCode::OK); + let stranger = member_answers(&fixture, "never-a-member", &open, &etag).await; + // A stranger is refused on every write and read, and lists no rows. + assert!( + stranger[..4] + .iter() + .all(|(status, _)| status.is_client_error()), + "{stranger:?}" + ); + assert_eq!(stranger[4], (StatusCode::OK, json!(0)), "{stranger:?}"); + assert_eq!( + member_answers(&fixture, "removed-member", &open, &etag).await, + stranger + ); + // The nested probe: the steward's membership read runs the stewardship + // probe inside the same policies, and the removed member stays out. + let members = request( + &fixture.app, + &steward, + Method::GET, + "/v1/records/memberships", + ORGANISATION_STEWARD, + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert!(members.body.to_string().contains("removed-member")); + assert_eq!( + member_answers(&fixture, "removed-member", &open, &etag).await, + stranger + ); +} + +#[tokio::test] +async fn removing_an_inactive_member_is_refused_by_the_commit_guard() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let membership = appoint(&fixture, &steward, &fixture.keys.allowed, "twice-removed") + .await + .success(StatusCode::OK) + .body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + remove(&fixture, &steward, &membership) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + // The guard, not a membership refusal: only a guard names its reason. + let again = remove(&fixture, &steward, &membership).await; + again.problem(StatusCode::PRECONDITION_FAILED, "action.guard-failed"); + assert_eq!(again.body["guardReason"], "membership-inactive"); + assert_eq!(fixture.durable_state().await, before); +} + +#[tokio::test] +async fn one_live_appointment_per_person_and_reappointment_creates_a_new_row() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + fixture + .seed(Some(&fixture.keys.allowed), "reappointed-facility") + .await; + let first = appoint(&fixture, &steward, &fixture.keys.allowed, "reappointed") + .await + .success(StatusCode::OK) + .body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + let before = fixture.durable_state().await; + let duplicate = appoint(&fixture, &steward, &fixture.keys.allowed, "reappointed").await; + assert_eq!(duplicate.status, StatusCode::CONFLICT, "{}", duplicate.body); + assert_eq!(fixture.durable_state().await, before); + + remove(&fixture, &steward, &first) + .await + .success(StatusCode::OK); + assert!(!facilities_seen_by(&fixture, "reappointed") + .await + .contains("reappointed-facility")); + let second = appoint(&fixture, &steward, &fixture.keys.allowed, "reappointed") + .await + .success(StatusCode::OK) + .body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + assert_ne!(first, second); + assert!(facilities_seen_by(&fixture, "reappointed") + .await + .contains("reappointed-facility")); +} + +#[tokio::test] +async fn a_steward_cannot_reactivate_or_change_any_stewardship_or_membership_directly() { + let fixture = steward_fixture().await; + let stewardship = fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let membership = appoint(&fixture, &steward, &fixture.keys.allowed, "kept-member") + .await + .success(StatusCode::OK) + .body["results"]["membership"]["recordId"] + .as_str() + .unwrap() + .to_owned(); + // The registrar deactivates the stewardship. The steward cannot restore + // it, nor change its own or any member row, by a direct write. + let deactivated = request( + &fixture.app, + &fixture.steward(), + Method::PATCH, + &format!("/v1/records/stewardships/{}", stewardship.record_id()), + MEMBERSHIP_WRITER, + patch("active", false), + Some(stewardship.etag()), + ) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + for (path, etag) in [ + ( + format!("/v1/records/stewardships/{}", stewardship.record_id()), + deactivated.etag().to_owned(), + ), + ( + format!("/v1/records/memberships/{membership}"), + "\"any\"".to_owned(), + ), + ] { + for (method, body) in [ + (Method::PATCH, patch("active", true)), + (Method::PATCH, patch("principal", STEWARD_OF_ALLOWED)), + (Method::DELETE, Value::Null), + ] { + request( + &fixture.app, + &steward, + method, + &path, + ORGANISATION_STEWARD, + body, + Some(&etag), + ) + .await + .problem(StatusCode::FORBIDDEN, "profile.not-authorized"); + } + } + // remove-member takes only a membership: a stewardship identifier is + // concealed like a missing one. + assert_concealed( + &remove(&fixture, &steward, &stewardship.record_id()).await, + &remove(&fixture, &steward, &Uuid::new_v4().to_string()).await, + ); + assert_eq!(fixture.durable_state().await, before); +} + +#[tokio::test] +async fn every_membership_helper_restores_the_probe_marker_beside_the_steward_policy() { + // `membership` is now both a probe source and bounded by `stewardship`, + // so its probes can run inside another probe. Each generated helper, + // called directly under each profile, must answer and hand back the + // caller's marker unchanged. + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let helpers = fixture + .registry + .ddl() + .functions + .iter() + .filter(|function| function.name.starts_with("membership_")) + .map(|function| function.name.clone()) + .collect::>(); + assert!(helpers.len() >= 4, "{helpers:?}"); + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let allowed = Uuid::parse_str(&fixture.keys.allowed).unwrap(); + for (profile, principal) in [(MEMBER, MEMBER), (ORGANISATION_STEWARD, STEWARD_OF_ALLOWED)] { + let tx = client.transaction().await.unwrap(); + tx.query_one( + "SELECT set_config('registry.access_profile', $1, true), + set_config('registry.principal', $2, true), + set_config('registry.membership_probe', 'prior-marker', true)", + &[&profile, &principal], + ) + .await + .unwrap(); + let mut granted = 0; + for helper in &helpers { + let answer: bool = tx + .query_one( + &format!("SELECT registry_context.\"{helper}\"($1)"), + &[&allowed], + ) + .await + .unwrap() + .get(0); + granted += usize::from(answer); + let marker: String = tx + .query_one("SELECT current_setting('registry.membership_probe')", &[]) + .await + .unwrap() + .get(0); + assert_eq!(marker, "prior-marker", "{helper} under {profile}"); + } + // Each profile reaches the allowed organisation through its own + // source, and only through helpers guarded for that profile. + assert!(granted >= 1, "{profile} reached nothing"); + tx.rollback().await.unwrap(); + } + + // After a helper fails, the caller's marker is in place again: a lock + // helper in a read-only transaction errors, and rolling back to the + // caller's savepoint discards the failed statement's settings. This shows + // what a caller sees after the failure. It cannot tell the helper's own + // restore from PostgreSQL's rollback of the failed statement. + let lock = helpers + .iter() + .find(|helper| helper.starts_with("membership_lock_")) + .expect("the steward's Actions lock their source"); + let tx = client.transaction().await.unwrap(); + tx.batch_execute( + "SET TRANSACTION READ ONLY; + SELECT set_config('registry.membership_probe', 'prior-marker', true); + SAVEPOINT probe", + ) + .await + .unwrap(); + tx.query_one( + &format!("SELECT registry_context.\"{lock}\"($1)"), + &[&allowed], + ) + .await + .expect_err("a locking helper cannot run read-only"); + tx.batch_execute("ROLLBACK TO SAVEPOINT probe") + .await + .unwrap(); + let marker: String = tx + .query_one("SELECT current_setting('registry.membership_probe')", &[]) + .await + .unwrap() + .get(0); + assert_eq!(marker, "prior-marker"); + tx.rollback().await.unwrap(); + + // With the stewardship deactivated, no helper grants the steward + // anything, nested or not. + let stewardship = &fixture.registry.entities()["stewardship"]; + fixture + .database + .admin + .execute( + &format!( + "UPDATE registry_data.\"{}\" SET \"{}\" = false", + stewardship.physical_table, stewardship.fields["active"].physical_name + ), + &[], + ) + .await + .unwrap(); + let tx = client.transaction().await.unwrap(); + tx.query_one( + "SELECT set_config('registry.access_profile', $1, true), + set_config('registry.principal', $2, true)", + &[&ORGANISATION_STEWARD, &STEWARD_OF_ALLOWED], + ) + .await + .unwrap(); + for helper in &helpers { + let answer: bool = tx + .query_one( + &format!("SELECT registry_context.\"{helper}\"($1)"), + &[&allowed], + ) + .await + .unwrap() + .get(0); + assert!(!answer, "{helper} granted through an inactive stewardship"); + } + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_removed_member_cannot_replay_a_stored_record_write_or_batch() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let create = json!({"data":{"organization":fixture.keys.allowed,"label":"replayed-create"}}); + let batch = json!({"items":[ + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"replayed-batch"}} + ]}); + let send = |path: String, body: Value, key: &'static str| { + let app = fixture.app.clone(); + let member = member.clone(); + async move { + request_with_key(&app, &member, Method::POST, &path, MEMBER, body, None, key).await + } + }; + let created = send(RECORDS.to_owned(), create.clone(), "replay-create") + .await + .success(StatusCode::CREATED); + send(format!("{RECORDS}:batch"), batch.clone(), "replay-batch") + .await + .success(StatusCode::OK); + // While the membership holds, a replay returns the stored answer. + let replay = send(RECORDS.to_owned(), create.clone(), "replay-create") + .await + .success(StatusCode::CREATED); + assert_eq!( + replay.body["data"]["recordId"], + created.body["data"]["recordId"] + ); + + steward_removal(&fixture, &fixture.keys.membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + let before = fixture.durable_state().await; + for (path, body, key) in [ + (RECORDS.to_owned(), create, "replay-create"), + (format!("{RECORDS}:batch"), batch, "replay-batch"), + ] { + send(path, body, key) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + } + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn appoint_member_availability_answers_for_the_stewards_own_organisation() { + // The organisation target is bounded by its own identifier. Availability + // reads it like any target: available for an organisation the steward + // stewards, concealed like a missing one otherwise. + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let path = "/v1/actions/appoint-member/availability"; + let ask = |organization: String| { + let app = fixture.app.clone(); + let steward = steward.clone(); + async move { + request( + &app, + &steward, + Method::POST, + path, + ORGANISATION_STEWARD, + json!({"targetInput":"organization", + "input":{"organization":organization,"principal":"candidate"}}), + None, + ) + .await + } + }; + let own = ask(fixture.keys.allowed.clone()) + .await + .success(StatusCode::OK); + assert_eq!(own.body["availability"]["available"], true, "{}", own.body); + let outside = ask(fixture.keys.foreign.clone()).await; + assert!(outside.status.is_client_error(), "{}", outside.body); + outside.assert_same_problem(&ask(Uuid::new_v4().to_string()).await); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn two_concurrent_appointments_of_one_person_leave_one_live_row() { + let fixture = steward_fixture().await; + fixture + .stewardship(&fixture.keys.allowed, STEWARD_OF_ALLOWED) + .await; + let steward = fixture.organisation_steward(STEWARD_OF_ALLOWED); + let (first, second) = tokio::join!( + appoint(&fixture, &steward, &fixture.keys.allowed, "raced-member"), + appoint(&fixture, &steward, &fixture.keys.allowed, "raced-member"), + ); + let mut statuses = [first.status, second.status]; + statuses.sort(); + assert_eq!( + statuses, + [StatusCode::OK, StatusCode::CONFLICT], + "{} {}", + first.body, + second.body + ); + let membership = &fixture.registry.entities()["membership"]; + let live: i64 = fixture + .database + .admin + .query_one( + &format!( + "SELECT count(*) FROM registry_data.\"{}\" WHERE \"{}\" = $1 AND \"{}\" IS TRUE AND record_lifecycle = 'active'", + membership.physical_table, + membership.fields["principal"].physical_name, + membership.fields["active"].physical_name, + ), + &[&"raced-member"], + ) + .await + .unwrap() + .get(0); + assert_eq!(live, 1); + fixture.database.cleanup().await; +} + +/// A member's stored tombstone of one facility, and the replay that resends +/// it with the same key. +async fn tombstone_with_key( + fixture: &Fixture, + label: &str, + key: &'static str, +) -> (String, String, Reply) { + let member = fixture.member(); + let created = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":label}}), + None, + ) + .await + .success(StatusCode::CREATED); + let path = record(&created.record_id()); + let first = request_with_key( + &fixture.app, + &member, + Method::DELETE, + &path, + MEMBER, + Value::Null, + Some(created.etag()), + key, + ) + .await; + (path, created.etag().to_owned(), first) +} + +#[tokio::test] +async fn a_current_member_replays_a_stored_tombstone_and_batch_patch() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let (path, etag, first) = + tombstone_with_key(&fixture, "replayed-tombstone", "tombstone-key").await; + let first = first.success(StatusCode::OK); + let replay = request_with_key( + &fixture.app, + &member, + Method::DELETE, + &path, + MEMBER, + Value::Null, + Some(&etag), + "tombstone-key", + ) + .await + .success(StatusCode::OK); + assert_eq!(replay.body, first.body); + + // Batch carries creates and patches; a tombstone is not a Batch item. + let row = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":"batch-patch"}}), + None, + ) + .await + .success(StatusCode::CREATED); + let batch = json!({"items":[{"operation":"patch","recordId":row.record_id(),"ifMatch":row.etag(), + "patch":[{"op":"replace","path":"/data/label","value":"batch-patched"}]}]}); + let stored = request_with_key( + &fixture.app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + batch.clone(), + None, + "batch-tombstone-key", + ) + .await + .success(StatusCode::OK); + let replay = request_with_key( + &fixture.app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + batch, + None, + "batch-tombstone-key", + ) + .await + .success(StatusCode::OK); + assert_eq!(replay.body, stored.body); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_tombstone_replay_rechecks_the_stored_key_and_fails_closed_without_it() { + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let (path, etag, first) = + tombstone_with_key(&fixture, "removed-tombstone", "removed-key").await; + first.success(StatusCode::OK); + let (erased_path, erased_etag, erased) = + tombstone_with_key(&fixture, "erased-tombstone", "erased-key").await; + erased.success(StatusCode::OK); + // Without the stored key, the replay cannot be rechecked and is refused. + let erased_id = erased_path.rsplit('/').next().unwrap().to_owned(); + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_revisions SET snapshot = NULL, erased_at = now() WHERE record_id = $1::uuid", + &[&Uuid::parse_str(&erased_id).unwrap()], + ) + .await + .unwrap(); + request_with_key( + &fixture.app, + &member, + Method::DELETE, + &erased_path, + MEMBER, + Value::Null, + Some(&erased_etag), + "erased-key", + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + // A member removed since the tombstone gets the refusal a fresh request + // would, not the stored answer. + steward_removal(&fixture, &fixture.keys.membership) + .await + .await + .unwrap() + .success(StatusCode::OK); + request_with_key( + &fixture.app, + &member, + Method::DELETE, + &path, + MEMBER, + Value::Null, + Some(&etag), + "removed-key", + ) + .await + .problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_current_member_replays_a_stored_patch_and_a_create_only_create() { + let mut project = membership_write_project::project(); + // A profile that may only create, so it reads no rows back. + project["accessProfiles"]["creator"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":"unrestricted", + "permissions":{"records":[{ + "recordType":"facility","operations":["create"], + "rowBoundaries":[{"field":"organization","membership":"membership"}], + "readableFields":["organization","label"],"writableFields":["organization","label"] + }]} + }); + let fixture = + Fixture::configured(Duration::from_secs(2), project, vec![], |service| service).await; + let member = fixture.member(); + let row = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":"patch-replay"}}), + None, + ) + .await + .success(StatusCode::CREATED); + let path = record(&row.record_id()); + let send_patch = || { + request_with_key( + &fixture.app, + &member, + Method::PATCH, + &path, + MEMBER, + patch("label", "patched-once"), + Some(row.etag()), + "patch-replay-key", + ) + }; + let stored = send_patch().await; + assert_eq!( + stored.status, + StatusCode::OK, + "first patch: {}", + stored.body + ); + let replayed = send_patch().await; + assert_eq!( + replayed.status, + StatusCode::OK, + "patch replay: {}", + replayed.body + ); + assert_eq!(replayed.body, stored.body); + + let create = json!({"data":{"organization":fixture.keys.allowed,"label":"create-only"}}); + let send_create = || { + request_with_key( + &fixture.app, + &member, + Method::POST, + RECORDS, + "creator", + create.clone(), + None, + "create-only-key", + ) + }; + let stored = send_create().await; + assert_eq!( + stored.status, + StatusCode::CREATED, + "first create: {}", + stored.body + ); + let replayed = send_create().await; + assert_eq!( + replayed.status, + StatusCode::CREATED, + "create replay: {}", + replayed.body + ); + assert_eq!(replayed.body, stored.body); + fixture.database.cleanup().await; +} diff --git a/crates/registry-breg/tests/support/membership_write_project.rs b/crates/registry-breg/tests/support/membership_write_project.rs new file mode 100644 index 0000000000..e2311b7dd7 --- /dev/null +++ b/crates/registry-breg/tests/support/membership_write_project.rs @@ -0,0 +1,336 @@ +// SPDX-License-Identifier: Apache-2.0 + +use serde_json::{json, Value}; + +pub(super) fn project() -> Value { + let mut project = super::membership_fixture::source("facility"); + project["project"]["id"] = json!("membership-writes"); + project["package"] = json!({"sourceRevision":"membership-writes-fixture"}); + project["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("accessRequirements"); + project["recordTypes"]["membership"]["tombstone"] = json!(true); + project["recordTypes"]["organization"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"owner","type":"string","maximumLength":80,"classification":"internal"})); + let facility = &mut project["recordTypes"]["facility"]; + facility["tombstone"] = json!(true); + facility["batch"] = json!({"maximumItems":4,"maximumBytes":8192}); + facility["constraints"] = json!([{"type":"unique","fields":["label"]}]); + facility["hooks"] = json!([ + {"phase":"after","id":"facility-created","trigger":"created","projection":["label"],"handler":{"type":"url","destinationId":"record-events"}}, + {"phase":"after","id":"facility-patched","trigger":"patched","projection":["label"],"handler":{"type":"url","destinationId":"record-events"}}, + {"phase":"after","id":"facility-tombstoned","trigger":"tombstoned","projection":["label"],"handler":{"type":"url","destinationId":"record-events"}} + ]); + facility["fields"][0]["required"] = json!(false); + facility["fields"].as_array_mut().unwrap().extend([ + json!({"id":"number","type":"string","maximumLength":32,"required":true, + "classification":"internal","generate":{"type":"sequence","prefix":"FAC-","minimumDigits":4}}), + json!({"id":"related","type":"reference","target":"facility","classification":"internal"}), + ]); + let membership = json!([{"field":"organization","membership":"membership"}]); + let claim = json!([{"field":"organization","claim":"organization","operator":"in"}]); + let writable = json!(["organization", "label", "related"]); + let readable = json!(["organization", "label", "related", "number"]); + let operations = json!(["get", "list", "create", "patch", "tombstone", "batch"]); + project["accessProfiles"]["member"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":"unrestricted", + "permissions":{"records":[{ + "recordType":"facility","rowBoundaries": membership.clone(), + "operations": operations.clone(),"readableFields":readable.clone(), + "writableFields":writable.clone() + }]} + }); + project["accessProfiles"]["claimed"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":["records:claim"], + "permissions":{"records":[{ + "recordType":"facility","rowBoundaries":claim.clone(),"operations":operations, + "readableFields":readable.clone(),"writableFields":writable.clone() + }]} + }); + for (id, fields) in [ + ("observer", json!(["organization", "label"])), + ("limited", json!(["label"])), + ] { + project["accessProfiles"][id] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":"unrestricted", + "permissions":{"records":[{ + "recordType":"facility","rowBoundaries":"unrestricted", + "operations":["get"],"readableFields": fields + }]} + }); + } + let steward = &mut project["accessProfiles"]["steward"]; + steward["principalClaim"] = json!("sub"); + steward["permissions"]["records"][0]["writableFields"] = json!(["name", "owner"]); + steward["permissions"]["records"][1]["operations"] = + json!(["create", "get", "patch", "tombstone"]); + steward["permissions"]["records"][2]["readableFields"] = readable; + steward["permissions"]["records"][2]["writableFields"] = writable; + let reference = |id: &str, target: &str, required| { + json!({"id":id,"type":"reference","target":target,"required":required, + "classification":"internal"}) + }; + let label = || { + json!({"id":"label","type":"string","maximumLength":80,"required":true, + "classification":"internal"}) + }; + project["actions"] = json!({ + "register-facility": { + "execution":{"mode":"immediate"}, + "inputs":[reference("organization","organization",true),reference("related","facility",false),label()], + "plan":{"type":"fixed","effects":[{"id":"register","target":{"recordType":"facility"}, + "operation":"create","set":{"organization":{"fromInput":"organization"}, + "related":{"fromInput":"related"},"label":{"fromInput":"label"}}}]} + }, + "close-facility": { + "execution":{"mode":"immediate","concurrency":"current-revision"}, + "inputs":[reference("facility","facility",true)], + "commitGuards":{"targets":[{"input":"facility","field":"label","equals":"open", + "reason":"facility-not-open"}]}, + "plan":{"type":"fixed","effects":[{"id":"close","target":{"fromInput":"facility"}, + "operation":"patch","set":{"label":{"value":"closed"}}}]} + }, + "move-facility": { + "execution":{"mode":"immediate"}, + "inputs":[reference("facility","facility",true),reference("organization","organization",true)], + "commitGuards":{"targets":[{"input":"facility","revision":"unchanged"}]}, + "plan":{"type":"fixed","effects":[{"id":"move","target":{"fromInput":"facility"}, + "operation":"patch","set":{"organization":{"fromInput":"organization"}}}]} + } + }); + project["actions"]["register-pair"] = json!({ + "execution":{"mode":"immediate"}, + "inputs":[reference("first","organization",true),reference("second","organization",true)], + "plan":{"type":"fixed","effects":[ + {"id":"first","target":{"recordType":"facility"},"operation":"create", + "set":{"organization":{"fromInput":"first"},"label":{"value":"existing-label"}}}, + {"id":"second","target":{"recordType":"facility"},"operation":"create", + "set":{"organization":{"fromInput":"second"},"label":{"value":"pair-second"}}} + ]} + }); + project["actions"]["retire-membership-and-register"] = json!({ + "execution":{"mode":"immediate","concurrency":"current-revision"}, + "inputs":[reference("organization","organization",true), reference("membership","membership",true), label()], + "commitGuards":{"targets":[{"input":"membership","field":"active","equals":true}]}, + "plan":{"type":"fixed","effects":[ + {"id":"register","target":{"recordType":"facility"},"operation":"create", + "set":{"organization":{"fromInput":"organization"},"label":{"fromInput":"label"}}}, + {"id":"retire","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}}} + ]} + }); + let register_then_retire = project["actions"]["retire-membership-and-register"].clone(); + project["actions"]["retire-membership-and-register"]["plan"]["effects"] + .as_array_mut() + .unwrap() + .swap(0, 1); + project["actions"]["register-and-retire-membership"] = register_then_retire; + project["actions"]["register-in-created-organization"] = json!({ + "execution":{"mode":"immediate"}, + "inputs":[label()], + "plan":{"type":"fixed","effects":[ + {"id":"organization","target":{"recordType":"organization"},"operation":"create", + "set":{"name":{"fromInput":"label"}}}, + {"id":"register","target":{"recordType":"facility"},"operation":"create", + "set":{"organization":{"fromEffect":"organization"},"label":{"fromInput":"label"}}} + ]} + }); + project["accessProfiles"]["maintainer"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":["records:retire"], + "permissions":{"actions":[ + {"action":"retire-membership-and-register","operations":["invoke"],"results":["register","retire"], + "targets":[ + {"recordType":"facility","rowBoundaries":membership.clone()}, + {"recordType":"membership","rowBoundaries":"unrestricted"}, + {"recordType":"organization","rowBoundaries":"unrestricted"} + ]}, + {"action":"register-in-created-organization","operations":["invoke"],"results":["organization","register"], + "targets":[ + {"recordType":"facility","rowBoundaries":membership.clone()}, + {"recordType":"organization","rowBoundaries":"unrestricted"} + ]} + ]} + }); + let mut register_then_retire = + project["accessProfiles"]["maintainer"]["permissions"]["actions"][0].clone(); + register_then_retire["action"] = json!("register-and-retire-membership"); + project["accessProfiles"]["maintainer"]["permissions"]["actions"] + .as_array_mut() + .unwrap() + .push(register_then_retire); + for (id, bounds) in [ + ("member", membership.clone()), + ("claimed", claim.clone()), + ("observer", membership.clone()), + ("limited", membership), + ] { + project["accessProfiles"][id]["permissions"]["actions"] = Value::Array( + [ + ("register-facility", "register", true), + ("close-facility", "close", false), + ("move-facility", "move", true), + ] + .into_iter() + .map(|(action, result, uses_organization)| { + let mut targets = vec![json!({"recordType":"facility","rowBoundaries":bounds})]; + if uses_organization { + let owner = json!([{"field":"owner","claim":"sub","operator":"equals"}]); + targets.push(json!({"recordType":"organization","rowBoundaries":owner})); + } + json!({"action":action,"operations":["invoke"],"targets":targets,"results":[result]}) + }) + .collect(), + ); + } + let mut claim_observer = project["accessProfiles"]["observer"].clone(); + claim_observer["requiredScopes"] = json!(["records:claim"]); + claim_observer["permissions"]["actions"] = json!([{ + "action":"close-facility","operations":["invoke"],"results":["close"], + "targets":[{"recordType":"facility","rowBoundaries":claim}] + }]); + project["accessProfiles"]["claim-observer"] = claim_observer; + project["accessProfiles"]["member"]["permissions"]["actions"].as_array_mut().unwrap().push( + json!({"action":"register-pair","operations":["invoke"],"results":["first","second"], + "targets":[{"recordType":"facility","rowBoundaries":[{"field":"organization","membership":"membership"}]}, + {"recordType":"organization","rowBoundaries":[{"field":"owner","claim":"sub","operator":"equals"}]}]}), + ); + project +} + +/// The write fixture with the same membership and claim twins on Proposal grants. +pub(super) fn proposal_project() -> Value { + let mut project = project(); + for (immediate, proposal) in [ + ("register-facility", "propose-facility"), + ("move-facility", "propose-move"), + ] { + let mut action = project["actions"][immediate].clone(); + if immediate == "register-facility" { + action["inputs"] + .as_array_mut() + .unwrap() + .retain(|input| input["id"] != "related"); + action["plan"]["effects"][0]["set"] + .as_object_mut() + .unwrap() + .remove("related"); + } + let inputs: Vec<_> = action["inputs"] + .as_array() + .unwrap() + .iter() + .map(|input| input["id"].clone()) + .collect(); + action["execution"] = json!({ + "mode":"proposal","proposal":{ + "review":{"type":"none"},"application":{"mode":"manual"}, + "retention":{"mode":"operator-erase"} + } + }); + project["actions"][proposal] = action; + for profile in ["member", "claimed"] { + let permissions = project["accessProfiles"][profile]["permissions"] + .as_object_mut() + .unwrap(); + let targets = permissions["actions"] + .as_array() + .unwrap() + .iter() + .find(|grant| grant["action"] == immediate) + .unwrap()["targets"] + .clone(); + permissions + .get_mut("actions") + .unwrap() + .as_array_mut() + .unwrap() + .push(json!({ + "action":proposal,"operations":["start"],"targets":targets + })); + permissions + .entry("proposals") + .or_insert_with(|| json!([])) + .as_array_mut() + .unwrap() + .push(json!({ + "action":proposal, + "operations":["get","list","edit","submit","cancel","apply"], + "party":"owner","readableInputs":inputs,"targets":targets + })); + } + } + project +} + +/// The write fixture with an organisation steward: a `stewardship` leaf only +/// the registrar (`steward` here, the unrestricted writer) writes, an +/// `organisation-steward` profile bounded by it, and the two Actions through +/// which that profile changes members. +// Only the membership journeys use the steward project; postgres_proposal +// includes this module for its Proposal project. +#[allow(dead_code)] +pub(super) fn steward_project() -> Value { + let mut project = project(); + let mut stewardship = project["recordTypes"]["membership"].clone(); + stewardship["route"] = json!("stewardships"); + stewardship["indexes"][0]["id"] = json!("stewardship-principal-key"); + project["recordTypes"]["stewardship"] = stewardship; + project["accessProfiles"]["steward"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push(json!({ + "recordType":"stewardship","rowBoundaries":"unrestricted", + "operations":["create","get","patch","tombstone"], + "readableFields":["organization","principal","active"], + "writableFields":["organization","principal","active"] + })); + project["actions"]["appoint-member"] = json!({ + "execution":{"mode":"immediate"}, + "inputs":[ + {"id":"organization","type":"reference","target":"organization","required":true, + "classification":"internal"}, + {"id":"principal","type":"string","maximumLength":80,"required":true, + "classification":"restricted"} + ], + "plan":{"type":"fixed","effects":[{ + "id":"membership","target":{"recordType":"membership"},"operation":"create", + "set":{"organization":{"fromInput":"organization"}, + "principal":{"fromInput":"principal"},"active":{"value":true}} + }]} + }); + project["actions"]["remove-member"] = json!({ + "execution":{"mode":"immediate","concurrency":"current-revision"}, + "inputs":[{"id":"membership","type":"reference","target":"membership","required":true, + "classification":"internal"}], + "commitGuards":{"targets":[{"input":"membership","field":"active","equals":true, + "reason":"membership-inactive"}]}, + "plan":{"type":"fixed","effects":[{ + "id":"membership","target":{"fromInput":"membership"},"operation":"patch", + "set":{"active":{"value":false}} + }]} + }); + let bounded = json!([{"field":"organization","membership":"stewardship"}]); + let own = json!([{"field":"id","membership":"stewardship"}]); + project["accessProfiles"]["organisation-steward"] = json!({ + "principalClaim":"sub","actorKind":"human","requiredScopes":["stewardship:manage"], + "permissions":{ + "records":[ + {"recordType":"organization","rowBoundaries":own.clone(), + "operations":["get","list"],"readableFields":["name"]}, + {"recordType":"membership","rowBoundaries":bounded.clone(), + "operations":["get","list"],"readableFields":["organization","principal","active"]} + ], + "actions":[ + {"action":"appoint-member","operations":["invoke"],"results":["membership"], + "targets":[{"recordType":"membership","rowBoundaries":bounded.clone()}, + {"recordType":"organization","rowBoundaries":own}]}, + {"action":"remove-member","operations":["invoke"],"results":["membership"], + "targets":[{"recordType":"membership","rowBoundaries":bounded}]} + ] + } + }); + project +} diff --git a/crates/registry-breg/tests/support/pilot_acceptance_harness.rs b/crates/registry-breg/tests/support/pilot_acceptance_harness.rs index 5991d6f3ce..7044c43920 100644 --- a/crates/registry-breg/tests/support/pilot_acceptance_harness.rs +++ b/crates/registry-breg/tests/support/pilot_acceptance_harness.rs @@ -212,6 +212,8 @@ impl PilotHarness { } } + // Individual suites use only the token helpers their callers need. + #[allow(dead_code)] pub fn token(&self, purpose: &str, row_boundary_claims: &[(&str, Value)]) -> String { self.token_with_scopes(purpose, row_boundary_claims, &[]) } diff --git a/crates/registry-breg/tests/support/postgres_membership_writes.rs b/crates/registry-breg/tests/support/postgres_membership_writes.rs new file mode 100644 index 0000000000..94c47f6dda --- /dev/null +++ b/crates/registry-breg/tests/support/postgres_membership_writes.rs @@ -0,0 +1,583 @@ +// SPDX-License-Identifier: Apache-2.0 + +use super::*; +use registry_breg::model::CompiledEntity; +use registry_breg::package::CompiledRegistryMigrationBaseline; +use tokio_postgres::{error::SqlState, Transaction}; +use uuid::Uuid; + +const MEMBER_KEY: Uuid = Uuid::from_u128(1); +const INACTIVE_KEY: Uuid = Uuid::from_u128(2); +const OTHER_KEY: Uuid = Uuid::from_u128(3); +const MEMBER_CHILD: Uuid = Uuid::from_u128(4); +const OTHER_CHILD: Uuid = Uuid::from_u128(5); + +struct MembershipFixture { + database: postgres_harness::TestDatabase, + registry: registry_breg::CompiledRegistry, +} + +impl MembershipFixture { + async fn create(with_steward: bool) -> Self { + let (registry, actions) = membership_targets::immediate(with_steward); + let mut baseline = CompiledRegistryMigrationBaseline::from_compiled("fixture", ®istry); + baseline.actions = actions; + let registry = registry.with_migration_baseline_schema(&baseline); + let database = postgres_harness::TestDatabase::create(2).await; + let (migration, task) = database.connect_migration().await; + install_compiled_schema(&migration, ®istry, &database.runtime_role) + .await + .unwrap(); + let catalog = ExpectedManagedCatalog::compiled(®istry); + registry_breg::postgres::managed_schema_fingerprint( + &migration, + &database.runtime_role, + &catalog, + ) + .await + .expect("the compiled membership functions, policies and ACLs form a closed catalog"); + task.abort(); + + let parent = ®istry.entities()["parent"]; + let membership = ®istry.entities()["membership"]; + let child = ®istry.entities()["child"]; + let parent_table = relation(parent); + let membership_table = relation(membership); + let child_table = relation(child); + database.admin.batch_execute(&format!( + "SELECT set_config('registry.active_package_revision', 'fixture', false); + INSERT INTO {parent_table} (record_id, {}, {}) VALUES + ('{MEMBER_KEY}', 'active', 'test'), ('{INACTIVE_KEY}', 'active', 'test'), ('{OTHER_KEY}', 'active', 'test'); + INSERT INTO {membership_table} (record_id, {}, {}, {}) VALUES + (gen_random_uuid(), '{MEMBER_KEY}', 'member-a', true), + (gen_random_uuid(), '{INACTIVE_KEY}', 'member-a', false); + INSERT INTO {child_table} (record_id, {}, {}) VALUES + ('{MEMBER_CHILD}', '{MEMBER_KEY}', 'member child'), + ('{OTHER_CHILD}', '{OTHER_KEY}', 'other child')", + column(parent, "status"), + column(parent, "zone"), + column(membership, "organization"), + column(membership, "principal"), + column(membership, "active"), + column(child, "parent"), + column(child, "label"), + )).await.unwrap(); + + Self { database, registry } + } + + fn helper(&self, prefix: &str) -> ®istry_breg::generated_ddl::DdlFunction { + self.registry + .ddl() + .functions + .iter() + .find(|function| function.name.starts_with(prefix)) + .unwrap() + } + + fn lock(&self) -> ®istry_breg::generated_ddl::DdlFunction { + self.helper("membership_lock_") + } + + fn ordinary(&self) -> ®istry_breg::generated_ddl::DdlFunction { + self.helper("membership_target_") + } + + async fn set_target(&self, tx: &Transaction<'_>, id: Uuid) { + let action = &self.registry.actions().actions[0]; + let context = json!({ + "version": 1, + "actionId": action.id, + "contractFingerprint": action.definition_revision, + "activePackageRevision": "fixture", + "selectedAccessProfile": "registrar", + "principal": "member-a", + "purpose": null, + "effectIds": ["child"], + "applicationId": Uuid::from_u128(6), + "targetEntityId": "child", + "targetRecordId": id, + "operation": "create", + "fields": ["label", "parent"], + "expectedRevision": null, + "lockOnly": false, + "targetRowBoundaries": [], + }); + tx.query_one( + "SELECT set_config('registry.immediate_action_target_context', $1, true)", + &[&context.to_string()], + ) + .await + .unwrap(); + } +} + +fn relation(entity: &CompiledEntity) -> String { + format!("registry_data.\"{}\"", entity.physical_table) +} + +fn column(entity: &CompiledEntity, field: &str) -> String { + format!("\"{}\"", entity.fields[field].physical_name) +} + +async fn select_profile(tx: &Transaction<'_>) { + tx.batch_execute( + "SELECT set_config('registry.access_profile', 'registrar', true), + set_config('registry.principal', 'member-a', true), + set_config('registry.active_package_revision', 'fixture', true)", + ) + .await + .unwrap(); +} + +async fn probe( + tx: &Transaction<'_>, + function: ®istry_breg::generated_ddl::DdlFunction, + key: Option, +) -> Result, tokio_postgres::Error> { + tx.query_one( + &format!("SELECT registry_context.\"{}\"($1)", function.name), + &[&key], + ) + .await + .map(|row| row.get(0)) +} + +#[tokio::test] +async fn the_target_load_of_a_row_outside_the_callers_memberships_returns_no_row() { + let fixture = MembershipFixture::create(false).await; + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + let child = relation(&fixture.registry.entities()["child"]); + for (id, visible) in [(MEMBER_CHILD, true), (OTHER_CHILD, false)] { + fixture.set_target(&tx, id).await; + let row = tx + .query_opt( + &format!("SELECT record_id FROM {child} WHERE record_id = $1"), + &[&id], + ) + .await + .unwrap(); + assert_eq!(row.is_some(), visible); + } + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_create_outside_the_callers_memberships_fails_row_security_with_42501() { + let fixture = MembershipFixture::create(false).await; + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let child = &fixture.registry.entities()["child"]; + let sql = format!( + "INSERT INTO {} (record_id, {}, {}) VALUES ($1, $2, 'child')", + relation(child), + column(child, "parent"), + column(child, "label") + ); + let id = Uuid::from_u128(7); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + fixture.set_target(&tx, id).await; + assert_eq!(tx.execute(&sql, &[&id, &MEMBER_KEY]).await.unwrap(), 1); + tx.rollback().await.unwrap(); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + fixture.set_target(&tx, id).await; + let err = tx.execute(&sql, &[&id, &OTHER_KEY]).await.unwrap_err(); + assert_eq!(err.code(), Some(&SqlState::INSUFFICIENT_PRIVILEGE)); + assert!(err + .as_db_error() + .unwrap() + .message() + .contains("row-level security")); + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn the_lock_helper_answers_true_for_a_member_and_false_for_an_inactive_or_unknown_key() { + let fixture = MembershipFixture::create(false).await; + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + let marker = "prior-marker"; + tx.query_one( + "SELECT set_config('registry.membership_probe', $1, true)", + &[&marker], + ) + .await + .unwrap(); + for (key, answer) in [ + (Some(MEMBER_KEY), Some(true)), + (Some(INACTIVE_KEY), Some(false)), + (Some(Uuid::nil()), Some(false)), + (None, None), + ] { + assert_eq!(probe(&tx, fixture.lock(), key).await.unwrap(), answer); + let restored: String = tx + .query_one("SELECT current_setting('registry.membership_probe')", &[]) + .await + .unwrap() + .get(0); + assert_eq!(restored, marker); + } + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn the_membership_lock_policy_exists() { + let fixture = MembershipFixture::create(false).await; + let source = relation(&fixture.registry.entities()["membership"]); + let runtime = fixture.database.runtime_role.as_str(); + let migration = fixture.database.migration_role.as_str(); + let lock_name = &fixture.lock().name; + assert_ne!(migration, runtime); + let row = fixture + .database + .admin + .query_one( + "SELECT c.relrowsecurity AND c.relforcerowsecurity, + r.rolname, p.polpermissive, p.polcmd::text, + pg_get_expr(p.polqual, p.polrelid), pg_get_expr(p.polwithcheck, p.polrelid), + NOT (r.rolsuper OR r.rolbypassrls) + FROM pg_policy p JOIN pg_class c ON c.oid = p.polrelid + JOIN pg_roles r ON p.polroles = ARRAY[r.oid] + WHERE c.oid = $1::text::regclass AND p.polname = $2", + &[&source, &format!("registry_{lock_name}_update")], + ) + .await + .unwrap(); + assert!(row.get::<_, bool>(0)); + assert_eq!(row.get::<_, String>(1), runtime); + assert!(row.get::<_, bool>(2)); + assert_eq!(row.get::<_, String>(3), "w"); + let guard: String = row.get(4); + for value in [ + lock_name.as_str(), + "registry.membership_probe", + "registry.access_profile", + "registrar", + "registry.principal", + "IS TRUE", + "record_lifecycle", + ] { + assert!(guard.contains(value), "{guard}"); + } + assert_eq!(row.get::<_, String>(5), "false"); + assert!(row.get::<_, bool>(6)); + for (helper, volatility) in [(fixture.ordinary(), "s"), (fixture.lock(), "v")] { + let signature = format!("registry_context.{}(uuid)", helper.name); + let row = fixture + .database + .admin + .query_one( + "SELECT r.rolname, NOT (r.rolsuper OR r.rolbypassrls), + l.lanname, p.provolatile::text, p.proisstrict, + NOT (p.prosecdef OR p.proleakproof OR p.proretset), + p.proconfig, p.prorettype = 'boolean'::regtype + FROM pg_proc p JOIN pg_roles r ON r.oid = p.proowner + JOIN pg_language l ON l.oid = p.prolang + WHERE p.oid = $1::text::regprocedure", + &[&signature], + ) + .await + .unwrap(); + assert_eq!(row.get::<_, String>(0), migration); + assert!(row.get::<_, bool>(1)); + assert_eq!(row.get::<_, String>(2), "plpgsql"); + assert_eq!(row.get::<_, String>(3), volatility); + assert!(row.get::<_, bool>(4)); + assert!(row.get::<_, bool>(5)); + assert_eq!(row.get::<_, Vec>(6), ["search_path=pg_catalog"]); + assert!(row.get::<_, bool>(7)); + } + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn the_runtime_role_can_lock_a_membership_row_it_cannot_update() { + let fixture = MembershipFixture::create(false).await; + let membership = &fixture.registry.entities()["membership"]; + let source = relation(membership); + let active = column(membership, "active"); + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let row = client + .query_one( + "SELECT has_table_privilege($1, 'SELECT'), has_table_privilege($1, 'UPDATE'), + has_column_privilege($1, 'record_id', 'UPDATE')", + &[&source], + ) + .await + .unwrap(); + assert!(row.get::<_, bool>(0)); + assert!(!row.get::<_, bool>(1)); + assert!(row.get::<_, bool>(2)); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + assert_eq!( + probe(&tx, fixture.lock(), Some(MEMBER_KEY)).await.unwrap(), + Some(true) + ); + tx.commit().await.unwrap(); + for sql in [ + format!("UPDATE {source} SET {active} = false"), + format!("INSERT INTO {source} (record_id) VALUES (gen_random_uuid())"), + ] { + let error = client.execute(&sql, &[]).await.unwrap_err(); + assert_eq!(error.code(), Some(&SqlState::INSUFFICIENT_PRIVILEGE)); + } + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn the_lock_helper_is_refused_in_a_read_only_transaction() { + let fixture = MembershipFixture::create(false).await; + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let tx = client + .build_transaction() + .read_only(true) + .start() + .await + .unwrap(); + select_profile(&tx).await; + assert_eq!( + probe(&tx, fixture.ordinary(), Some(MEMBER_KEY)) + .await + .unwrap(), + Some(true) + ); + let error = probe(&tx, fixture.lock(), Some(MEMBER_KEY)) + .await + .unwrap_err(); + assert_eq!(error.code(), Some(&SqlState::READ_ONLY_SQL_TRANSACTION)); + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_membership_table_no_write_locks_gets_no_update_privilege() { + let mut source = membership_fixture::source("facility"); + source["accessProfiles"]["steward"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .remove(1); + let registry = membership_fixture::compile(&source).unwrap(); + let database = postgres_harness::TestDatabase::create(1).await; + let (migration, task) = database.connect_migration().await; + install_compiled_schema(&migration, ®istry, &database.runtime_role) + .await + .unwrap(); + let pool = database.runtime_config.build_pool().unwrap(); + let client = pool.get_for_test().await.unwrap(); + let table = relation(®istry.entities()["membership"]); + let row = client + .query_one( + "SELECT has_table_privilege($1, 'SELECT'), has_table_privilege($1, 'UPDATE'), + has_column_privilege($1, 'record_id', 'UPDATE')", + &[&table], + ) + .await + .unwrap(); + assert!(row.get::<_, bool>(0)); + assert!(!row.get::<_, bool>(1)); + assert!(!row.get::<_, bool>(2)); + assert!(registry + .ddl() + .functions + .iter() + .all(|function| !function.name.starts_with("membership_lock_"))); + drop(client); + task.abort(); + database.cleanup().await; +} + +#[tokio::test] +async fn the_lock_blocks_a_removal_until_the_writer_commits() { + let fixture = MembershipFixture::create(true).await; + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + let writer_pid: i32 = tx + .query_one("SELECT pg_backend_pid()", &[]) + .await + .unwrap() + .get(0); + assert_eq!( + probe(&tx, fixture.lock(), Some(MEMBER_KEY)).await.unwrap(), + Some(true) + ); + let mut remover = pool.get_for_test().await.unwrap(); + let removal = remover.transaction().await.unwrap(); + removal + .batch_execute( + "SELECT set_config('registry.access_profile', 'steward', true), + set_config('registry.principal', 'steward', true), + set_config('registry.row_boundaries', '[]', true), + set_config('registry.active_package_revision', 'fixture', true)", + ) + .await + .unwrap(); + let remover_pid: i32 = removal + .query_one("SELECT pg_backend_pid()", &[]) + .await + .unwrap() + .get(0); + let membership = &fixture.registry.entities()["membership"]; + let removal_sql = format!( + "UPDATE {} SET {} = false WHERE {} = $1 AND {} = 'member-a'", + relation(membership), + column(membership, "active"), + column(membership, "organization"), + column(membership, "principal") + ); + { + let remove = removal.execute(&removal_sql, &[&MEMBER_KEY]); + tokio::pin!(remove); + let observe = async { + loop { + let blocked: bool = tx + .query_one( + "SELECT $1 = ANY(pg_blocking_pids($2))", + &[&writer_pid, &remover_pid], + ) + .await + .unwrap() + .get(0); + if blocked { + return; + } + tokio::task::yield_now().await; + } + }; + tokio::select! { + result = &mut remove => panic!("removal finished before writer committed: {result:?}"), + observed = tokio::time::timeout(Duration::from_secs(5), observe) => observed.unwrap(), + } + tx.commit().await.unwrap(); + assert_eq!(remove.await.unwrap(), 1); + } + removal.commit().await.unwrap(); + drop(remover); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + assert_eq!( + probe(&tx, fixture.lock(), Some(MEMBER_KEY)).await.unwrap(), + Some(false) + ); + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn the_membership_probe_plan_uses_the_generated_index() { + assert_index_plan(false).await; +} + +#[tokio::test] +async fn the_membership_lock_plan_uses_the_generated_index() { + assert_index_plan(true).await; +} + +async fn assert_index_plan(lock: bool) { + let fixture = MembershipFixture::create(false).await; + let membership = &fixture.registry.entities()["membership"]; + let table = relation(membership); + fixture + .database + .admin + .batch_execute(&format!( + "INSERT INTO {table} (record_id, {}, {}, {}) + SELECT gen_random_uuid(), '{MEMBER_KEY}', 'other-' || i, i <= 2000 + FROM generate_series(1, 2223) i; + ANALYZE {table}", + column(membership, "organization"), + column(membership, "principal"), + column(membership, "active") + )) + .await + .unwrap(); + + let helper = if lock { + fixture.lock() + } else { + fixture.ordinary() + }; + let ddl = fixture + .registry + .ddl() + .statements + .iter() + .find(|statement| statement.id == helper.id) + .unwrap(); + let body = ddl.sql.split_once(" AS '").unwrap().1.replace("''", "'"); + // The compiler's inner statement is explained under the same profile and + // marker as the helper. PL/pgSQL PERFORM spells SQL SELECT without a result. + let scan = if lock { + body.split_once("PERFORM 1 FROM") + .unwrap() + .1 + .split_once("; authorized") + .unwrap() + .0 + } else { + body.split_once("SELECT EXISTS (SELECT 1 FROM") + .unwrap() + .1 + .split_once(") INTO authorized") + .unwrap() + .0 + }; + let query = format!("EXPLAIN (FORMAT JSON) SELECT 1 FROM{scan}"); + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let tx = client.transaction().await.unwrap(); + select_profile(&tx).await; + tx.query_one( + "SELECT set_config('registry.membership_probe', $1, true)", + &[&helper.name], + ) + .await + .unwrap(); + let plan: Value = tx.query_one(&query, &[&MEMBER_KEY]).await.unwrap().get(0); + let index_ddl = fixture + .registry + .ddl() + .statements + .iter() + .find(|statement| statement.id == "entity.membership.membership.key-index") + .unwrap(); + let index = index_ddl.sql.split('"').nth(1).unwrap(); + fn index_node<'a>(node: &'a Value, index: &str) -> Option<&'a Value> { + if node["Index Name"] == index { + return Some(node); + } + node["Plans"] + .as_array()? + .iter() + .find_map(|child| index_node(child, index)) + } + let node = index_node(&plan[0]["Plan"], index).unwrap_or_else(|| panic!("{plan}")); + println!( + "membership {} plan: {}", + if lock { "lock" } else { "probe" }, + node + ); + tx.rollback().await.unwrap(); + drop(client); + fixture.database.cleanup().await; +} diff --git a/crates/registry-breg/tests/support/proposal_additions.rs b/crates/registry-breg/tests/support/proposal_additions.rs index 6e36c19bfb..af6de5d906 100644 --- a/crates/registry-breg/tests/support/proposal_additions.rs +++ b/crates/registry-breg/tests/support/proposal_additions.rs @@ -469,7 +469,7 @@ async fn additions_reviewer_reads_live_files_under_the_exact_context_binding() { reviewer["permissions"]["records"] = json!([]); let grant = &mut reviewer["permissions"]["proposals"][0]; grant["operations"] = json!(["get-review-context"]); - grant.as_object_mut().unwrap().remove("ownership"); + grant.as_object_mut().unwrap().remove("party"); grant["readableInputs"] = json!([]); grant["readableAttachments"] = json!([]); grant["writableAttachments"] = json!([]); diff --git a/crates/registry-breg/tests/support/proposal_additions_authority.rs b/crates/registry-breg/tests/support/proposal_additions_authority.rs index dcead67205..d14dab8114 100644 --- a/crates/registry-breg/tests/support/proposal_additions_authority.rs +++ b/crates/registry-breg/tests/support/proposal_additions_authority.rs @@ -657,7 +657,7 @@ async fn additions_reviewer_cannot_download_a_file_missing_from_the_live_context reviewer["permissions"]["records"] = json!([]); let grant = &mut reviewer["permissions"]["proposals"][0]; grant["operations"] = json!(["get-review-context"]); - grant.as_object_mut().unwrap().remove("ownership"); + grant.as_object_mut().unwrap().remove("party"); grant["readableInputs"] = json!([]); grant["readableAttachments"] = json!([]); grant["writableAttachments"] = json!([]); diff --git a/crates/registry-breg/tests/support/proposal_hooks_model.rs b/crates/registry-breg/tests/support/proposal_hooks_model.rs index 6317b7bb2d..dd07766652 100644 --- a/crates/registry-breg/tests/support/proposal_hooks_model.rs +++ b/crates/registry-breg/tests/support/proposal_hooks_model.rs @@ -18,7 +18,7 @@ pub fn source(hooks: Value) -> Value { "accessProfiles":{"clerk": {"default":true,"principalClaim":"sub","requiredScopes":["proposal:manage"],"requiredPurposes":["registry-administration"],"permissions":{ "records":[{"recordType":"target","operations":["create","get"],"readableFields":["name"],"writableFields":["name"],"rowBoundaries":"unrestricted"}], "actions":[{"action":"correct-name","operations":["start"],"targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}], - "proposals":[{"action":"correct-name","operations":["get","edit","submit","cancel","apply"],"ownership":"caller", + "proposals":[{"action":"correct-name","operations":["get","edit","submit","cancel","apply"],"party":"owner", "readableInputs":["target","value"],"readableAttachments":["support"],"writableAttachments":["support"],"targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}]}}}}) } diff --git a/crates/registry-breg/tests/support/proposal_review_asks.rs b/crates/registry-breg/tests/support/proposal_review_asks.rs index 303c1b0b36..b117edb0bc 100644 --- a/crates/registry-breg/tests/support/proposal_review_asks.rs +++ b/crates/registry-breg/tests/support/proposal_review_asks.rs @@ -750,6 +750,61 @@ async fn ask_feed_skips_unknown_and_bad_bindings_but_transient_reads_leave_the_p fixture.finish().await; } +#[tokio::test] +async fn matching_an_action_input_does_not_make_a_caller_the_proposal_subject() { + use registry_platform_oidc::ActorKind; + + let authority = Authority::start(false, true).await; + let fixture = answer_fixture(&authority).await; + let id = submitted(&fixture, "plain-input-no-subject-authority").await; + let binding = retained_binding(&fixture, id).await; + accept(&fixture, id, &binding).await; + let (ask, _) = announce(&authority, &binding); + worker(&fixture, &authority).await.unwrap(); + let path = format!("/v1/proposals/{id}"); + let (status, headers, owner) = request(&fixture, "GET", &path, None, None, Value::Null).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(owner["input"]["value"], "After"); + assert_eq!(owner["turn"], "party"); + assert_eq!(owner["asks"][0]["id"], ask.to_string()); + + // Both people match the same compiled profile and row boundary. The + // caller's principal matches the ordinary Action value rather than the + // Proposal's independent ownership binding. + let other = || caller_claims("After", ActorKind::Human); + let (status, _, concealed) = + request_as(&fixture, other(), "GET", &path, None, None, Value::Null).await; + assert_eq!(status, StatusCode::NOT_FOUND); + assert_no_asks(&concealed, "the non-owner"); + let (status, _, page) = request_as( + &fixture, + other(), + "GET", + "/v1/proposals?turn=party", + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!(page["items"], json!([])); + let (status, _, _) = request_as( + &fixture, + other(), + "POST", + &format!("{path}/asks/{ask}/answer"), + Some(headers["etag"].to_str().unwrap()), + Some("non-owner-answer"), + json!({"text":"Must not reach the reviewer"}), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + let (status, after, _) = request(&fixture, "GET", &path, None, None, Value::Null).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(after["etag"], headers["etag"]); + fixture.finish().await; +} + #[tokio::test] async fn ask_feed_turn_uses_the_shared_awaiting_party_rule_and_lists_only_live_unanswered_asks() { let authority = Authority::start(false, true).await; @@ -829,7 +884,7 @@ fn answer_source() -> Value { reviewer["requiredScopes"] = json!(["proposal:review"]); let grant = &mut reviewer["permissions"]["proposals"][0]; grant["operations"] = json!(["get-review-context"]); - grant.as_object_mut().unwrap().remove("ownership"); + grant.as_object_mut().unwrap().remove("party"); grant["readableAttachments"] = json!([]); grant["writableAttachments"] = json!([]); source["accessProfiles"]["reviewer"] = reviewer; @@ -2215,7 +2270,7 @@ async fn agent_answer_fixture_with_checker( profile["requesterClients"] = json!(["agent-client"]); } let grant = &mut profile["permissions"]["proposals"][0]; - grant.as_object_mut().unwrap().remove("ownership"); + grant.as_object_mut().unwrap().remove("party"); grant["operations"] = operations; grant["readableInputs"] = inputs; grant["readableContextFields"] = json!([]); diff --git a/crates/registry-breg/tests/task_grant_row_findings.rs b/crates/registry-breg/tests/task_grant_row_findings.rs index a59c1622f6..a25b899521 100644 --- a/crates/registry-breg/tests/task_grant_row_findings.rs +++ b/crates/registry-breg/tests/task_grant_row_findings.rs @@ -49,7 +49,7 @@ fn project(rows: Value, classification: &str) -> Value { "actions":[ {"action":"relabel-note","operations":["invoke"],"targets":[{"recordType":"note","rowBoundaries":rows.clone()}],"results":["relabelled"]}, {"action":"correct-case","operations":["start"],"targets":[{"recordType":"case","rowBoundaries":rows.clone()}]}], - "proposals":[{"action":"correct-case","operations":["get","edit"],"ownership":"caller","readableInputs":["case-ref","new-label"],"targets":[{"recordType":"case","rowBoundaries":rows}]}]}} + "proposals":[{"action":"correct-case","operations":["get","edit"],"party":"owner","readableInputs":["case-ref","new-label"],"targets":[{"recordType":"case","rowBoundaries":rows}]}]}} } }) } @@ -148,10 +148,8 @@ fn membership_bound_task_grant_profile_draws_no_finding() { membership_fixture::compile(&source).expect("membership-bound task-grant profile compiles"); assert_eq!(unbound_paths(®istry), Vec::::new()); - source["accessProfiles"]["member"]["permissions"]["records"][0] - .as_object_mut() - .expect("record permission object") - .remove("membershipBoundaries"); + source["accessProfiles"]["member"]["permissions"]["records"][0]["rowBoundaries"] = + serde_json::json!("unrestricted"); let registry = membership_fixture::compile(&source).expect("unbound task-grant profile compiles"); assert_eq!( diff --git a/crates/registry-breg/tests/value_type_consistency.rs b/crates/registry-breg/tests/value_type_consistency.rs index 10d4837096..4f99073912 100644 --- a/crates/registry-breg/tests/value_type_consistency.rs +++ b/crates/registry-breg/tests/value_type_consistency.rs @@ -62,7 +62,7 @@ fn project_source(definition: Value, use_site: &str) -> Value { json!({"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "set-value", "operations": ["invoke"], @@ -339,7 +339,7 @@ fn module_host(with_action_permission: bool) -> RegistryProject { source["accessProfiles"] = json!({"operator": { "default": true, "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"actions": [{ "action": "set-value", "operations": ["invoke"], diff --git a/crates/registry-breg/tests/wasm_handler_admission.rs b/crates/registry-breg/tests/wasm_handler_admission.rs index b647799487..1139a9f8c1 100644 --- a/crates/registry-breg/tests/wasm_handler_admission.rs +++ b/crates/registry-breg/tests/wasm_handler_admission.rs @@ -112,7 +112,7 @@ fn wasm_project() -> Value { }] } }}, - "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":"unrestricted", + "accessProfiles":{"registrar": {"default":true,"principalClaim":"registry_principal","requiredScopes":["records:write"], "permissions":{"actions":[{ "action":"register-person","operations":["invoke"], "targets":[{"recordType":"person","rowBoundaries":"unrestricted"}], diff --git a/crates/registry-bregctl/src/action_handler_test.rs b/crates/registry-bregctl/src/action_handler_test.rs index 64b0ee3a33..71c6f8a5eb 100644 --- a/crates/registry-bregctl/src/action_handler_test.rs +++ b/crates/registry-bregctl/src/action_handler_test.rs @@ -769,7 +769,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [records:write] permissions: actions: - action: register-person diff --git a/crates/registry-bregctl/src/check.rs b/crates/registry-bregctl/src/check.rs index 5c2656dc1f..b745ca52b2 100644 --- a/crates/registry-bregctl/src/check.rs +++ b/crates/registry-bregctl/src/check.rs @@ -1788,7 +1788,7 @@ fn action_for(code: &str, severity: Severity) -> &'static str { "breg.disclosure.derived-reads-unreadable-source" => "Grant the profile get on the record type the derived SQL reads, with only its link fields readable and the rowBoundaries of the profile's grant on the record type that owns the derived field. Or remove the derived field from the profile.", "breg.disclosure.derived-reads-source-boundary" => "Give the profile's grant on the record type the derived SQL reads the same rowBoundaries as its grant on the record type that owns the derived field, and no requiredPurposes unless they include every purpose that grant requires. Or remove the derived field from the profile.", "breg.disclosure.derived-reads-other-owner-rows" => "Read the record type that owns the derived field once, in the top-level FROM, with its own id as the key, and group or pick DISTINCT ON by nothing or by that id. A read path reader may instead read that record type under the rowBoundaries and requiredPurposes of its grant on the path's root. Or remove the derived field from the profile.", - "breg.disclosure.derived-reads-withheld-source-rows" => "Accept this finding if the derived value should leave out the rows the record condition, membershipBoundaries or requireConsent hides, or that rowBoundaries hide from a subquery that refers to no column of the row. Otherwise add the profile to exemptProfiles of the condition, link the subquery to the row, or remove the derived field from the profile.", + "breg.disclosure.derived-reads-withheld-source-rows" => "Accept this finding if the derived value should leave out the rows the record condition, a membership entry in rowBoundaries or requireConsent hides, or that rowBoundaries hide from a subquery that refers to no column of the row. Otherwise add the profile to exemptProfiles of the condition, link the subquery to the row, or remove the derived field from the profile.", "breg.disclosure.row-boundary-withheld-field" => "Bound the profile's rows by a field no condition withholds from it, or add the profile to exemptProfiles.", "breg.disclosure.membership-boundary-withheld-field" => "Bound the profile's rows by a membership on a field no condition withholds from it, or add the profile to exemptProfiles.", "breg.disclosure.consent-boundary-withheld-field" => "Point requireConsent on at a field no condition withholds from the profile, or add the profile to exemptProfiles.", @@ -2066,7 +2066,7 @@ mod tests { assert_ne!(action, REVIEW_FINDING, "{code}"); for setting in [ "rowBoundaries", - "membershipBoundaries", + "a membership entry in rowBoundaries", "requireConsent", "exemptProfiles", ] { diff --git a/crates/registry-bregctl/src/consent_module/module.yaml b/crates/registry-bregctl/src/consent_module/module.yaml index 560f9108d6..a57d84de80 100644 --- a/crates/registry-bregctl/src/consent_module/module.yaml +++ b/crates/registry-bregctl/src/consent_module/module.yaml @@ -38,6 +38,7 @@ recordTypes: - {id: data-life, type: string, maximumLength: 80, classification: public} - {id: description, type: text, maximumLength: 4000, required: true, classification: public} __SUBJECT__-consent-link: + membership: {key: subject, principal: principal, active: active} primaryDataset: consent route: __SUBJECT__-consent-links mutationMode: mutable diff --git a/crates/registry-bregctl/src/consent_module/profiles.yaml b/crates/registry-bregctl/src/consent_module/profiles.yaml index c7993be117..9ec1ee0af5 100644 --- a/crates/registry-bregctl/src/consent_module/profiles.yaml +++ b/crates/registry-bregctl/src/consent_module/profiles.yaml @@ -4,9 +4,8 @@ __SUBJECT__-consent-self: permissions: records: - recordType: __SUBJECT__-consent-decision - rowBoundaries: unrestricted - membershipBoundaries: - - {field: subject, membershipRecordType: __SUBJECT__-consent-link, membershipKeyField: subject, principalField: principal, activeField: active} + rowBoundaries: + - {field: subject, membership: __SUBJECT__-consent-link} operations: [get, list] readableFields: [subject, notice, clause, recipient, purpose, scope, decision, effective-at, expires-at, channel] - recordType: __SUBJECT__-consent-link diff --git a/crates/registry-bregctl/src/data_lifecycle.rs b/crates/registry-bregctl/src/data_lifecycle.rs index 22d49d9419..1311272bf3 100644 --- a/crates/registry-bregctl/src/data_lifecycle.rs +++ b/crates/registry-bregctl/src/data_lifecycle.rs @@ -1886,7 +1886,7 @@ mod tests { }}, "accessProfiles": {PROFILE: { "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": ENTITY, "operations": operations, @@ -1989,7 +1989,7 @@ mod tests { json!({ "action": format!("review-flow-{flow}"), "operations": ["get", "list", "edit", "submit", "cancel", "apply"], - "ownership": "caller", + "party": "owner", "readableInputs": readable_inputs, "targets": targets }) @@ -2884,7 +2884,7 @@ mod tests { }}, "accessProfiles": {PROFILE: { "principalClaim": "principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["records:write"], "permissions": {"records": [{ "recordType": ENTITY, "operations": ["create", "batch", "list"], diff --git a/crates/registry-bregctl/src/explain_report.rs b/crates/registry-bregctl/src/explain_report.rs index c6c7fe62fd..105863cb84 100644 --- a/crates/registry-bregctl/src/explain_report.rs +++ b/crates/registry-bregctl/src/explain_report.rs @@ -372,12 +372,21 @@ fn proposal_permissions(value: &Value, action_inputs: &Value, depth: usize, line let mut fields = permission_gates(permission); fields.extend([ ( - "ownership", - permission["ownership"] + "party", + permission["party"] .as_str() .unwrap_or("unrestricted") .to_owned(), ), + ( + "submits for", + if permission["submitsForAnyone"] == true { + "anyone" + } else { + "the submitter" + } + .to_owned(), + ), ( "readable context fields", names(&permission["readableContextFields"], "id"), diff --git a/crates/registry-bregctl/src/lib.rs b/crates/registry-bregctl/src/lib.rs index 2b8fd2239a..06059aa2e3 100644 --- a/crates/registry-bregctl/src/lib.rs +++ b/crates/registry-bregctl/src/lib.rs @@ -8079,6 +8079,20 @@ fn lifecycle_failure(command: &'static str, error: ApplyLifecycleError) -> Failu SuggestedAction::ReconcileFailedMigration, ); } + registry_breg::migration::MigrationError::MembershipDuplicateLiveRows { + entity_id, + } => { + return source_failure( + command, + diagnostic( + "breg.membership.duplicate-live-rows", + &format!("recordTypes[{entity_id}].membership"), + "Existing active rows of this membership source repeat a key and principal, so its unique live-row index could not build. The exact target remains pinned in maintenance; deactivate or tombstone all but one active row for each key and principal through operator recovery and retry the exact pinned target.", + ), + DiagnosticArtifact::DatabaseMigration, + SuggestedAction::ReconcileFailedMigration, + ); + } registry_breg::migration::MigrationError::FieldEncryptionLookupCollision { entity_id, record_ids, @@ -13512,11 +13526,10 @@ fn push_row_reach(row_reach: &Value, lines: &mut report::Lines) { ]; if reach["surface"] == "proposal_target" { fields.push(( - "Proposal ownership", - if reach["ownerOnly"] == true { - "caller only".to_owned() - } else { - "unrestricted".to_owned() + "Proposal party", + match reach["party"].as_str() { + Some(party) => format!("{party} only"), + None => "unrestricted".to_owned(), }, )); } @@ -19162,7 +19175,7 @@ recordTypes: accessProfiles: operator: principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [records:write] requiredPurposes: [operations] permissions: records: diff --git a/crates/registry-bregctl/tests/cli.rs b/crates/registry-bregctl/tests/cli.rs index 31a8c718a0..95a10256b3 100644 --- a/crates/registry-bregctl/tests/cli.rs +++ b/crates/registry-bregctl/tests/cli.rs @@ -1317,14 +1317,14 @@ fn explain_access_names_membership_constraints_instead_of_unrestricted_rows() { let output = bregctl(&["explain", "access", path(&project)]); assert!(output.status.success(), "{output:?}"); let human = String::from_utf8(output.stdout).unwrap(); - let member = human - .split("profile member") - .nth(1) - .expect("the member profile is explained") - .split("profile steward") - .next() - .unwrap(); - let aligned = member.split_whitespace().collect::>().join(" "); + let aligned = human + .lines() + .skip_while(|line| line.trim() != "profile member") + .skip(1) + .take_while(|line| !line.trim_start().starts_with("profile ")) + .flat_map(str::split_whitespace) + .collect::>() + .join(" "); assert!(aligned.contains("row restrictions (all) governed membership required")); assert!(aligned.contains("membership restrictions (all)")); assert!(aligned.contains("membershipRecordType")); @@ -1850,7 +1850,7 @@ accessProfiles: clerk: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [entry:write] permissions: records: - recordType: entry @@ -1936,7 +1936,7 @@ journeys: - id: list-records recordType: record accessProfile: operator - claims: {principal: data-operator} + claims: {principal: data-operator, scopes: [records:write]} request: {type: list} expect: {outcome: success, status: 200, count: 0} "#; @@ -2222,7 +2222,7 @@ accessProfiles: writableFields: [] household-archiver: principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [household:archive] requiredPurposes: [household-archive] permissions: actions: @@ -6810,7 +6810,7 @@ fn explain_access_human_reports_profile_gates_permissions_and_target_row_reach() "target contact: patch", "results contact-email", "Proposal profile directory-editor", - "ownership caller", + "party owner", "readable inputs email, jurisdiction, name", "writable inputs all Action inputs", "Target row reach:", @@ -6857,10 +6857,7 @@ fn explain_access_human_reports_profile_gates_permissions_and_target_row_reach() .iter() .find(|block| block.contains("surface proposal_target")) .unwrap_or_else(|| panic!("missing Proposal target block in {human}")); - assert!( - proposal.contains("Proposal ownership caller only"), - "{proposal}" - ); + assert!(proposal.contains("Proposal party owner only"), "{proposal}"); } #[test] @@ -6881,7 +6878,7 @@ fn explain_access_human_distinguishes_proposal_ownership_and_writable_inputs() { .split_whitespace() .collect::>() .join(" "); - assert!(baseline.contains("ownership caller"), "{baseline}"); + assert!(baseline.contains("party owner"), "{baseline}"); assert!( baseline.contains("writable inputs all Action inputs"), "{baseline}" @@ -6890,7 +6887,7 @@ fn explain_access_human_distinguishes_proposal_ownership_and_writable_inputs() { let mut narrowed = source; let permission = &mut narrowed["accessProfiles"]["directory-editor"]["permissions"]["proposals"][0]; - permission.as_object_mut().unwrap().remove("ownership"); + permission.as_object_mut().unwrap().remove("party"); permission["writableInputs"] = json!(["email"]); let narrowed = TestProject::from_registry_source(serde_norway::to_string(&narrowed).unwrap().as_bytes()); @@ -6901,7 +6898,7 @@ fn explain_access_human_distinguishes_proposal_ownership_and_writable_inputs() { .split_whitespace() .collect::>() .join(" "); - assert!(narrowed.contains("ownership unrestricted"), "{narrowed}"); + assert!(narrowed.contains("party unrestricted"), "{narrowed}"); assert!(narrowed.contains("writable inputs email"), "{narrowed}"); assert_ne!(baseline, narrowed); } @@ -7207,7 +7204,7 @@ accessProfiles: registrar: default: true principalClaim: registry_principal - requiredScopes: unrestricted + requiredScopes: [person:register] permissions: actions: - action: register-person @@ -11687,7 +11684,7 @@ fn encrypted_package_module_bytes() -> Vec { } fn data_package_fixture() -> (TestProject, PathBuf) { - let module_bytes = br#"{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{"record": {"primaryDataset":"data-registry","route":"records","mutationMode":"create-only","batch":{"maximumItems":2,"maximumBytes":400},"fields":[{"id":"code","type":"string","minimumLength":2,"maximumLength":16,"required":true,"classification":"internal"}],"accessProfiles":{"operator": {"principalClaim":"principal","operations":["create","batch","list"],"readableFields":["code"],"writableFields":["code"],"allowDataExport":true, "requiredScopes":"unrestricted","rowBoundaries":"unrestricted"}}}}}"#.to_vec(); + let module_bytes = br#"{"apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1","kind":"BRegModule","id":"core","version":"1","recordTypes":{"record": {"primaryDataset":"data-registry","route":"records","mutationMode":"create-only","batch":{"maximumItems":2,"maximumBytes":400},"fields":[{"id":"code","type":"string","minimumLength":2,"maximumLength":16,"required":true,"classification":"internal"}],"accessProfiles":{"operator": {"principalClaim":"principal","operations":["create","batch","list"],"readableFields":["code"],"writableFields":["code"],"allowDataExport":true, "requiredScopes":["records:write"],"rowBoundaries":"unrestricted"}}}}}"#.to_vec(); let module = parse_module_json(&module_bytes).expect("data module parses"); let module_digest = module_digest(&module); let project = TestProject::from_registry_source( diff --git a/crates/registry-bregctl/tests/cli/migration_capacity.rs b/crates/registry-bregctl/tests/cli/migration_capacity.rs index 086d76d66f..e624163b11 100644 --- a/crates/registry-bregctl/tests/cli/migration_capacity.rs +++ b/crates/registry-bregctl/tests/cli/migration_capacity.rs @@ -83,7 +83,7 @@ fn capacity_project(profile_count: usize) -> Vec { json!({ "action": format!("review-flow-{flow}"), "operations": ["get", "list", "edit", "submit", "cancel", "apply"], - "ownership": "caller", "readableInputs": readable_inputs, + "party": "owner", "readableInputs": readable_inputs, "targets": targets }) }) diff --git a/crates/registry-bregctl/tests/explain_contract.rs b/crates/registry-bregctl/tests/explain_contract.rs index 387cee2d2d..df0d67df9e 100644 --- a/crates/registry-bregctl/tests/explain_contract.rs +++ b/crates/registry-bregctl/tests/explain_contract.rs @@ -1389,3 +1389,40 @@ fn ctl_report_explain_example_matches_current_actions_report() { "{path:?} differs from current report bytes" ); } + +#[test] +fn access_contract_requires_membership_to_report_an_empty_claim_list() { + let fixture = fixture_path("products/breg/fixtures/organization-membership-access"); + let explanation = explain("access", &fixture); + let schema = load_schema("AccessExplanation"); + let path = "/recordTypes/0/profiles/0"; + let profile = explanation.pointer(path).unwrap(); + assert_eq!(profile["rowBoundaries"], json!([])); + assert!(!profile["membershipBoundaries"] + .as_array() + .unwrap() + .is_empty()); + assert!(schema.is_valid(&explanation)); + + let mut no_membership = explanation.clone(); + no_membership + .pointer_mut(path) + .unwrap() + .as_object_mut() + .unwrap() + .remove("membershipBoundaries"); + assert!(!schema.is_valid(&no_membership)); + + let mut empty_membership = explanation.clone(); + empty_membership.pointer_mut(path).unwrap()["membershipBoundaries"] = json!([]); + assert!(!schema.is_valid(&empty_membership)); + + let mut physical = explanation.clone(); + physical.pointer_mut(path).unwrap()["membershipBoundaries"][0]["membershipTable"] = + json!("physical-table"); + assert!(!schema.is_valid(&physical)); + + let mut unrestricted = explanation; + unrestricted.pointer_mut(path).unwrap()["rowBoundaries"] = json!("unrestricted"); + assert!(!schema.is_valid(&unrestricted)); +} diff --git a/crates/registry-casework/src/task_grants/native_exchange_tests.rs b/crates/registry-casework/src/task_grants/native_exchange_tests.rs index b1bae5f60a..72764f1018 100644 --- a/crates/registry-casework/src/task_grants/native_exchange_tests.rs +++ b/crates/registry-casework/src/task_grants/native_exchange_tests.rs @@ -555,7 +555,7 @@ fn prepare_issuer( ], ) .unwrap(); - let mut seed_client = client("seed-client", seed, Some("service"), &["records:get"]); + let mut seed_client = client("seed-client", seed, Some("service"), &["records:seed"]); seed_client.claims.extend([ ("tenant_claim".into(), "tenant-a".into()), ("registry_purpose".into(), "maintain".into()), @@ -564,7 +564,7 @@ fn prepare_issuer( "other-seed-client", other_seed, Some("service"), - &["records:get"], + &["records:seed"], ); other_seed_client.claims.extend([ ("tenant_claim".into(), "tenant-b".into()), @@ -581,8 +581,9 @@ fn prepare_issuer( vec![seed_client, other_seed_client], ) .unwrap(); - let source_resource = target.resource_servers[0].id.clone(); description.resource_servers.extend(target.resource_servers); + let source_resource = + local::declare_resource(&mut description, BREG_RESOURCE, &["records:get".into()]).unwrap(); // The reviewer needs a separate source-scoped token for the same subject. // The Casework staff scope grants no permissions in the BReg audience. let reviewer = description @@ -1988,7 +1989,7 @@ async fn approved_casework_tasks_reach_evidence_breg_and_scheduling_through_stoc "seed-client", &seed_key, BREG_RESOURCE, - "records:get", + "records:seed", ) .bearer_token() .await @@ -2001,7 +2002,7 @@ async fn approved_casework_tasks_reach_evidence_breg_and_scheduling_through_stoc "other-seed-client", &other_seed_key, BREG_RESOURCE, - "records:get", + "records:seed", ) .bearer_token() .await diff --git a/crates/registry-casework/src/task_grants/native_resource.rs b/crates/registry-casework/src/task_grants/native_resource.rs index 3681ad0cb3..340e26335b 100644 --- a/crates/registry-casework/src/task_grants/native_resource.rs +++ b/crates/registry-casework/src/task_grants/native_resource.rs @@ -30,9 +30,13 @@ journeys: - id: empty-site-list steps: - id: list-sites - entity: asset-site + recordType: asset-site accessProfile: steward - claims: {sub: fixture-steward, tenant_claim: fixture} + claims: + principal: fixture-steward + scopes: [records:seed] + directClaims: + tenant_claim: fixture request: {type: list} expect: {outcome: success, status: 200, count: 0} "#; @@ -84,7 +88,7 @@ pub(super) const PROJECT: &str = r#"{ "steward":{ "default":true, "principalClaim":"sub", - "requiredScopes":"unrestricted", + "requiredScopes":["records:seed"], "permissions":{ "records":[ { diff --git a/crates/registry-coordinator/tests/support/breg_service.rs b/crates/registry-coordinator/tests/support/breg_service.rs index 6ebb639d7c..f651c478d1 100644 --- a/crates/registry-coordinator/tests/support/breg_service.rs +++ b/crates/registry-coordinator/tests/support/breg_service.rs @@ -210,8 +210,8 @@ impl Breg { })); } registry["accessProfiles"]["writer"]["permissions"]["proposals"] = json!([ - {"action":"propose-item","operations":["get","submit","cancel"],"ownership":"caller","targets":[{"recordType":"item","rowBoundaries":[{"field":"owner","claim":"sub","operator":"equals"}]}]}, - {"action":"manual-item","operations":["get","submit","cancel","apply"],"ownership":"caller","targets":[{"recordType":"item","rowBoundaries":[{"field":"owner","claim":"sub","operator":"equals"}]}]} + {"action":"propose-item","operations":["get","submit","cancel"],"party":"owner","targets":[{"recordType":"item","rowBoundaries":[{"field":"owner","claim":"sub","operator":"equals"}]}]}, + {"action":"manual-item","operations":["get","submit","cancel","apply"],"party":"owner","targets":[{"recordType":"item","rowBoundaries":[{"field":"owner","claim":"sub","operator":"equals"}]}]} ]); let mut task_status = None; if let Some((citizen_project, status, status_key)) = citizen_project { diff --git a/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt b/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt index 67cf00d65c..d38f376003 100644 --- a/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt +++ b/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt @@ -146,6 +146,7 @@ evidence_oid4vci_request_refusals_total{check="task-grant-scope"} 0 evidence_oid4vci_request_refusals_total{check="task-grant-lifetime"} 0 evidence_oid4vci_request_refusals_total{check="task-grant-status"} 0 evidence_oid4vci_request_refusals_total{check="row-boundary"} 0 +evidence_oid4vci_request_refusals_total{check="membership"} 0 evidence_oid4vci_request_refusals_total{check="ownership"} 0 evidence_oid4vci_request_refusals_total{check="visibility"} 0 evidence_oid4vci_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-evidence/src/observability/golden-scrape.txt b/crates/registry-evidence/src/observability/golden-scrape.txt index 89d3c341d6..32d2052afe 100644 --- a/crates/registry-evidence/src/observability/golden-scrape.txt +++ b/crates/registry-evidence/src/observability/golden-scrape.txt @@ -113,6 +113,7 @@ evidence_request_refusals_total{check="task-grant-scope"} 0 evidence_request_refusals_total{check="task-grant-lifetime"} 0 evidence_request_refusals_total{check="task-grant-status"} 0 evidence_request_refusals_total{check="row-boundary"} 0 +evidence_request_refusals_total{check="membership"} 0 evidence_request_refusals_total{check="ownership"} 0 evidence_request_refusals_total{check="visibility"} 0 evidence_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-platform-authcommon/src/refusal.rs b/crates/registry-platform-authcommon/src/refusal.rs index 25c2543e81..4397cb25ed 100644 --- a/crates/registry-platform-authcommon/src/refusal.rs +++ b/crates/registry-platform-authcommon/src/refusal.rs @@ -153,6 +153,8 @@ failed_checks! { TaskGrantStatus => "task-grant-status", /// The target row is outside the caller's row boundary. RowBoundary => "row-boundary", + /// The target key failed a membership check. + Membership => "membership", /// The target exists and belongs to another caller. Ownership => "ownership", /// The target is absent or not visible to the caller, and the product does not tell which. @@ -210,6 +212,7 @@ impl FailedCheck { | Self::TaskGrantLifetime | Self::TaskGrantStatus | Self::RowBoundary + | Self::Membership | Self::Ownership | Self::Visibility | Self::ActionGuard => RefusalClass::Admission, @@ -574,8 +577,8 @@ mod tests { #[test] fn the_set_is_closed_unique_and_in_declaration_order() { - assert_eq!(FailedCheck::ALL.len(), 45); - assert_eq!(FailedCheck::COUNT, 45); + assert_eq!(FailedCheck::ALL.len(), 46); + assert_eq!(FailedCheck::COUNT, 46); let mut seen = std::collections::HashSet::new(); for (index, check) in FailedCheck::ALL.iter().enumerate() { assert_eq!(*check as usize, index); @@ -636,6 +639,7 @@ mod tests { ("TaskGrantLifetime", "task-grant-lifetime"), ("TaskGrantStatus", "task-grant-status"), ("RowBoundary", "row-boundary"), + ("Membership", "membership"), ("Ownership", "ownership"), ("Visibility", "visibility"), ("ActionGuard", "action-guard"), @@ -697,6 +701,7 @@ mod tests { (FailedCheck::TaskGrantLifetime, Admission), (FailedCheck::TaskGrantStatus, Admission), (FailedCheck::RowBoundary, Admission), + (FailedCheck::Membership, Admission), (FailedCheck::Ownership, Admission), (FailedCheck::Visibility, Admission), (FailedCheck::ActionGuard, Admission), diff --git a/crates/registry-rstack-dev/src/products.rs b/crates/registry-rstack-dev/src/products.rs index db1376777f..45a68cb73e 100644 --- a/crates/registry-rstack-dev/src/products.rs +++ b/crates/registry-rstack-dev/src/products.rs @@ -4447,12 +4447,179 @@ fn has_run_source(plan: &Plan) -> bool { mod tests { use super::*; use crate::bindings::{Bindings, BregReviewAuthority, CaseworkContextProvider}; + use registry_platform_config::service_compiler::development_plan; + use registry_platform_config::service_roles::{assign_roles, decode_role_document}; + use registry_platform_yaml::{Expect, Reader}; use std::{ io::{BufRead, BufReader}, os::unix::fs::PermissionsExt, sync::mpsc, }; + #[test] + fn canonical_facility_schema_people_require_exact_scopes_and_assignments() { + const JOURNEY: &str = "bounded-facility-and-batch-validation"; + const NORTH: &str = "facility-operator"; + const SOUTH: &str = "facility-south-operator"; + const FIRST: &str = "create-north-district-facility"; + const CONCEALED: &str = "south-district-claim-cannot-see-north-record"; + let root = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../products/breg/acceptance/facility") + .canonicalize() + .unwrap(); + let mut plan = facility_schema_plan(&root); + + let bindings = schema_people(&root, &plan, true).unwrap(); + assert_eq!( + bindings + .iter() + .map(|binding| ( + binding.journey.as_str(), + binding.step.as_str(), + binding.person.as_str(), + )) + .collect::>(), + [ + (JOURNEY, FIRST, NORTH), + (JOURNEY, "get-north-district-facility", NORTH), + (JOURNEY, "rename-north-district-facility", NORTH), + (JOURNEY, "list-north-district-facilities", NORTH), + (JOURNEY, CONCEALED, SOUTH), + (JOURNEY, "batch-refuses-out-of-bounds-installation", NORTH), + ], + ); + for (alias, district) in [(NORTH, "north-district"), (SOUTH, "south-district")] { + let person = &plan.people[alias]; + assert_eq!(person.subject, "synthetic-facility-operator"); + assert_eq!(person.client, "facility-operator"); + let grant = &person.grants[&Product::Breg]; + assert_eq!(grant.scopes, ["registry:facility:operate"]); + assert_eq!(grant.claims["administrative_boundaries"], json!([district])); + } + + let assert_refused = |root: &Path, plan: &Plan, step| { + let Err(refusal) = schema_people(root, plan, true) else { + panic!("expected the facility schema assignment to fail for {step}"); + }; + assert_eq!( + refusal.to_string(), + format!( + "dev.yaml /schemaTestPeople/{JOURNEY}/{step}: A BReg fixture step must resolve to exactly one test person with matching profile, scopes, and purpose. Next: Add or update a matching BReg grant, or select the matching person in schemaTestPeople." + ) + ); + }; + for (alias, step) in [(NORTH, FIRST), (SOUTH, CONCEALED)] { + let mut plan = facility_schema_plan(&root); + let grant = plan + .people + .get_mut(alias) + .unwrap() + .grants + .get_mut(&Product::Breg) + .unwrap(); + let scopes = std::mem::take(&mut grant.scopes); + assert_refused(&root, &plan, step); + + let grant = plan + .people + .get_mut(alias) + .unwrap() + .grants + .get_mut(&Product::Breg) + .unwrap(); + grant.scopes = scopes; + grant.scopes.push("registry:facility:extra".to_owned()); + assert_refused(&root, &plan, step); + } + + // The canonical journey names its actors. Remove one actor in a copy + // so the test can exercise the plan assignment and its absence. + let scratch = tempfile::tempdir().unwrap(); + let unassigned = scratch.path().canonicalize().unwrap(); + fs::create_dir(unassigned.join("tests")).unwrap(); + let mut journeys = authored_document(&root.join("tests/journeys.yaml")).unwrap(); + let journey = journeys["journeys"] + .as_array_mut() + .unwrap() + .iter_mut() + .find(|journey| journey["id"] == JOURNEY) + .unwrap(); + let step = journey["steps"] + .as_array_mut() + .unwrap() + .iter_mut() + .find(|step| step["id"] == CONCEALED) + .unwrap(); + assert_eq!( + step.as_object_mut().unwrap().remove("actor"), + Some(json!(SOUTH)) + ); + fs::write( + unassigned.join("tests/journeys.yaml"), + serde_json::to_vec(&journeys).unwrap(), + ) + .unwrap(); + assert_refused(&unassigned, &plan, CONCEALED); + + plan.schema_test_people.insert( + JOURNEY.to_owned(), + BTreeMap::from([(CONCEALED.to_owned(), SOUTH.to_owned())]), + ); + let bindings = schema_people(&unassigned, &plan, true).unwrap(); + let binding = bindings + .iter() + .find(|binding| binding.step == CONCEALED) + .unwrap(); + assert_eq!(binding.person, SOUTH); + } + + fn facility_schema_plan(root: &Path) -> Plan { + let dev_path = root.join("dev.yaml"); + let settings = Reader::new(dev_path.to_string_lossy()) + .read(&fs::read(&dev_path).unwrap(), &Expect::one(&plan::FORMAT)) + .unwrap(); + let mut document = development_plan(root, &settings).unwrap().native; + let registry = authored_document(&root.join("registry.yaml")).unwrap(); + let service = root.join("service.yaml"); + let service = + decode_role_document(&service.to_string_lossy(), &fs::read(&service).unwrap()).unwrap(); + let dev = document.as_object_mut().unwrap(); + dev.remove("apiVersion").unwrap(); + dev.remove("kind").unwrap(); + + // Supply the resolved grants consumed by schema_people using the + // facility's role declarations and BReg profile scopes. + for person in dev + .get_mut("people") + .unwrap() + .as_object_mut() + .unwrap() + .values_mut() + { + let roles: Vec = serde_json::from_value(person["roles"].clone()).unwrap(); + let assignment = assign_roles(&service.roles, &roles).unwrap(); + let profiles = &assignment.profiles["breg"]; + assert_eq!(profiles.len(), 1); + let profile = *profiles.first().unwrap(); + let scopes = ®istry["accessProfiles"][profile]["requiredScopes"]; + let mut claims = person["claims"]["breg"] + .as_object() + .cloned() + .unwrap_or_default(); + if let Some(purpose) = person["tokenFixtures"]["breg"]["purpose"] + .as_str() + .or_else(|| person["purposes"]["breg"].as_str()) + { + claims.insert("registry_purpose".to_owned(), json!(purpose)); + } + *person = json!({ + "subject": person["subject"], "client": person["client"], + "grants": {"breg": {"profile": profile, "scopes": scopes, "claims": claims}} + }); + } + serde_json::from_value(document).unwrap() + } + #[test] fn the_project_copy_is_private_to_the_owner() { let scratch = tempfile::tempdir().unwrap(); diff --git a/crates/registry-scheduling/src/metrics.rs b/crates/registry-scheduling/src/metrics.rs index 399dd29425..0a68a5758a 100644 --- a/crates/registry-scheduling/src/metrics.rs +++ b/crates/registry-scheduling/src/metrics.rs @@ -14,7 +14,7 @@ //! and problem details never become labels. //! //! The refusal counter, `scheduling_request_refusals_total`, is labelled by -//! the check a request failed. The check is a closed set of 45 names, never a +//! the check a request failed. The check is a closed set of 46 names, never a //! value a caller sent. //! //! The outbox and hook-delivery series are gauges sampled from the store when diff --git a/crates/registry-stack-client-node/breg/client.d.ts b/crates/registry-stack-client-node/breg/client.d.ts index 649d277ddc..b8b235cb19 100644 --- a/crates/registry-stack-client-node/breg/client.d.ts +++ b/crates/registry-stack-client-node/breg/client.d.ts @@ -517,8 +517,15 @@ export interface BRegOperationDescriptor { export interface BRegProposalActionDescriptor { readonly actionId: string readonly accessProfile: string + /** The Proposal party this entry is bound to; absent for an entry bound to no party. */ + readonly party?: BRegProposalPartyRole readonly operations: ReadonlyArray readonly readableInputs: ReadonlyArray + /** + * The inputs this entry may set through Start, Edit, Revise or Rebase; + * absent from a server that predates the member. Empty when it writes none. + */ + readonly writableInputs?: ReadonlyArray readonly readableContextFields: ReadonlyArray } @@ -567,6 +574,13 @@ export interface BRegActionDescriptor { readonly targetRecordType: string }> readonly requiredConditionKeys: ReadonlyArray + /** The input that names the person a Proposal is about, or `null` when the Action declares none. */ + readonly subjectInput: string | null + /** + * The inputs the selected profile may set, or `null` for an immediate Action + * or a server that predates the member. + */ + readonly writableInputs: ReadonlyArray | null readonly resultEffects: ReadonlyArray<{ readonly effect: string readonly recordType: string @@ -1102,6 +1116,8 @@ export interface BRegProposalReviewDocument { } /** Who is expected to act next, derived by BReg. */ export type BRegProposalTurn = 'party' | 'official' | 'nobody' +/** Which party of a Proposal a party-bound entry admitted the caller as. */ +export type BRegProposalPartyRole = 'owner' | 'subject' export type BRegProposalStatus = 'draft' | 'awaiting-party' | 'in-review' | 'approved' | 'processing' | 'applied' | 'rejected' | 'cancelled' /** The review decision on one submission. The public reason is the only reviewer text BReg serves. */ export interface BRegProposalDecision { readonly status: 'approved' | 'rejected' | 'changes-requested' | 'answered'; readonly decidedAt: string; readonly publicReason?: string } @@ -1114,7 +1130,7 @@ export interface BRegProposalSubmission { readonly decision?: BRegProposalDecision readonly handoffRefusal?: BRegProposalHandoffRefusal } -export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } +export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } export declare class BRegProposal { private constructor(); private readonly __opaque: void; readonly responseEtag: string | null; readonly identifier: string; readonly actionIdentifier: string; readonly documentJson: string; readonly inputJson?: string | null } export declare class BRegProposalGetBinding { private constructor(); private readonly __opaque: void } export declare class BRegProposalReviewBinding { private constructor(); private readonly __opaque: void } diff --git a/docs/site/src/content/docs/configure/breg-access.mdx b/docs/site/src/content/docs/configure/breg-access.mdx index 35faff1d5c..f43e538974 100644 --- a/docs/site/src/content/docs/configure/breg-access.mdx +++ b/docs/site/src/content/docs/configure/breg-access.mdx @@ -354,23 +354,26 @@ permission, with the reason `required-filters`, and still exports its `get`. ## Require a current membership -A row boundary works when the Record carries the claim value it is compared with. Sometimes the -right to read follows an affiliation that changes over time: a facility belongs to an -organisation, and whoever is currently a member of that organisation may read it. Copying members -into tokens would leave access in place until each token expired. - -`membershipBoundaries` on a record permission puts that rule into the registry. Each entry names -the Record's reference `field`, a `membershipRecordType`, and that type's `membershipKeyField`, -`principalField`, and `activeField`. A row is readable only while a membership Record exists with -the same key, the caller's verified principal, and `active: true`. Memberships are ordinary -Records that a separate steward profile creates and deactivates. A request that starts after a -deactivation commits no longer sees the Records; a read already running may finish. Historical -reads compare against current memberships too, so a past membership cannot restore access. - -A facility stores `organization`, a reference to an `organization` Record type. -A separate `membership` Record type stores an `organization` reference, a string `principal`, and a Boolean `active`. -Its optional descriptive fields can remain private. -Add the boundary to the facility's read grant: +Use a membership boundary when access follows an affiliation that can change. +For example, a facility belongs to an organisation, and its current members may read it. + +Declare the membership fields once on the Record type that holds the affiliation. +In the example, both the facility and the membership Record store an `organization` +reference to the same Record type. Add this declaration under the membership Record type. + +```yaml +recordTypes: + membership: + membership: + key: organization + principal: principal + active: active +``` + +`key` names the stored reference. `principal` names a stored plaintext string or text field. +`active` names a stored Boolean field. Add an entry to `rowBoundaries` on each grant you +want to restrict. The entry's `field` names the protected Record's reference, and +`membership` names the Record type with the declaration. ```yaml accessProfiles: @@ -382,7 +385,9 @@ accessProfiles: permissions: records: - recordType: facility - rowBoundaries: unrestricted + rowBoundaries: + - field: organization + membership: membership operations: - get - list @@ -400,88 +405,198 @@ accessProfiles: lookups: - selector: label valueOrigin: request - membershipBoundaries: - - field: organization - membershipRecordType: membership - membershipKeyField: organization - principalField: principal - activeField: active ``` The `label` lookup selector must already be declared on the facility Record type. -The two organisation fields must be stored references to the same Record type. -`principalField` must be a stored string or text field and `activeField` a stored Boolean. -Only active-lifecycle membership rows with `active: true` and an exact match to the profile's verified principal grant access. -A missing membership, null value, inactive membership, or other principal does not. -Configure a stable identity claim from a trusted issuer, and do not accept caller-submitted principal values as authority. - -Every listed membership boundary and ordinary `rowBoundaries` predicate must hold. -Declare `rowBoundaries` explicitly even when membership is the only row restriction; `rowBoundaries: unrestricted` adds no direct claim predicate and leaves the membership checks in force. -Up to eight membership boundaries are supported. -The declared fields are authorisation inputs, not an additional readable-field grant. -The root profile must satisfy the membership Record type's mandatory scopes and purposes. -The current boundary does not carry additional direct row requirements from that source, so the compiler rejects a membership Record type with mandatory `rowBoundaries`. - -The organisation membership access example project in the repository (at your release tag) holds the complete authored model, including separate steward grants and an index on principal, organisation, and active status. -Run `bregctl check` against that directory to compile it. -The same boundary compiles for facility and document registries without new server code. - -{/* Evidence: crates/registry-breg/src/contract.rs MembershipBoundarySource; - crates/registry-breg/src/membership.rs breg.access.membership-limit, breg.access.membership-key-type, - breg.access.membership-principal-type, breg.access.membership-active-type, - breg.access.membership-source-row-requirement; - crates/registry-breg/tests/membership_access.rs membership_boundaries_compile_for_distinct_registry_models; +The maintained synthetic organisation membership fixture in the repository contains the full +declarations and separate grants for the `member` and `steward` profiles. +To create a membership Record or set its `active` field to `false`, use a profile with a +write grant on the membership Record type. The grant must cover the operation and fields. The +fixture's `steward` profile is such an administrator: it writes every membership and is not +itself bounded by membership. For a steward limited to one organisation, see +[Steward an organisation](#steward-an-organisation). Use the fixture from the version you are +running to check the complete project with `bregctl check`. + +If you have an older project with `membershipBoundaries`, move the source field names into +the Record type's `membership` declaration and replace the old entries with `field` and +`membership` entries in `rowBoundaries`. Claim predicates can share the same list. +Every entry must hold. You can declare up to eight distinct membership entries per grant, +including entries expanded from a row boundary set. + +An active-lifecycle membership Record must match the key and the verified principal exactly, +with `active: true`. A missing match or a null key grants no access. Set `principalClaim` to +a stable identity claim from a trusted issuer. If the profile requires neither scopes nor +requester clients, it must use `sub` for membership. A profile that admits tokens without +scopes cannot write to a Record type that declares membership. An open profile's write target +needs a membership boundary or a claim boundary on its `principalClaim`. + +The grant's profile must satisfy the membership Record type's mandatory scopes and purposes. +Membership inputs remain private unless a separate field grant exposes them. +The compiler refuses membership entries in mandatory access requirements and refuses a +membership source with mandatory row predicates or incoming relationship read paths. +A membership source's own grants, and its Action and Proposal targets, can carry membership +entries only over a different membership source. That source must have no membership entries +and no incoming read paths. A source bounded by itself, or a chain of two levels, is refused with +`breg.access.membership-source-recursive`. So is a membership source that requires consent from +a consent record that membership bounds. + +A profile bounded through a membership source cannot create that source's rows. Nor can it +write the key, principal or active field the check reads, unless that write is itself bounded +over a different source. BReg refuses it with `breg.access.membership-source-write`. Writes that only +remove authority stay admitted: a fixed `active: false`, a tombstone, or a field the check does +not read. Put membership writes in a separate administrator profile, or in bounded Actions. + +Some grants are bounded on a membership source's own rows: by claims, or by a membership +entry on a field other than its key. Such a grant cannot set the key or principal. On an existing row it can only +deactivate. This covers Create, Batch, Import, Patch, and Action, Proposal and function plans. +BReg refuses it with `breg.access.membership-source-key-write`. Set the key through an Action +whose reference target grant you scope, or use an unrestricted grant. An unrestricted grant +can still reactivate any row, so give it only to administrators. + +BReg keeps at most one active row per key and principal in each membership source. A second +active row for the same person and key answers `409 conflict`. A successor package that meets +existing duplicates is refused with `breg.membership.duplicate-live-rows` until all but one are +deactivated. + +{/* Evidence: crates/registry-breg/src/contract.rs, MembershipDeclarationSource, MembershipRowBoundarySource; + crates/registry-breg/src/membership.rs, validate_declaration, validate_entries, validate_write_admission, source_predicate; + crates/registry-breg/tests/membership_authoring.rs, claim_and_membership_entries_share_one_row_boundaries_list, + membership_entries_are_limited_and_unique_after_set_expansion, open_profiles_with_membership_must_use_sub, + a_scopeless_profile_with_requester_clients_cannot_write_membership_records, + a_membership_entry_in_access_requirements_is_refused; + crates/registry-breg/tests/membership_access.rs, membership_boundaries_is_refused_with_its_replacement_named; products/breg/fixtures/organization-membership-access/registry.yaml. */} -Membership boundaries apply to reads only: get, lookup, list, count, snapshot, and revisions. -A record grant with a membership boundary cannot also grant writes. -Action and Proposal grants do not accept `membershipBoundaries` and do not inherit membership checks from read grants. -Give record mutations and membership administration to a separate, explicitly authorised steward profile. -Cursor replay on a read re-evaluates live membership, and a read grant never authorises a mutation or its replay. -Spatial bbox permissions use a separate authority role and cannot currently be combined with membership boundaries; ordinary reads of facilities remain available under the membership profile. - -Membership profiles can protect the root of a relationship read path. -A related Record type's membership rules cannot silently be bypassed by targeting it through a separate root grant, so the compiler rejects such target permissions. -Membership sources must remain leaf Record types without their own membership boundaries or incoming relationship read paths, which prevents recursive row-security policies. - -{/* Evidence: crates/registry-breg/src/membership.rs breg.access.membership-read-only, - breg.access.membership-read-path-target, breg.access.membership-source-recursive, - breg.access.membership-spatial-unsupported; - crates/registry-breg/tests/membership_access.rs membership_boundaries_refuse_unenforced_authority_paths. */} +You can use membership with these grants: + +- Record get, lookup, list, count, snapshot, and revisions. Count still requires `allowCount`. +- Record Create, Patch, Tombstone, and Batch. +- Immediate Action targets and Proposal Start and lifecycle targets. Put the boundary on + the target grant. An ordinary Record read grant supplies no Action or Proposal authority. + +A Proposal's Start grant and its lifecycle grant each carry their own membership entries. +Bound both. A lifecycle grant without the entry admits its operations on every Proposal the +grant otherwise reaches, whatever the current membership for its targets. + +The compiler refuses membership on Import, spatial bounding-box queries, Action grants used +by hooks, and grants used by timers. Use separately authorised grants for those paths. +A membership boundary can protect the root of a relationship read. The compiler refuses a +relationship read path through or to a Record type with membership-filtered permissions. +Use a direct read of that Record type. + +{/* Evidence: crates/registry-breg/src/membership.rs, validate_target_entries, refuse_membership_write; + crates/registry-breg/tests/membership_access.rs, membership_boundaries_refuse_unenforced_authority_paths; + crates/registry-breg/tests/membership_authoring.rs, import_grants_refuse_membership_entries, + membership_entries_are_incompatible_with_spatial_queries, + production_admits_a_membership_bound_immediate_action_target, + production_admits_membership_on_proposal_start_and_lifecycle_targets, + a_hook_cannot_use_an_action_grant_with_membership, a_timer_cannot_use_an_action_grant_with_membership. */} + +### Steward an organisation + +A steward manages who belongs to an organisation. Keep the job and the organisation apart. +The job is a role whose profile the issuer grants. +Which organisation a person stewards is a second membership source, `stewardship`. +It has the same declaration as `membership`, and only a registrar changes it. +So a steward cannot appoint a steward, themselves included. + +The steward's grants use two entries: + +- `{field: id, membership: stewardship}` on `organization` reads the organisation itself. + `field: id` names the protected Record's own identifier. + The compiler admits it only when the source's key references that Record type. + It bounds reads, and Action or Proposal targets the plan does not write. + A write bounded by `id` is refused with `breg.access.membership-key-type`. +- `{field: organization, membership: stewardship}` on `membership` reads the organisation's + members and bounds the steward's Actions. This is one level of membership over a different + source. + +Grant the steward no direct write on `membership` or `stewardship`. +Change members through two immediate Actions. +One creates an active membership for an organisation the steward reaches. +The other sets `active` to `false`, with `concurrency: current-revision` and a commit guard +that the row is still active. +Action effects create or patch, so removal deactivates the row. +BReg keeps one active row per organisation and principal, so appointing the same person again +creates a new row. A removed member gets the same answer as a caller who never had a membership. + +Name stewards the same way. The registrar holds two Actions, and no direct write on +`stewardship`. Each Action's `organization` reference target is bounded by the registrar's +own claims. + +The [organisation stewardship example](https://github.com/registrystack/registry-stack/tree/main/products/breg/examples/organisation-stewardship) +has the three roles, the six Actions, and a journey that `rstack dev start` runs. + +{/* Evidence: crates/registry-breg/src/membership.rs, validate_declaration, validate_entries, is_leaf_over, CANONICAL_ID; + crates/registry-breg/src/mutation/membership.rs, boundary_key; + crates/registry-breg/tests/steward_authoring.rs, + a_membership_boundary_may_name_the_protected_record_types_own_identifier, + the_identifier_field_bounds_reads_and_referenced_targets_only, + one_level_of_membership_over_a_different_leaf_compiles, a_chain_of_two_membership_levels_stays_refused, + a_chain_through_an_action_target_stays_refused; + crates/registry-breg/tests/support/membership_write_journeys.rs, + a_steward_appoints_and_removes_members_only_in_their_organisation, + a_removed_member_gets_a_strangers_answer_on_every_membership_path, + a_steward_cannot_reactivate_or_change_any_stewardship_or_membership_directly, + one_live_appointment_per_person_and_reappointment_creates_a_new_row; + products/breg/examples/organisation-stewardship/registry.yaml. */} ### Revocation and history -Authorisation queries read current membership Records in PostgreSQL. -A new request issued after a membership deactivation commits is denied or returns an empty authorised collection, including counts, lookups, and cursor continuations. -An already running read can finish from the statement snapshot that preceded revocation. -There is no token membership cache, external authorisation service, or registry-wide authorisation lock. +Authorisation checks use current membership Records in PostgreSQL. After a deactivation commits, +a new request loses access through that membership, including when it continues a list cursor. +An already running read can finish from its earlier statement snapshot. -Snapshots and revisions compare the retained Record's organisation with current memberships. -The historical membership state cannot restore access, and deactivation removes access to those historical Records as well. -Moving a facility to another organisation does not by itself remove access to its older revisions from members of the previous organisation. -This preserves the ordinary historical row-boundary contract, and current-owner-only history is a different policy that this feature does not imply. -Erased history remains unavailable. +Snapshots and revisions compare the retained Record's key with current memberships. +Erased history remains unavailable. If the caller loses access to a Proposal, the history response +can still return the Record revision while concealing its Proposal link. -{/* Evidence: crates/registry-breg/tests/postgres_membership_access.rs - real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs. */} -{/* TODO[evidence]: the claim that moving a facility keeps older-revision access for previous members is not asserted by a test I could name. */} +A Proposal's target membership also applies when filtering its list, disclosing review context +and saved documents, and admitting answers, commands, and attachments. Review context checks +current Record authority and membership for each frozen subject. -### How PostgreSQL enforces it - -PostgreSQL enforces the predicate through generated `SECURITY INVOKER` functions and forced row-level security. -Each generated PL/pgSQL function saves the prior authorisation context, enables only its matching membership probe, and restores the context before returning. -Its exception block rolls back the local context on errors. -It does not grant direct membership endpoints or derived views access to private membership Records. -The logical source views keep `security_invoker`, so the caller's row-level security policies decide every read through them; they are not barrier views. -No additional database role or RLS bypass is required. -PostgreSQL 17 remains the minimum for this surface, and other enabled features can require a newer supported version. +{/* Evidence: crates/registry-breg/tests/postgres_membership_access.rs, + real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs; + crates/registry-breg/tests/postgres_proposal.rs, proposal_list_correlates_membership_filtered_page_with_its_journal; + crates/registry-breg/tests/postgres_proposal_security.rs, + review_context_checks_each_frozen_membership_and_saved_document, + submitted_create_membership_controls_attachments_answers_and_commands, + record_history_rechecks_proposal_membership_without_hiding_the_revision. */} -Use `bregctl explain access` to inspect the expanded membership boundary alongside its scopes, purposes, and ordinary row boundaries. -Compiler diagnostics identify the unsupported field or grant and describe the supported alternative. +### How PostgreSQL enforces it -{/* Evidence: crates/registry-breg/src/membership.rs; - crates/registry-breg/tests/postgres_membership_access.rs - real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs. */} +PostgreSQL enforces the read predicate through generated `SECURITY INVOKER` functions and +forced row-level security. Each function temporarily enables only the matching membership probe +and restores the prior authorisation context. The check grants no direct access to membership +Records or their private fields. Source views use `security_invoker`. BReg generates a partial +index on key and principal for active membership rows. PostgreSQL 17 remains the minimum +for this surface. + +For membership-bounded Record writes, immediate Actions, and caller Apply, BReg takes shared +locks on the matching membership rows and checks the required keys in the write transaction. +When a write moves a Record between keys, the caller needs membership for both the stored and +proposed keys. If deactivation wins the lock first, the write can lose admission. If the write +locks the membership first, deactivation waits. A lock timeout returns `503 service.unavailable`. +Membership refusal uses the same concealment or generic precondition response as the equivalent +claim boundary. System Apply uses the pinned system grant for the frozen submission and has +no caller membership to lock. + +Use `bregctl explain access` to inspect the expanded predicate. Its output retains the +`membershipBoundaries` property and can show an empty claim-boundary array for a +membership-only grant. + +{/* Evidence: crates/registry-breg/src/generated_ddl.rs, security_invoker; + crates/registry-breg/src/membership.rs, source_guard, source_predicate, index_statement; + crates/registry-breg/src/mutation/membership.rs, verify_locked, authorize_proposed; + crates/registry-breg/src/postgres/proposal_context.rs, locks_membership, SystemApplyAuthority; + crates/registry-breg/tests/support/membership_write_journeys.rs, + record_write_first_makes_the_removal_wait, record_removal_first_refuses_the_write, + a_lock_wait_past_lock_timeout_answers_service_unavailable, + membership_refusals_match_the_claim_boundary_answer_at_each_step, + proposal_membership_refusals_match_the_claim_boundary_answer, + proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted, + automatic_worker_keeps_system_authority_and_human_apply_has_a_source_lock; + products/breg/contracts/explain/AccessExplanation.schema.json, membershipBoundaries. */} ## Require the subject's consent @@ -807,9 +922,9 @@ bregctl explain access facility The human report shows the actor kind, requester clients and task-grant requirements beside each profile's fields and row restrictions. Action and Proposal permissions include their target -rows, inputs, attachments and ownership. Omitted ownership and writable-input defaults are -explicit. Caller ownership limits which Proposal documents can be managed; it does not bound -the target Records. The report also shows the built-in executor's system application ceiling. Each +rows, inputs, attachments, party and `submitsFor`. Omitted party and writable-input defaults are +explicit. A party limits which Proposal documents can be managed. It does not bound the +target Records. A Proposal target in `rowReach` names its `party`. The report also shows the built-in executor's system application ceiling. Each read-path grant names its target Record type, through Record type, and route. `rowReach` also lists the target under a `read_path` surface with the root profile's row boundaries, so a review that starts from the disclosed Record type does not miss incoming paths. Add `--scenario` with a file of diff --git a/docs/site/src/content/docs/configure/breg-mcp.mdx b/docs/site/src/content/docs/configure/breg-mcp.mdx index f64d1f2bbc..487d2fc06f 100644 --- a/docs/site/src/content/docs/configure/breg-mcp.mdx +++ b/docs/site/src/content/docs/configure/breg-mcp.mdx @@ -125,7 +125,7 @@ accessProfiles: proposals: - action: correct-address operations: [get, list, edit] - ownership: caller + party: owner readableInputs: [address, new-address-line, new-locality, new-postal-code] targets: - recordType: person-address diff --git a/docs/site/src/content/docs/configure/breg-proposals.mdx b/docs/site/src/content/docs/configure/breg-proposals.mdx index 4ee975bbe1..527c26db49 100644 --- a/docs/site/src/content/docs/configure/breg-proposals.mdx +++ b/docs/site/src/content/docs/configure/breg-proposals.mdx @@ -165,7 +165,7 @@ proposals: - submit - revise - cancel - ownership: caller + party: owner readableInputs: - holder - statement @@ -175,12 +175,6 @@ proposals: - statement ``` -Treat a holder or applicant identifier as an ordinary typed input. -A self-service application fills it from authenticated caller metadata, and BReg rechecks the matching target boundary against verified claims at Submit. -BReg does not provide a claim-copy expression for Action inputs. -It records the Proposal owner and each submitter from the authenticated request, independently of the input value. -An officer acting for another applicant uses a separate staff profile with its own row boundaries and no caller-ownership restriction. - A standing human officer grant can hold Edit, Revise, Submit, and a bounded `writableInputs` list. Revise increments `submissionVersion`; a later Submit records that authenticated submitter and, when Review is required, creates a new exact Review. Edit, Revise, and Rebase audit only the IDs in `changedInputs`, never their values. @@ -190,9 +184,119 @@ The earlier version remains available through `readProposalSubmission`, includin crates/registry-bregctl/tests/cli.rs writable_inputs; crates/registry-breg/tests/postgres_proposal.rs writable_inputs. */} +### Owners and subjects + +A Proposal has two parties. +Its owner is the caller who filed it, recorded from the authenticated request. +Its subject is the person it is about, named by an Action input. +A Proposal grant written with `party: owner` admits only the owner, and one written with `party: subject` admits only the subject. +A grant without `party` is bound to no party, as an officer's or reviewer's grant is. + +The Action names its subject's input under `execution.proposal.subject`: + +```yaml +actions: + apply-for-licence: + execution: + mode: proposal + proposal: + subject: + input: holder +``` + +The input must be a required string, text or uuid input. +For work on an existing Record, name a required reference input and the field of the referenced Record that holds the person, for example `{input: licence, field: holder}`. +The field must be a plaintext string or text field. +BReg reads it inside the Submit transaction, as a commit guard reads its field, and never returns its value to the submitter. +A submitter who files only for themselves learns one thing: whether it names them. +An empty field and another person's identifier both answer `403 proposal.subject-not-caller`. + +Whoever writes that field chooses who may follow Proposals about the Record, so the compiler treats it as authority. +A direct Create, Batch, Import or Patch grant that may write it is refused with `breg.proposal.subject-field-write` when its row boundaries let the writer name anyone. +So is an Action grant whose plan sets it with no person deciding: an immediate Action, or a Proposal Action without required review that is applied automatically. +An unrestricted grant stays admitted, for staff who may decide who a Record is about. +So does a grant bounded on that field by the profile's own principal claim, and a Proposal Action that a reviewer decides or a person applies. + +BReg binds the subject once, at the first Submit, not at Start. +A draft binds no one, so the person it names cannot see it. +After that Submit, Edit, Revise and Rebase must restate the subject input exactly. +A different value answers `400 request.invalid` with `fieldPath` naming the input. +For the field form, a later Submit that reads a different value answers `409 proposal.subject-changed`. +To name someone else, cancel the Proposal and file a new one. +Declaring or changing `subject` changes the Action's revision, so a Proposal submitted before it needs Rebase and Submit before it has a subject. +Existing Proposals have none and behave as before. + +At Submit, BReg compares the subject with the submitter's verified principal. +When they differ, Submit answers `403 proposal.subject-not-caller` unless the submitting grant says `submitsFor: anyone`. +A registry reads one principal claim, so the identifier a clerk types is the value of that same claim in the citizen's token. +A self-service profile therefore files only for its caller, and a desk profile that files for others says so: + +```yaml +accessProfiles: + licence-desk: + principalClaim: holder_ref + requiredScopes: ["registry:licence:intake"] + permissions: + proposals: + - action: apply-for-licence + party: owner + submitsFor: anyone + operations: [get, list, edit, submit, revise, cancel] + readableInputs: [holder, statement, licence-number] + citizen: + principalClaim: holder_ref + requiredScopes: ["registry:licence:self"] + permissions: + proposals: + - action: apply-for-licence + party: owner + operations: [get, list, edit, submit, revise, cancel] + readableInputs: [holder, statement] + - action: apply-for-licence + party: subject + operations: [get, list, get-review-status, answer, add, cancel] + readableInputs: [holder] +``` + +A caller is the subject when the verified principal of their access profile equals the bound value exactly. +No other claim, input or header takes part. +No issuer takes part either: any issuer admitted to the profile whose token carries that principal matches. +So `authentication.oidc.issuers..accessProfiles` decides which issuers may. +Only a verified person acting for themselves, under no task grant and with no delegated actor, is matched. +An agent, a service or a delegated token with the subject's principal is not. +A caller whose principal only happens to equal an ordinary input of an Action without `subject` gains nothing. + +A profile holds at most one entry for each party of an Action, and an entry without `party` cannot sit beside them. +For one Proposal, the owner entry governs a caller who filed it, then the subject entry a caller who is its subject. +The governing entry alone decides the operation and the projection, including `readableInputs` and attachments, so a self-filer always sees the owner entry's view. +A subject entry may hold only `get`, `list`, `get-review-status`, `answer`, `add` and `cancel`. +The subject cannot change what someone else filed. +An operation the subject entry does not hold answers `403 profile.not-authorized` while the subject can still read the Proposal. +A subject whose target has left their row boundary, and every other caller refused after a Proposal is found, gets a concealed `404 resource.not-found`. +A subject's `target` filter on the list matches only reference inputs the subject entry reads. +The profile's `actorKind` must be `human` or unset, and an open profile with a subject entry must use `sub` as its principal. +Target row boundaries still apply to both parties. + +The Proposal document carries `partyRole: owner` or `partyRole: subject` when a party entry admitted the caller. +Officers' reads carry none. +`GET /v1/proposals` lists the Proposals the caller filed and those filed about them, each under its own entry, and `turn=party` keeps the ones waiting for either. +Audit records a keyed subject pseudonym on the Submit that binds it, never the identifier, and `partyRole` on every request a party entry admitted. +Erasing a Proposal's detail also erases its stored subject, so the subject no longer follows it. +The owner still reads its state. + +Nothing here records a mandate or lets a party delegate. +The filer keeps the owner access their own profile gives, and BReg does not check that they had the right to act for the subject. +That is the job of the profile that says `submitsFor: anyone`. + +{/* Evidence: crates/registry-breg/tests/proposal_party_compiler.rs; + crates/registry-breg/tests/postgres_proposal_subject.rs; + crates/registry-breg/src/api/proposals.rs select_proposal_grant; + crates/registry-breg/src/mutation/proposal.rs bind_proposal_subject; + crates/registry-breg/src/proposal_subject.rs validate_field_writes. */} + ### Access after a target leaves the row boundary -Ownership alone does not preserve access after a target leaves the caller's current row boundary. +A party binding alone does not preserve access after a target leaves the caller's current row boundary. Proposal Get then returns a concealed 404, List omits the Proposal, and transitions such as Cancel return the generic precondition refusal. The saved Proposal remains governed work, but that caller can no longer view, cancel or recover it. Explain this loss of access to users and provide a service contact path; do not retain a private copy as substitute authority. @@ -229,7 +333,7 @@ Refetch status for the intended submission after Revise or Rebase; do not use a ### Show review progress to the applicant -To show an applicant where their current submission is in review, set `readableReviewProgress: true` on the Action's caller-owned Proposal grant that includes `get-review-status`. +To show an applicant where their current submission is in review, set `readableReviewProgress: true` on the Action's party-bound Proposal grant (`party: owner` or `party: subject`) that includes `get-review-status`. Have the Review provider declare the codes it can release. With Casework, set `publicProgressCode` on the stages the applicant sees. diff --git a/docs/site/src/content/docs/configure/breg.mdx b/docs/site/src/content/docs/configure/breg.mdx index c34dee5331..f856611ac8 100644 --- a/docs/site/src/content/docs/configure/breg.mdx +++ b/docs/site/src/content/docs/configure/breg.mdx @@ -373,7 +373,7 @@ The fixture compares the claim with the stored owner directly, so access is not History access is granted separately, and the fixture grants none. The fixture does not implement a general cross-Record invariant, arbitrary SQL or Rhai reads during a mutation, or a process engine. -Live relational membership authorisation is a separate policy capability that needs its own declared model and tests. +Live membership authorisation is a separate capability: declare a membership source and use membership entries in `rowBoundaries`, as [Require a current membership](../breg-access/#require-a-current-membership) describes. Use a Proposal when accepting a change requires review. {/* Evidence: products/breg/fixtures/facility-registry-actions/registry.yaml; @@ -532,7 +532,7 @@ It does not detect a join to a table expression or `FROM` subquery over rows not Keep such a derived field to readers whose grant on that Record type is unbounded. Other protections on a Record type the SQL reads also leave rows out of the computation. -They are a `record` disclosure condition that binds the reader, and `membershipBoundaries` or `requireConsent` on the reader's grant on that type. +They are a `record` disclosure condition that binds the reader, and a membership entry in `rowBoundaries` or `requireConsent` on the reader's grant on that type. The same grant governs the profile's direct reads, where hiding those rows may be intended. So `bregctl check` reports each one as the finding `breg.disclosure.derived-reads-withheld-source-rows` instead of refusing it. The derived value leaves out the rows that the protection hides. diff --git a/docs/site/src/content/docs/explanation/where-authority-lives.mdx b/docs/site/src/content/docs/explanation/where-authority-lives.mdx index 0112d4985a..4bac0bf5cd 100644 --- a/docs/site/src/content/docs/explanation/where-authority-lives.mdx +++ b/docs/site/src/content/docs/explanation/where-authority-lives.mdx @@ -45,27 +45,28 @@ See [BReg access profiles](../../configure/breg-access/) for the fields and exam {/* Evidence: crates/registry-breg/src/contract.rs row_boundaries; crates/registry-breg/src/access.rs; crates/registry-breg/src/authority.rs. */} -## Membership boundaries read records, for reads only +## Membership boundaries read records -A membership boundary moves the decision into records. A row is readable only while a current, -active membership Record names the caller. Deactivate the membership and the next request no longer -sees the row. No token expiry is involved. +A membership boundary moves the decision into records. A row is in reach only while a current, +active membership Record names the caller. Deactivate the membership and the next request loses +that reach. No token expiry is involved. -Membership boundaries support `get`, `lookup`, `list`, `revisions` and `snapshot` only. Today BReg -refuses a profile that combines a membership boundary with any other operation, or with -`writableFields`. The compiler reports `breg.access.membership-read-only` and tells you to use a -separate, directly authorised profile for writes and proposal application. +A membership boundary bounds reads, Record Create, Patch, Tombstone and Batch, and immediate +Action and Proposal targets. Writes check the membership in the write transaction and hold it +locked until they commit. Because the membership source is itself authority, BReg refuses a +profile bounded through a source that could write the fields its check reads +(`breg.access.membership-source-write`). Grant membership writes to a separate administrator +profile, or to bounded Actions such as a steward's, and review that grant as authority. -So a registry that must restrict writes by team still uses `rowBoundaries` and token claims for the -write profile. Membership records cannot yet carry write authority. +Some limits apply: -Two more limits apply today: +- A profile with a membership boundary cannot enable spatial bounding-box queries or Import. +- A grant declares at most eight membership boundaries. +- A membership source can be bounded by membership only one level deep. -- A profile with a membership boundary cannot enable spatial bounding-box queries. -- A profile declares at most eight membership boundaries. - -{/* Evidence: crates/registry-breg/src/membership.rs validate(); - crates/registry-breg/tests/membership_access.rs membership_boundaries_refuse_unenforced_authority_paths. */} +{/* Evidence: crates/registry-breg/src/membership.rs validate(), validate_source_writes; + crates/registry-breg/tests/membership_access.rs membership_boundaries_refuse_unenforced_authority_paths; + crates/registry-breg/tests/steward_authoring.rs a_member_cannot_write_the_fields_their_membership_probe_reads. */} ## Casework keeps BReg disclosure under the reviewer's identity diff --git a/docs/site/src/content/docs/operate/adapter.mdx b/docs/site/src/content/docs/operate/adapter.mdx index 13d12f204e..7be099317b 100644 --- a/docs/site/src/content/docs/operate/adapter.mdx +++ b/docs/site/src/content/docs/operate/adapter.mdx @@ -1001,7 +1001,7 @@ Facade series: | --- | --- | --- | --- | | `adapter_http_requests_total` | counter | `route` (route template, or `unmatched`), `method`, `status` (`1xx`, `2xx`, `3xx`, `4xx`, `5xx`, `other`) | Answered facade requests. | | `adapter_upstream_failures_total` | counter | `class` (`upstream`, `upstream.http`, `upstream.timeout`, `upstream.connection`, `upstream.malformed`, `upstream.too-large`, `upstream.redirect`, `breaker.open`, `throttle.rejected`, `credential.rejected`, `egress.refused`) | Calls to the source that failed, by error class. It counts failed exchanges, status polls, bounded-wait polls and recovery checks. | -| `adapter_request_refusals_total` | counter | `check` (the 45 shared failed-check labels, all present at zero, for example `credential-missing`, `token-signature`, `scope`, `operation`, `ownership`, `visibility`) | Facade and payment requests refused, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. | +| `adapter_request_refusals_total` | counter | `check` (the 46 shared failed-check labels, all present at zero, for example `credential-missing`, `token-signature`, `scope`, `operation`, `ownership`, `visibility`) | Facade and payment requests refused, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. | | `adapter_journal_write_failures_total` | counter | none | Audit journal writes that failed, so the exchange answered an internal error. Custody and rendering failures are not counted here. | | `adapter_retention_sweep_failures_total` | counter | `store` (`journal`, `idempotency`, `other`) | Retention sweep batches that failed and were left to the next tick. | @@ -1013,7 +1013,7 @@ Job host series: | `adapter_job_last_successful_pass_age_seconds` | gauge | none | Seconds since a pass in this process settled its page. Absent until the first such pass. | | `adapter_job_pass_failures_total` | counter | `reason` (`page-fault`, `destination-stop`, `refusal-limit`, `store-unreachable`) | Passes that did not settle, and passes that could not reach the store. A pass that finds another process holding the lease is not a failure and is not counted. | | `adapter_job_hook_refusals_total` | counter | `reason` (`not-found`, `method`, `unauthenticated`, `rate-limited`, `unavailable`, `body-timeout`, `body-too-large`, `body-unreadable`) | Hook requests the ingress refused. | -| `adapter_job_request_refusals_total` | counter | `check` (the 45 shared failed-check labels, all present at zero. The hook ingress records `credential-missing`, `credential-malformed`, `shared-secret` and `rate-limit`) | Hook requests refused for a credential or the rate limit, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. Present when the host is built with `job-hook`. | +| `adapter_job_request_refusals_total` | counter | `check` (the 46 shared failed-check labels, all present at zero. The hook ingress records `credential-missing`, `credential-malformed`, `shared-secret` and `rate-limit`) | Hook requests refused for a credential or the rate limit, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. Present when the host is built with `job-hook`. | | `adapter_job_gauge_sample_failures_total` | counter | none | Item count reads that failed or timed out. | When the store cannot be read at scrape time, `adapter_job_items` carries no samples and diff --git a/docs/site/src/content/docs/operate/coordinator.mdx b/docs/site/src/content/docs/operate/coordinator.mdx index a078e06c91..d75192b251 100644 --- a/docs/site/src/content/docs/operate/coordinator.mdx +++ b/docs/site/src/content/docs/operate/coordinator.mdx @@ -805,7 +805,7 @@ The metrics are Prometheus text (`text/plain; version=0.0.4`, served with `Cache | `coordinator_runs_finished_total` | counter | `state`: `finished`, `failed`, `cancelled`, `cancelled-after-effect`, `expired` | | `coordinator_step_attempts_total` | counter | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent`, `unavailable` | | `coordinator_authentication_refusals_total` | counter | `reason`: `refused`, `policy`, `unavailable` | -| `coordinator_request_refusals_total` | counter | `check`: the closed set of 45 failed checks, every value published at zero | +| `coordinator_request_refusals_total` | counter | `check`: the closed set of 46 failed checks, every value published at zero | | `coordinator_metrics_sample_failures_total` | counter | `sample`: `dispatch-queue`, `run-holds` | | `coordinator_dispatch_jobs` | gauge | `state`: `pending`, `leased`, `unknown` | | `coordinator_runs_attention` | gauge | `reason`: `definition-refused`, `other` | diff --git a/docs/site/src/content/docs/operate/documents.mdx b/docs/site/src/content/docs/operate/documents.mdx index c6db0ca572..1a91d1d898 100644 --- a/docs/site/src/content/docs/operate/documents.mdx +++ b/docs/site/src/content/docs/operate/documents.mdx @@ -697,7 +697,7 @@ answers the series below and nothing else. The document listener does not route | `documents_hook_oldest_overdue_age_seconds` | none | Gauge of how many seconds the oldest pending hook delivery is past its due time. Zero when none is overdue | | `documents_worker_last_success_age_seconds` | `worker`: `cleanup` | Gauge of seconds since the cleanup pass last finished without leaving an orphaned object unconfirmed | | `documents_metrics_sample_failures_total` | `sample`: `verification-jobs`, `erasure-jobs`, `hook-deliveries` | Scrapes in which that queue could not be read | -| `documents_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `documents_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | Every state is listed, with a zero when no row is in it. Watch the `dead-lettered` state of each gauge, the work that gave up and needs a person. Replay a verification or erasure job as diff --git a/docs/site/src/content/docs/operate/messaging.mdx b/docs/site/src/content/docs/operate/messaging.mdx index 128c83992a..372e41e911 100644 --- a/docs/site/src/content/docs/operate/messaging.mdx +++ b/docs/site/src/content/docs/operate/messaging.mdx @@ -673,7 +673,7 @@ The series are: | `messaging_provider_attempts_total` | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent` | Provider attempts, by class | | `messaging_provider_callbacks_total` | `outcome`: `unverified`, `unreadable`, `ignored`, `applied`, `unchanged`, `unmatched`, `ambiguous`, `unavailable` | Provider callbacks, by what became of them | | `messaging_limit_refusals_total` | `limit`: `rate`, `daily`, `pacing`, `callback` | Submissions, attempts, and callbacks a limit refused | -| `messaging_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `messaging_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | | `messaging_retention_runs_total` | `outcome`: `erased`, `idle`, `failed` | Retention sweeps this process ran | | `messaging_metrics_sample_failures_total` | `sample`: `dispatch-queue` | Scrapes in which the database read failed, since the process started | | `messaging_dispatch_jobs` | `state`: `pending`, `leased`, `unknown` | Gauge read from the database at each scrape | diff --git a/docs/site/src/content/docs/operate/scheduling.mdx b/docs/site/src/content/docs/operate/scheduling.mdx index 03487f5312..df5bcf5dd1 100644 --- a/docs/site/src/content/docs/operate/scheduling.mdx +++ b/docs/site/src/content/docs/operate/scheduling.mdx @@ -481,7 +481,7 @@ the series below and nothing else. The public listener does not route `/metrics` | `scheduling_hook_oldest_pending_age_seconds` | none | Gauge of how many seconds ago the oldest pending hook delivery's event was captured. Zero when none is pending | | `scheduling_worker_last_success_age_seconds` | `worker`: `hold-expiry`, `retention` | Gauge of seconds since the worker last finished a pass | | `scheduling_metrics_sample_failures_total` | `queue`: `outbox`, `hook-deliveries` | Scrapes in which that queue could not be read | -| `scheduling_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `scheduling_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | Every state is listed, with a zero when no row is in it. Watch `scheduling_outbox_items{state="dead-lettered"}` and diff --git a/docs/site/src/content/docs/reference/breg-api.mdx b/docs/site/src/content/docs/reference/breg-api.mdx index e546a90dcf..10ad8f1956 100644 --- a/docs/site/src/content/docs/reference/breg-api.mdx +++ b/docs/site/src/content/docs/reference/breg-api.mdx @@ -852,9 +852,18 @@ An absent member means an immediate Action or a server that predates these membe Rust keeps a value this client version does not recognise as `Unknown`, and Node and Python return it as served. A member that is not a lowercase identifier string fails the whole metadata document as a protocol error. -`proposals.actions` is a read-only inventory of each visible `actionId` and `accessProfile` pair, its `operations`, and its `readableInputs`. +`proposals.actions` is a read-only inventory of each visible Proposal grant: its `actionId`, `accessProfile`, `party` when the grant is bound to one, `operations`, `readableInputs` and `writableInputs`. +A profile with an owner and a subject entry for one Action appears twice, once for each `party`. +`writableInputs` lists the inputs the grant may set through Start, Edit, Revise or Rebase. +It is the grant's own list, or every declared input when the grant names none, or an empty list for a grant that writes nothing. +A form built from it never offers an input the server will refuse. Rust exposes `proposal_actions()`, Node exposes `proposalActions`, and Python exposes `proposal_actions`, all from one validated client model. Profiles are never unioned. + +A Proposal Action's description carries `subject: {"input": ...}` when the Action declares a subject, so a form can label that field, and `writableInputs` for the selected profile. +A profile that can read a Proposal but not start its Action receives a description without routes and with no writable inputs. +Its `resultEffects` list the effects on Record types that profile can see in the same metadata document. +An effect on any other Record type is omitted. Start does not imply Get, and List or Apply can be advertised without a Start route. Hosts can use the exact inventory to choose their UI, while per-Proposal links still determine currently available lifecycle operations. diff --git a/docs/site/src/content/docs/reference/coordinator-configuration.mdx b/docs/site/src/content/docs/reference/coordinator-configuration.mdx index f403e02dc5..4c862ab3a5 100644 --- a/docs/site/src/content/docs/reference/coordinator-configuration.mdx +++ b/docs/site/src/content/docs/reference/coordinator-configuration.mdx @@ -120,7 +120,7 @@ Keep a task-bound record-read connection separate when a workflow needs both aut The Proposal operations use the same connection type. In the BReg project, grant the connection's profile `get` on every Action the workflow follows, under `permissions.proposals`. -Where the workflow starts or submits requests itself, also grant `start` on the Action under `permissions.actions`, and `cancel`, plus `submit` when the workflow submits, under `permissions.proposals` with `ownership: caller`. +Where the workflow starts or submits requests itself, also grant `start` on the Action under `permissions.actions`, and `cancel`, plus `submit` when the workflow submits, under `permissions.proposals` with `party: owner`. Leave `writableInputs` off that Proposal grant, or list every input the workflow sends: with the list, Start refuses a value for any other input. Never grant `apply`, because no Coordinator operation applies a Proposal. Two optional members serve Proposal waits: diff --git a/docs/site/src/content/docs/reference/messaging-configuration.mdx b/docs/site/src/content/docs/reference/messaging-configuration.mdx index ea63e0f0f5..9fc0049693 100644 --- a/docs/site/src/content/docs/reference/messaging-configuration.mdx +++ b/docs/site/src/content/docs/reference/messaging-configuration.mdx @@ -149,7 +149,7 @@ The metrics are Prometheus text, and every label is closed: | `messaging_provider_callbacks_total` | counter | `outcome` | | `messaging_provider_attempts_total` | counter | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent` | | `messaging_limit_refusals_total` | counter | `limit`: `rate`, `daily`, `pacing`, `callback` | -| `messaging_request_refusals_total` | counter | `check`: the closed set of 45 failed checks, every value published at zero | +| `messaging_request_refusals_total` | counter | `check`: the closed set of 46 failed checks, every value published at zero | | `messaging_retention_runs_total` | counter | `outcome`: `erased`, `idle`, `failed` | | `messaging_dispatch_jobs` | gauge | `state`: `pending`, `leased`, `unknown` | diff --git a/docs/site/src/content/docs/security/breg.mdx b/docs/site/src/content/docs/security/breg.mdx index 35a91dfa59..c90a74ae76 100644 --- a/docs/site/src/content/docs/security/breg.mdx +++ b/docs/site/src/content/docs/security/breg.mdx @@ -14,7 +14,7 @@ standards_referenced: [] This page states what the Base Registry Engine (BReg) security invariants assume, what you must do for them to hold, and which limits a deployment accepts. The operator obligations are numbered 1 to 22, and each accepted residual risk carries a stable -identifier from `BREG-RES-01` to `BREG-RES-27`. +identifier from `BREG-RES-01` to `BREG-RES-28`. The invariants themselves, each with its threat, enforcement point, refusal, and negative test, are the rows of the machine-checked BReg security invariant matrix in the registry-stack repository. This page does not repeat those rows; it names them by identifier (`BREG-SEC-NN`). @@ -152,6 +152,32 @@ It grants no approval or application authority. applicant_progress_rechecks_withdrawal_and_audit_before_release; crates/registry-breg/src/contract.rs, readable_review_progress. */} +### Proposal parties + +A Proposal grant bound to a party admits only that party of each Proposal (`BREG-SEC-265`, +`BREG-SEC-266`). +The owner is matched by the stored reference of the issuer and principal that filed it. +The subject is bound once, at the first Submit, from the input the Action declares. +It is matched when the caller's verified principal equals that value. +BReg chooses the governing entry per Proposal, owner first, and the Proposal transaction checks +the chosen party again. +Only a verified person acting for themselves is matched as a subject (`BREG-SEC-270`). +A self-service Submit that names someone else is refused unless the grant says +`submitsFor: anyone` (`BREG-SEC-267`), and a bound subject cannot be moved (`BREG-SEC-268`, +`BREG-SEC-269`). +A subject entry cannot edit, submit, revise or apply (`BREG-SEC-271`), and it reads only the +attachments it names (`BREG-SEC-274`). +A Record field a subject is read from is authority: a bounded grant that could set it to anyone is +refused at compile time (`BREG-SEC-273`). +The stored subject reference is an unkeyed hash used only for matching. +It is never served, logged or exported. +Audit records a keyed pseudonym in its place (`BREG-SEC-272`). + +{/* Evidence: crates/registry-breg/tests/postgres_proposal_subject.rs; + crates/registry-breg/tests/proposal_party_compiler.rs; + crates/registry-breg/tests/support/proposal_review_asks.rs, + matching_an_action_input_does_not_make_a_caller_the_proposal_subject. */} + ### Caller authentication BReg matches the bearer token to an entry under `authentication.oidc.issuers`. @@ -216,13 +242,14 @@ A request batch audits both items as not available, and the metric still counts a_declared_unresolved_problem_logs_a_cause_only_when_a_404_does_not_match_it. */} BReg counts each request it refuses by the check that refused it, in `breg_request_refusals_total{check}` on the private metrics listener. -The `check` label is a closed set of 45 names, every one published at zero, and no caller value becomes a label. +The `check` label is a closed set of 46 names, every one published at zero, and no caller value becomes a label. Each refusal also writes one `request refused` log line with `failed_check` and the request's trace id when it has one, at most five lines per check per minute, with `suppressed` counting what a window held back. In production, a request that BReg answers `404 resource.not-found` because the caller may not see the target reads the same to the caller whatever the reason. The operator can tell the reasons apart: the counter holds the request under the rule that refused it, for example `scope`, `purpose`, `requester-client`, `row-boundary`, `task-grant-binding`, `disclosure` or `visibility`. A refused write the engine answers with `write.outside-boundary` counts under `row-boundary`. Once the route admits the caller, BReg counts a missing or inaccessible Proposal under `visibility`. A successful Proposal review-context batch answers `200` and each concealed item counts once. +An observed membership denial counts under `membership`, including when caller Apply returns the generic `412 precondition.failed`. A `412` for a stale version and a request for an unknown route are not counted. A failed field guard counts under `action-guard`, also when it answers the generic `412`. A refusal on the `scope` check also names the claim that carries scopes, the scope the operation needs and the access profile, each as the configuration or package declares it. @@ -238,7 +265,128 @@ The audit journal's `refusalReason` stays the three values it lists below. crates/registry-breg/tests/postgres_proposal_security.rs, proposal_target_refusals_are_identical_across_routes_and_postures; crates/registry-breg/tests/postgres_proposal.rs, review_context_projects_an_omitted_optional_input_as_null; - crates/registry-breg/src/mutation.rs, MutationError::failed_check. */} + crates/registry-breg/src/mutation.rs, MutationError::failed_check; + crates/registry-platform-authcommon/src/refusal.rs, FailedCheck::COUNT; + crates/registry-breg/tests/support/membership_write_journeys.rs, + membership_refusals_match_the_claim_boundary_answer_at_each_step, + proposal_membership_refusals_match_the_claim_boundary_answer, + membership_diagnostics_count_only_observed_denials. */} + +### Membership boundaries + +A membership boundary limits a grant to target keys for which the authenticated principal has an active membership Record. +Membership Records change through a Record write grant on the membership Record type, or through an Action or Proposal whose target grant covers it. +Treat any such grant as authority: it decides who holds the membership. +The selected profile also governs which fields the caller can see and which disclosure conditions apply. + +BReg checks current membership when it reads a Record or its history. +A Proposal's start and lifecycle grants can each limit their targets by membership, and each carries its own entries. +Bound both: a lifecycle grant without the entry admits its operations whatever the current membership for its targets. +BReg checks current target membership when it lists or reads Proposals and when it admits commands, answers, and attachments. +Review context and saved review documents also require current Record disclosure for the Records in the frozen context. + +Record writes, immediate Actions, and caller Apply hold shared locks on the memberships they rely on through the write transaction. +A write that moves a Record to another key must satisfy the applicable membership boundary for both keys. +If removal commits first, the write cannot use the revoked membership. +If the write has already locked the membership, removal waits. +Writers that keep taking shared locks on the same membership can delay its removal until the lock timeout, which then answers `503 service.unavailable`. +Submitting a Proposal does not reserve membership for later caller Apply. +Automatic Apply uses its own pinned system grant, so a member removed after Submit does not stop an automatic apply of that submission. +An idempotent replay of a Record write, Batch or Action rechecks current membership before it returns the stored answer. + +A membership source can itself be bounded by membership only one level deep. +The source it is bounded over must carry no membership entries and have no incoming read paths. +Claim boundaries and scopes on that source are allowed. +This is how a steward reaches an organisation's members through a separate stewardship source. +A profile bounded through a membership source cannot create that source's rows (`breg.access.membership-source-write`). +Nor can it write the key, principal or active field the check reads. +Writes that only remove authority stay admitted: a fixed `active: false`, a tombstone, or a field the check does not read. +Through the profile a membership bounds, a steward cannot appoint a steward or restore their own stewardship. +Through that profile, a member cannot reactivate or move their own membership either. +A grant bounded by claims on a membership source's own rows cannot set its key or principal (`breg.access.membership-source-key-write`). +Nor can one bounded by a membership entry off its key, and either can only deactivate an existing row. +Authority-bearing references on a membership source go through Actions whose reference target grants the author scopes. +An unrestricted administrator can also write them, and can still reactivate any row. +These rules hold per profile. +A person whose token also satisfies an administrator profile can use that profile's writes, so issue both to one person only by intent. +Each membership source keeps at most one active row per key and principal, so deactivating that row always ends the access it gave. +A boundary on the protected Record's own identifier bounds reads and Action or Proposal targets the plan only references. +A deactivated membership grants nothing on a read, list, write or Action target, including inside another source's check. +Operators remain responsible for who holds a write on a membership source through a separate administrator profile. + +{/* Evidence: crates/registry-breg/src/mutation/membership.rs, + MembershipLocks, RecordMembership; + crates/registry-breg/src/mutation/proposal.rs, + lock_apply_memberships; + crates/registry-breg/src/generated_ddl.rs, + the_membership_lock_helper_is_volatile_and_takes_for_share; + crates/registry-breg/tests/membership_authoring.rs, + production_admits_membership_on_proposal_start_and_lifecycle_targets; + crates/registry-breg/tests/postgres_membership_access.rs, + real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs; + crates/registry-breg/tests/postgres_proposal.rs, + proposal_list_correlates_membership_filtered_page_with_its_journal; + crates/registry-breg/tests/postgres_proposal_security.rs, + review_context_checks_each_frozen_membership_and_saved_document, + submitted_create_membership_controls_attachments_answers_and_commands; + crates/registry-breg/tests/support/membership_write_journeys.rs, + record_write_first_makes_the_removal_wait, record_removal_first_refuses_the_write, + action_write_first_makes_the_removal_wait, action_removal_first_refuses_the_write, + proposal_write_first_makes_the_removal_wait, proposal_removal_first_refuses_the_write, + proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted, + automatic_worker_keeps_system_authority_and_human_apply_has_a_source_lock, + a_removed_member_gets_a_strangers_answer_on_every_membership_path, + a_steward_cannot_reactivate_or_change_any_stewardship_or_membership_directly, + a_removed_member_cannot_replay_a_stored_record_write_or_batch, + two_concurrent_appointments_of_one_person_leave_one_live_row; + crates/registry-breg/src/membership.rs, validate_source_writes, index_statement; + crates/registry-breg/tests/steward_authoring.rs, + a_chain_of_two_membership_levels_stays_refused, + a_two_level_chain_through_an_action_target_is_refused, + a_member_cannot_write_the_fields_their_membership_probe_reads, + writes_that_only_remove_authority_stay_admitted, + a_claim_bounded_grant_cannot_set_a_sources_key_or_principal, + an_action_sets_a_key_only_through_a_bounded_reference, + the_identifier_field_cannot_bound_any_kind_of_write; + crates/registry-breg/tests/postgres_migration.rs, + duplicate_live_membership_rows_refuse_the_unique_index_by_name_until_repaired. */} + +### Membership-bound writes + +A membership-bound write uses the verified principal from the selected access profile and the active +membership rows for the configured source Record type. +When an open profile permits a membership-bound write, the project must bind the principal to `sub`. +The operator controls issuer and claim mapping, and the reviewed project defines which separately +authorized writes may change the source Records. +A caller's proposed target key does not supply membership authority. +The database policies and locks described here constrain requests through BReg. +The runtime database credential remains inside the trust boundary described above. + +For Record mutations, immediate Actions and caller Apply, the write transaction acquires source +membership locks before locking target rows. +It checks membership against the keys the operation uses, including proposed keys for a move. +A committed removal that wins the source lock is visible to the waiting writer. +A removal that loses the lock waits for the writer to settle. +Caller Apply checks current membership even after a Proposal has been submitted or approved. +The automatic Apply worker runs under its separate system authority. +A hook callback with a claim-bound or membership-bound target grant is refused. + +For a membership-bound immediate Action with S3 attachments, the runtime holds the write fences and +uses a separate session to commit staging metadata before the primary transaction uploads the bytes. +A membership denial before staging makes no storage call. +Reserve database capacity for one additional staging session per runtime pool using this path. +The shared-content attachment and history lock order remains an open invariant (`BREG-SEC-256`). + +{/* Evidence: crates/registry-breg/src/membership.rs, validate_write_admission; + crates/registry-breg/src/mutation/membership.rs, collect, acquire; + crates/registry-breg/src/mutation/action.rs, stage_membership_action_attachments, hook_target_authority; + crates/registry-breg/src/mutation/proposal.rs, lock_apply_memberships; + crates/registry-breg/tests/support/membership_write_journeys.rs, + record_removal_first_refuses_the_write, record_write_first_makes_the_removal_wait, + action_removal_first_refuses_the_write, proposal_removal_first_refuses_the_write, + proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted, + automatic_worker_keeps_system_authority_and_human_apply_has_a_source_lock, + a_membership_refusal_leaves_s3_staging_unchanged. */} ### Public check export @@ -336,7 +484,8 @@ identifier, the Proposal identifier and the submission version. The member discloses a Proposal identifier only under Proposal read authorization. BReg resolves the link from the Proposal's stored application results, then keeps it only when the selected access profile could read that Proposal: the same grant, ownership and row-boundary check a -Proposal read applies, run by the same code. +Proposal read applies, including current target membership. +When membership fails, BReg can still return the revision under the separate history grant. A profile that reads the Record's history but holds no `get` grant on the Proposal, a caller who does not own a caller-owned Proposal, a caller whose row boundaries exclude a target, a caller under a task grant and a standing agent all receive the revision without the member. @@ -382,6 +531,7 @@ The link has these known limits: record_history_omits_the_proposal_from_a_profile_without_a_proposal_grant, record_history_omits_the_proposal_when_ownership_does_not_match, record_history_omits_the_proposal_outside_the_proposal_row_boundary, + record_history_rechecks_proposal_membership_without_hiding_the_revision, record_history_never_names_the_proposal_to_a_task_grant_caller, record_history_never_names_the_proposal_to_a_standing_agent, record_history_reads_the_link_while_another_session_locks_the_proposal_row, @@ -724,8 +874,14 @@ and its ancestors. Deny other write access in every posture and group write acce It does not prove that a real identity satisfies a profile's claims and row bounds. A Proposal grant without `writableInputs` leaves every declared Action input writable; name the inputs on every grant that is not meant to set all of them. - A Proposal grant's `ownership: caller` restricts which Proposal documents the caller may touch, + A Proposal grant's `party` restricts which Proposal documents the caller may touch, not the target Records, which stay bounded by the grant's `rowBoundaries`. + Say `submitsFor: anyone` only on profiles whose holders are trusted to file for others, such as + a counter desk. + Admit to a profile with a `party: subject` entry only issuers whose tokens carry a principal the + person cannot choose (`BREG-RES-28`). + Grant unrestricted writes to a field a Proposal subject is read from only to staff who may decide + who a Record is about (`BREG-SEC-273`). Enable `readableReviewProgress` only on the applicant grants intended to receive it. Choose public stage codes at the review provider with the applicant audience in mind. A change in code presence can reveal a transition, so assign the same coarse code across stages @@ -733,7 +889,7 @@ and its ancestors. Deny other write access in every posture and group write acce [Configure Proposals](../../configure/breg-proposals/#limit-the-inputs-a-profile-writes) shows the grant settings. {/* Evidence: crates/registry-breg/src/contract.rs, writable_inputs, readable_review_progress, - ProposalOwnership; crates/registry-breg/tests/postgres_proposal.rs, + ProposalParty; crates/registry-breg/tests/postgres_proposal.rs, standing_officer_grant_revises_only_named_inputs_and_withdraws_exact_review; crates/registry-breg/tests/postgres_proposal_security.rs, applicant_progress_rechecks_withdrawal_and_audit_before_release. */} @@ -1418,6 +1574,29 @@ Each lists the condition, the consequence, the mitigation, and the related matri crates/registry-breg/tests/disclosure_compile.rs, a_record_condition_that_binds_a_refresh_profile_is_a_finding. */} +### `BREG-RES-28`: the subject is who the filer and the issuer say it is + +- Condition: a profile says `submitsFor: anyone`, or a profile with a `party: subject` entry admits + more than one issuer. +- Consequence: BReg does not check that a filer had the right to act for the person a Proposal + names. + A holder of a `submitsFor: anyone` grant can open a Proposal's status and answers to any person + they name. + No issuer takes part in a subject match, so any admitted issuer whose token carries the bound + principal reaches the Proposal as its subject. + Every caller is matched against the same stored value, so two issuers that fill the principal + claim from different identifier spaces, such as a national identifier and an account number, can + produce one value for two people. +- Mitigation: grant `submitsFor: anyone` only to staff profiles. + Admit to profiles with subject entries only issuers whose principal claim draws from one + identifier space. + Limit `authentication.oidc.issuers..accessProfiles` so only issuers that assert a principal the + person cannot choose reach profiles with subject entries. +- Related: `BREG-SEC-267`, `BREG-SEC-270`. + +{/* Evidence: crates/registry-breg/tests/postgres_proposal_subject.rs, + submit_names_someone_else_only_under_submits_for_anyone. */} + ## Report a vulnerability Report a suspected vulnerability through the process in diff --git a/docs/site/src/content/docs/security/casework.mdx b/docs/site/src/content/docs/security/casework.mdx index aa90faadea..f701594265 100644 --- a/docs/site/src/content/docs/security/casework.mdx +++ b/docs/site/src/content/docs/security/casework.mdx @@ -204,7 +204,7 @@ grants in [Registry Casework task grants](../../reference/casework-task-grants/) - Casework counts every refused request by the check that refused it, in `casework_request_refusals_total{check}` on the private metrics listener ([metrics](../../operate/casework/#scrape-metrics-and-the-running-version)). - The `check` label is a closed set of 45 names, every one published at zero, and no caller value + The `check` label is a closed set of 46 names, every one published at zero, and no caller value becomes a label. Refusals the caller cannot tell apart are told apart there. A review or administration request refused for its role, its profile's stage eligibility, an diff --git a/docs/site/src/content/docs/security/coordinator.mdx b/docs/site/src/content/docs/security/coordinator.mdx index fc8dd41863..85ed3138a5 100644 --- a/docs/site/src/content/docs/security/coordinator.mdx +++ b/docs/site/src/content/docs/security/coordinator.mdx @@ -70,7 +70,7 @@ Deployment steps are in [Deploy Registry Coordinator](../../operate/coordinator/ The signed timestamp bounds how long a captured completion can be replayed. - Coordinator counts every refused request by the check that refused it, in `coordinator_request_refusals_total{check}` on the private metrics listener. - The `check` label is a closed set of 45 names, every one published at zero, and no caller value + The `check` label is a closed set of 46 names, every one published at zero, and no caller value becomes a label. The counter covers a refused credential, a policy denial after authentication, a refused signed event delivery or completion callback, an unavailable access-token verifier key source, and a diff --git a/docs/site/src/content/docs/security/documents.mdx b/docs/site/src/content/docs/security/documents.mdx index 9c19416504..d2cc74e5b5 100644 --- a/docs/site/src/content/docs/security/documents.mdx +++ b/docs/site/src/content/docs/security/documents.mdx @@ -52,7 +52,7 @@ and the restore drill is in Members it does not know, such as `x5c` or `ext`, are ignored. - The Document Store counts every refused request by the check that refused it, in `documents_request_refusals_total{check}` on the private metrics listener. - The `check` label is a closed set of 45 names such as `credential-missing`, `token-signature`, + The `check` label is a closed set of 46 names such as `credential-missing`, `token-signature`, `scope`, `actor-kind`, `access-profile`, `operation`, `ownership` and `visibility`, every one published at zero, and no caller value becomes a label. The counter covers a missing or refused credential, a token that resolves to no access profile, a diff --git a/docs/site/src/content/docs/security/evidence.mdx b/docs/site/src/content/docs/security/evidence.mdx index 32f996dfa1..f7cb680aeb 100644 --- a/docs/site/src/content/docs/security/evidence.mdx +++ b/docs/site/src/content/docs/security/evidence.mdx @@ -71,7 +71,7 @@ authorisation. Watch for them in operational logs and metrics instead. Evidence counts every refused request by the check that refused it, in `evidence_request_refusals_total{check}` on the private metrics listener. The `check` label is a -closed set of 45 names such as `credential-missing`, `token-signature`, `scope`, `access-profile`, +closed set of 46 names such as `credential-missing`, `token-signature`, `scope`, `access-profile`, `purpose`, `revision-pin` and `rate-limit`, every one published at zero, and no caller value becomes a label. An issuer key set that cannot be reached answers `503`, and counts under `key-source-unavailable`. Each refusal also writes one `request refused` log line with diff --git a/docs/site/src/content/docs/security/index.mdx b/docs/site/src/content/docs/security/index.mdx index 0531f1a1a7..a6613c326e 100644 --- a/docs/site/src/content/docs/security/index.mdx +++ b/docs/site/src/content/docs/security/index.mdx @@ -222,7 +222,7 @@ Registry Evidence is stricter. It accepts only a declared `uri` key source, and ## Refused requests Services that use the shared refusal recorder count the checks they record in -`_request_refusals_total{check}`. Its 45 check labels start at zero. +`_request_refusals_total{check}`. Its 46 check labels start at zero. The recorder emits `request refused` logs with `failed_check` and no caller values. It writes at most five such lines per check per minute. In production, refusals that look the same to the caller can count under different checks. diff --git a/docs/site/src/content/docs/security/messaging.mdx b/docs/site/src/content/docs/security/messaging.mdx index 51efccdc56..d65e635a4a 100644 --- a/docs/site/src/content/docs/security/messaging.mdx +++ b/docs/site/src/content/docs/security/messaging.mdx @@ -58,7 +58,7 @@ fetched, read or used, is `503 service.unavailable` with `Retry-After: 5`; the c is wrong, so a caller should retry rather than rotate it. Messaging counts every refused request by the check that refused it, in `messaging_request_refusals_total{check}` on the private metrics listener. The `check` label is a -closed set of 45 names such as `token-signature`, `scope`, `actor-kind`, `access-profile`, +closed set of 46 names such as `token-signature`, `scope`, `actor-kind`, `access-profile`, `delivery-signature` and `visibility`, every one published at zero, and no caller value becomes a label. A verifier that cannot reach its key source counts under `key-source-unavailable`. Each refusal also writes one `request refused` log line with `failed_check` and the request's trace id diff --git a/docs/site/src/content/docs/security/render.mdx b/docs/site/src/content/docs/security/render.mdx index 02583d2d35..33f64cf063 100644 --- a/docs/site/src/content/docs/security/render.mdx +++ b/docs/site/src/content/docs/security/render.mdx @@ -257,7 +257,7 @@ returns 503. See [Diagnose a refused call](../../operate/advanced/connect-an-oid Render counts every refused request by the check that refused it, in `render_request_refusals_total{check}`. The series is served on the private metrics listener when `metricsListener` is set. Without it the counter still counts and the log line is the only signal. -The `check` label is a closed set of 45 names, every one published at zero, and no caller value +The `check` label is a closed set of 46 names, every one published at zero, and no caller value becomes a label. The counter covers a missing or malformed credential, a shared API key mismatch, a token the verifier refuses, a key source Render cannot reach or use, a missing scope, the shared key presented to the seal diff --git a/docs/site/src/content/docs/security/scheduling.mdx b/docs/site/src/content/docs/security/scheduling.mdx index ee594067b7..b1356f29cf 100644 --- a/docs/site/src/content/docs/security/scheduling.mdx +++ b/docs/site/src/content/docs/security/scheduling.mdx @@ -64,7 +64,7 @@ callers holding bearer tokens from a configured issuer. - The operator's view of a refusal: Scheduling counts every refused request by the check that refused it, in `scheduling_request_refusals_total{check}` on the private metrics listener ([metrics](../../operate/scheduling/#watch-the-metrics)). - The `check` label is a closed set of 45 names, every one published at zero, and no caller value + The `check` label is a closed set of 46 names, every one published at zero, and no caller value becomes a label. An answer replayed from a stored receipt is not counted again. Each refusal also writes one `request refused` log line with `failed_check` and the request's diff --git a/docs/site/src/data/breg-api.yaml b/docs/site/src/data/breg-api.yaml index 4b2669f88d..ea41c80c01 100644 --- a/docs/site/src/data/breg-api.yaml +++ b/docs/site/src/data/breg-api.yaml @@ -99,6 +99,8 @@ - ['`write.outside-boundary`', '403', 'A direct Create, direct Batch item, or Patch of a visible Record would put the resulting Record outside the selected access profile''s row boundary, or would leave a Record that a `record` disclosure condition then withholds from that profile. This code also covers a row-boundary refusal for a request-only immediate Action Create or the resulting row of a Patch admitted by Proposal Apply. An immediate Action, or a Proposal applied by hand, is refused the same way when its plan creates or patches a Record that a `record` disclosure condition binding the applying profile would then withhold from it. A Patch, Batch item, immediate Action or Proposal applied by hand is also refused when a disclosure condition that binds the applying profile matches the Record and the write names one of its withheld fields or would lift the mark. The response has no field, value, claim, or location extension, and no item commits.'] - ['`proposal.rejected`', '409', 'A Review rejected the Proposal, and a rejection is final: Submit, Edit, Add, Answer, Revise, Rebase, Apply, Retry and Cancel are refused. Start a new Proposal to try again.'] - ['`proposal.review-result-mismatch`', '412', 'The current Review result differs from the retained approval. Apply commits no effects. Reconcile the review result before attempting application again.'] + - ['`proposal.subject-not-caller`', '403', 'Submit names someone other than the submitter as the person the Proposal is about, and the submitting grant does not say `submitsFor: anyone`. The draft stays unbound.'] + - ['`proposal.subject-changed`', '409', 'A later Submit read a different subject from the Record the Action names than the one bound at the first Submit. Cancel the Proposal and file a new one.'] - ['`proposal.submission-expired`', '410', 'The submission''s review result window has lapsed or its detail was erased, and it has no application receipt. The Proposal itself stays readable.'] - ['`mutation.conflict`', '409', 'A constraint or workflow rule refused the write. A storage-pattern failure includes the declared `recordType` and `fieldId`; correct the input before retrying. A 409 does not imply that retrying an unchanged request can succeed.'] - ['`idempotency.key-reused`', '409', 'The caller reused the `Idempotency-Key` with a different request, another write included, or retried a key whose held response a retention erase removed. A byte-identical body also conflicts when the first attempt committed under a different package activation, access profile, or claims.'] diff --git a/products/adapter/examples/kobotoolbox-breg/registry.yaml b/products/adapter/examples/kobotoolbox-breg/registry.yaml index 4ad091a02f..34a9bb05bc 100644 --- a/products/adapter/examples/kobotoolbox-breg/registry.yaml +++ b/products/adapter/examples/kobotoolbox-breg/registry.yaml @@ -105,7 +105,7 @@ accessProfiles: proposals: - action: register-household operations: [get, submit] - ownership: caller + party: owner targets: - recordType: household rowBoundaries: diff --git a/products/adapter/examples/qfield-postgis/registry/registry.yaml b/products/adapter/examples/qfield-postgis/registry/registry.yaml index cb2b1b47db..2d98cee0b9 100644 --- a/products/adapter/examples/qfield-postgis/registry/registry.yaml +++ b/products/adapter/examples/qfield-postgis/registry/registry.yaml @@ -174,7 +174,7 @@ accessProfiles: - action: propose-site operations: [get, submit] readableInputs: [source-submission-id, site-name, position, boundary, contacts] - ownership: caller + party: owner targets: - recordType: field-site rowBoundaries: diff --git a/products/breg/AGENTS.md b/products/breg/AGENTS.md index 78f5fb1a10..c126354d2e 100644 --- a/products/breg/AGENTS.md +++ b/products/breg/AGENTS.md @@ -47,11 +47,15 @@ the old spelling. compound identifiers, concrete entity, route, and Rust-type names such as `group-membership` or `GroupMembership`, from `registry-breg`, `registry-bregctl`, and `registry-breg-client` production source. It does not -forbid the bare words `membership` or `memberships`: `membershipBoundaries` is -a generic, configured read-boundary mechanism, a one-hop join predicate over a -configured entity, key field, principal field, and active flag, restricted to -`get`, `lookup`, `list`, `revisions`, and `snapshot`, with at most eight -boundaries per access profile (`crates/registry-breg/src/membership.rs`, +forbid the bare words `membership` or `memberships`. A Record type declares +its membership key, principal and active fields under `membership`. A +`rowBoundaries` entry can require current membership through a stored +reference or the Record's own `id`. The compiled predicate bounds reads, +Record Create, Patch, Tombstone and Batch, and immediate Action and Proposal +targets, with at most eight membership entries per grant. A membership source +can itself be bounded one level deep, over a different source that has no +membership entries. A profile bounded through a source cannot write the +fields its probe reads (`crates/registry-breg/src/membership.rs`, `crates/registry-breg/src/contract.rs`). Domain-specific compounds such as `group-membership` remain forbidden. Changing the blocklist is a boundary decision: record it in this file. diff --git a/products/breg/CHANGELOG.md b/products/breg/CHANGELOG.md index eb6ab7a664..a032db6ec6 100644 --- a/products/breg/CHANGELOG.md +++ b/products/breg/CHANGELOG.md @@ -64,6 +64,27 @@ per source file. A sealed source file that mixes the historical and current spellings, or declares both for one key, is refused as `breg.package.integrity-refused`, because no release writes one. +- BREAKING: A Proposal grant names the party it is bound to with `party: owner`, which replaces `ownership: caller`. `bregctl check` refuses the old key with `config.removed-key` and names the replacement. Packages built by an earlier release still load as predecessors with the same meaning. Migration: replace `ownership: caller` with `party: owner` in every `permissions.proposals` entry, then build a successor package. +- A Proposal's subject, the person it is about, follows it when someone else filed it. An Action names the subject's input with `execution.proposal.subject: {input}`, or `{input, field}` to read it from the referenced Record. BReg binds it at the first Submit and refuses a later change (`400 request.invalid`, or `409 proposal.subject-changed` for the field form). A `party: subject` grant admits a verified person whose principal equals the bound value, with `get`, `list`, `get-review-status`, `answer`, `add` and `cancel` only. Submit refuses a subject other than the submitter with `403 proposal.subject-not-caller` unless the grant says `submitsFor: anyone`. The Proposal document carries `partyRole`, List returns both parties' Proposals, and audit records a keyed subject pseudonym on the binding Submit and `partyRole` on later requests. New diagnostics: `breg.proposal.subject-undeclared`, `breg.proposal.subject-input-unknown`, `breg.proposal.subject-input-type`, `breg.proposal.subject-input-optional`, `breg.proposal.subject-field-type`, `breg.proposal.subject-operation-forbidden`, `breg.proposal.submits-for-invalid` and `breg.access.open-subject-principal-not-sub`. Proposals submitted before their Action declared a subject have none until they are rebased and submitted again. +- A Record field a Proposal subject is read from is authority. A direct write grant, an immediate Action grant, or a grant for a Proposal Action applied automatically without required review, whose row boundaries let the writer name anyone in that field, is refused with `breg.proposal.subject-field-write`. Unrestricted grants, grants bounded on the field by their own principal claim, and reviewed or manually applied Proposal Actions stay admitted. Erasing a Proposal's detail also erases its stored subject. +- BREAKING: the Proposal state store keeps the bound subject's reference in its own column with a partial index, and the managed schema fingerprint changes with them. Migration: build and apply a successor package with this release. Its activation adds the column and index in place and keeps every Proposal, each with no subject until it is submitted again. +- `GET /v1/metadata` serves one `proposals.actions` entry for each Proposal grant, with its `party` when the grant is bound to one, and `writableInputs`: the grant's list, every declared input when the grant names none, and an empty list when the grant writes nothing. A Proposal Action's description names `subject: {input}` and the selected profile's `writableInputs`. The Rust, Node and Python clients expose `party`, `writableInputs`, `subjectInput` and the Proposal's `partyRole`. +- A profile that can read a Proposal but not start its Action keeps the Action's `resultEffects` on Record types it can see in the same metadata document; effects on other Record types stay omitted. +- Record Create, Patch, Tombstone, and Batch grants and immediate Action targets accept membership entries. A bounded write commits only while an active membership names the caller for each required key. A lock timeout returns `503 service.unavailable`. A writer may acquire a shared membership lock while a removal waits. +- BREAKING: Generate a unique partial index over the key and principal of active membership records, so a membership source holds at most one active row per key and principal and deactivating that row always ends the access it gave. A successor package builds it for existing membership declarations. Migration: before upgrading, deactivate or tombstone all but one active row for each key and principal in every membership source. Activation refuses with `breg.membership.duplicate-live-rows`, positioned on the source, until they are repaired. +- An idempotent replay of a Record write or Batch rechecks current membership for each written row. A member removed since the original request gets `412 precondition.failed`, not the stored response. +- Action availability answers for targets bounded by the record's own `id`. +- Grant the runtime role column-level row-lock privilege only where a compiled write grant needs to lock membership records and table-level update privilege is absent. A successor package reconciles the grant. +- BREAKING: Declare membership fields once on the membership Record type and use membership entries in `rowBoundaries`. Migration: Add `membership: {key, principal, active}` to the membership Record type and replace each authored `membershipBoundaries` entry with `{field, membership}` in `rowBoundaries`. The AccessExplanation schema accepts an empty claim array only when membership boundaries are present. +- Check membership and open-profile write admission with `breg.access.membership-import-unsupported`, `breg.access.membership-access-requirement-unsupported`, `breg.access.membership-hook-unsupported`, `breg.access.membership-timer-unsupported`, `breg.access.open-write-without-principal-boundary`, `breg.access.scopeless-membership-source-write`, and `breg.access.open-membership-principal-not-sub`. +- Proposal Start and lifecycle target grants accept membership entries in `rowBoundaries`. Caller Apply holds shared membership locks through the write. Proposal reads and lifecycle operations check current membership for the targets they authorize. +- A membership entry may name the protected Record type's own `id` when the membership key references that Record type. It bounds reads and Action or Proposal targets the plan only references. A write bounded by `id` is refused with `breg.access.membership-key-type`. +- BREAKING: A profile that a membership source bounds can no longer create that source's rows or write its key, principal or active field, unless the write carries a membership entry on the source's key over a different source, whether the project or a module declares the profile, refused with `breg.access.membership-source-write`. Writes that only remove authority (a fixed `active: false`, a tombstone, or a field the probe does not read) stay admitted. A membership source also cannot require consent from a consent record that membership bounds, refused with `breg.access.membership-source-recursive`. Migration: move the membership writes of a profile that is also bounded by that membership into a separate administrator profile, and select it for those writes. +- A Record type that declares membership may carry membership entries over a different membership source that has none of its own and no incoming read paths. Self-reference and longer chains stay refused with `breg.access.membership-source-recursive`. +- Add the organisation stewardship example: stewards manage an organisation's members through two Actions, bounded by a stewardship record that a registrar names and ends through jurisdiction-scoped Actions, which also register facilities and rename organisations. +- BREAKING: A grant bounded on a membership source's own rows, by claims or by a membership entry on a field other than the key, can no longer set that source's key or principal, and on an existing row can only set `active` to `false`. This covers Create, Batch, Import, Patch, and Action, Proposal and function-plan writes, refused with `breg.access.membership-source-key-write`. Unrestricted grants and grants bounded on the key are unaffected. Migration: set the key through an Action whose reference input targets the key's Record type under a target grant you scope, as the organisation stewardship example's `name-steward` does, or make the administrator's grant unrestricted. +- `tests/journeys.yaml` steps invoke a `concurrency: current-revision` Action without `preconditions`, as its HTTP contract requires. +- Observed membership refusals count under `membership` in `breg_request_refusals_total{check}` and in the refusal log. Generic precondition responses retain their existing body in both postures. ## 0.49.0 - 2026-12-01 diff --git a/products/breg/acceptance/asset-site-placement/registry.yaml b/products/breg/acceptance/asset-site-placement/registry.yaml index 2baf9236d3..967290ec15 100644 --- a/products/breg/acceptance/asset-site-placement/registry.yaml +++ b/products/breg/acceptance/asset-site-placement/registry.yaml @@ -217,7 +217,7 @@ "asset-operator": { "default": true, "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["asset:manage"], "requiredPurposes": [ "asset-management" ], @@ -308,7 +308,7 @@ }, "site-planner": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["asset:plan"], "requiredPurposes": [ "site-planning" ], diff --git a/products/breg/acceptance/asset-site-placement/tests/journeys.yaml b/products/breg/acceptance/asset-site-placement/tests/journeys.yaml index 66f0278fee..bab216c386 100644 --- a/products/breg/acceptance/asset-site-placement/tests/journeys.yaml +++ b/products/breg/acceptance/asset-site-placement/tests/journeys.yaml @@ -8,6 +8,7 @@ journeys: accessProfile: asset-operator claims: principal: synthetic-asset-operator + scopes: [asset:manage] purpose: asset-management request: type: create @@ -28,6 +29,7 @@ journeys: accessProfile: site-planner claims: principal: synthetic-site-planner + scopes: [asset:plan] purpose: site-planning request: type: get @@ -43,6 +45,7 @@ journeys: accessProfile: site-planner claims: principal: synthetic-site-planner + scopes: [asset:plan] purpose: site-planning request: type: list @@ -55,6 +58,7 @@ journeys: accessProfile: asset-operator claims: principal: synthetic-asset-operator + scopes: [asset:manage] purpose: asset-management request: type: patch @@ -76,6 +80,7 @@ journeys: accessProfile: asset-operator claims: principal: synthetic-asset-operator + scopes: [asset:manage] purpose: asset-management request: type: create @@ -94,6 +99,7 @@ journeys: accessProfile: site-planner claims: principal: synthetic-site-planner + scopes: [asset:plan] purpose: site-planning request: type: get @@ -109,6 +115,7 @@ journeys: accessProfile: site-planner claims: principal: synthetic-site-planner + scopes: [asset:plan] purpose: site-planning request: type: list @@ -121,6 +128,7 @@ journeys: accessProfile: site-planner claims: principal: synthetic-site-planner + scopes: [asset:plan] request: type: get recordCapture: renamed-asset diff --git a/products/breg/acceptance/business/registry.yaml b/products/breg/acceptance/business/registry.yaml index 8bfed90cba..8ff377c63a 100644 --- a/products/breg/acceptance/business/registry.yaml +++ b/products/breg/acceptance/business/registry.yaml @@ -423,7 +423,7 @@ }, "business-registrar": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["business:register"], "requiredPurposes": [ "business-registry" ], diff --git a/products/breg/acceptance/business/tests/journeys.yaml b/products/breg/acceptance/business/tests/journeys.yaml index 1580cd97b2..b9bf555b55 100644 --- a/products/breg/acceptance/business/tests/journeys.yaml +++ b/products/breg/acceptance/business/tests/journeys.yaml @@ -8,6 +8,7 @@ journeys: accessProfile: business-registrar claims: principal: synthetic-business-registrar + scopes: [business:register] purpose: business-registry request: type: create @@ -67,6 +68,7 @@ journeys: accessProfile: business-registrar claims: principal: synthetic-business-registrar + scopes: [business:register] purpose: business-registry request: type: patch @@ -105,6 +107,7 @@ journeys: accessProfile: business-registrar claims: principal: synthetic-business-registrar + scopes: [business:register] request: type: get recordCapture: suspended-business diff --git a/products/breg/acceptance/facility/registry.yaml b/products/breg/acceptance/facility/registry.yaml index 662b706221..594410fba6 100644 --- a/products/breg/acceptance/facility/registry.yaml +++ b/products/breg/acceptance/facility/registry.yaml @@ -413,7 +413,7 @@ "accessProfiles": { "facility-operator": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["registry:facility:operate"], "requiredPurposes": [ "facility-registry" ], diff --git a/products/breg/acceptance/facility/tests/journeys.yaml b/products/breg/acceptance/facility/tests/journeys.yaml index 35ceeab737..ebcda2e4a8 100644 --- a/products/breg/acceptance/facility/tests/journeys.yaml +++ b/products/breg/acceptance/facility/tests/journeys.yaml @@ -9,8 +9,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [north-district] request: @@ -33,8 +33,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [north-district] request: @@ -52,8 +52,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [north-district] request: @@ -77,8 +77,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [north-district] request: @@ -93,8 +93,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [south-district] request: @@ -110,8 +110,8 @@ journeys: accessProfile: facility-operator claims: principal: synthetic-facility-operator + scopes: [registry:facility:operate] purpose: facility-registry - scopes: [] directClaims: administrative_boundaries: [north-district] request: diff --git a/products/breg/acceptance/generated-identifiers/registry.yaml b/products/breg/acceptance/generated-identifiers/registry.yaml index 78a34c16b3..24c0c3f523 100644 --- a/products/breg/acceptance/generated-identifiers/registry.yaml +++ b/products/breg/acceptance/generated-identifiers/registry.yaml @@ -84,7 +84,7 @@ accessProfiles: - action: register-application operations: [get, list, edit, submit, cancel] readableInputs: [jurisdiction, applicant] - ownership: caller + party: owner targets: - recordType: application rowBoundaries: diff --git a/products/breg/acceptance/inspection/registry.yaml b/products/breg/acceptance/inspection/registry.yaml index 8a44e04414..b0d643417f 100644 --- a/products/breg/acceptance/inspection/registry.yaml +++ b/products/breg/acceptance/inspection/registry.yaml @@ -310,7 +310,7 @@ "accessProfiles": { "inspection-inspector": { "principalClaim": "registry_principal", - "requiredScopes": "unrestricted", + "requiredScopes": ["inspection:manage"], "requiredPurposes": [ "facility-inspection" ], diff --git a/products/breg/acceptance/inspection/tests/journeys.yaml b/products/breg/acceptance/inspection/tests/journeys.yaml index eb83747fca..8afba387f4 100644 --- a/products/breg/acceptance/inspection/tests/journeys.yaml +++ b/products/breg/acceptance/inspection/tests/journeys.yaml @@ -8,6 +8,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] purpose: facility-inspection request: type: create @@ -30,6 +31,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] purpose: facility-inspection request: type: patch @@ -51,6 +53,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] purpose: facility-inspection request: type: get @@ -66,6 +69,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] purpose: facility-inspection request: type: list @@ -78,6 +82,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] purpose: facility-inspection request: type: create @@ -100,6 +105,7 @@ journeys: accessProfile: inspection-inspector claims: principal: synthetic-inspection-inspector + scopes: [inspection:manage] request: type: get recordCapture: closed-inspection diff --git a/products/breg/acceptance/reviewed-evidence-journey/registry/registry.yaml b/products/breg/acceptance/reviewed-evidence-journey/registry/registry.yaml index 9ea8daf704..fc6c35686e 100644 --- a/products/breg/acceptance/reviewed-evidence-journey/registry/registry.yaml +++ b/products/breg/acceptance/reviewed-evidence-journey/registry/registry.yaml @@ -125,7 +125,7 @@ accessProfiles: - answer readableAttachments: [supporting] writableAttachments: [supporting] - ownership: caller + party: owner readableInputs: - record - status diff --git a/products/breg/contracts/explain/AccessExplanation.schema.json b/products/breg/contracts/explain/AccessExplanation.schema.json index c6b3057f19..2371cb0f54 100644 --- a/products/breg/contracts/explain/AccessExplanation.schema.json +++ b/products/breg/contracts/explain/AccessExplanation.schema.json @@ -82,7 +82,7 @@ }, "recordTypes": { "type": "array", - "description": "Per-Record type author inspection. Record grants explicitly report allowCount and render an empty compiled claim-bound row list as unrestricted. Other profile members follow the compiled AccessProfileSource.", + "description": "Per-Record type author inspection. Record grants explicitly report allowCount. A profile with membership and no claim boundaries reports an empty claim list. Other profile members follow the compiled AccessProfileSource.", "items": { "type": "object", "x-registry-passthrough": "EntityAccessExplanation retains compiled authority with inspection-only explicit defaults on its profiles.", @@ -99,44 +99,65 @@ "rowBoundaries", "allowCount" ], + "if": { + "required": [ + "membershipBoundaries" + ] + }, + "then": { + "properties": { + "membershipBoundaries": { + "$ref": "#/$defs/MembershipBoundaries" + }, + "rowBoundaries": { + "type": "array" + } + } + }, + "else": { + "properties": { + "rowBoundaries": { + "oneOf": [ + { + "const": "unrestricted" + }, + { + "type": "array", + "minItems": 1 + } + ] + } + } + }, "properties": { "id": { "$ref": "#/$defs/LocalId" }, "rowBoundaries": { - "description": "Unrestricted means no claim-bound row restriction. Membership and consent boundaries, when present, still apply.", - "oneOf": [ - { - "const": "unrestricted" - }, - { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "additionalProperties": false, - "required": [ - "field", - "claim", - "operator" - ], - "properties": { - "field": { - "type": "string" - }, - "claim": { - "type": "string" - }, - "operator": { - "enum": [ - "equals", - "in" - ] - } - } + "description": "Unrestricted means neither claim nor membership boundaries are present. Consent conditions still apply.", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "field", + "claim", + "operator" + ], + "properties": { + "field": { + "type": "string" + }, + "claim": { + "type": "string" + }, + "operator": { + "enum": [ + "equals", + "in" + ] } } - ] + } }, "allowCount": { "type": "boolean" @@ -302,9 +323,12 @@ ], "x-registry-member-names": true }, + "membershipBoundaries": { + "$ref": "#/$defs/MembershipBoundaries" + }, "rowBoundaries": { "type": "array", - "x-registry-passthrough": "The inspector retains the compiler's boundary list exactly; an empty list is the compiled representation of unrestricted row reach." + "x-registry-passthrough": "The inspector retains the claim boundary list. Membership restrictions are carried in membershipBoundaries." } }, "x-registry-passthrough": "bregctl writes each row-reach explanation as the engine holds it; the target Record type, profile, source path, surface, and row boundaries are pinned. Other members follow RowReachExplanation." @@ -751,6 +775,28 @@ } ], "$defs": { + "MembershipBoundaries": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "field", + "membershipRecordType", + "membershipKeyField", + "principalField", + "activeField" + ], + "properties": { + "field": {"$ref": "#/$defs/LocalId"}, + "membershipRecordType": {"$ref": "#/$defs/LocalId"}, + "membershipKeyField": {"$ref": "#/$defs/LocalId"}, + "principalField": {"$ref": "#/$defs/LocalId"}, + "activeField": {"$ref": "#/$defs/LocalId"} + } + } + }, "LocalId": { "description": "A local identifier: a lowercase letter, then up to 63 lowercase letters, digits, `_`, or `-`.", "pattern": "^[a-z][a-z0-9_-]{0,63}$", diff --git a/products/breg/contracts/security-invariant-matrix.yaml b/products/breg/contracts/security-invariant-matrix.yaml index 8c1d58679d..152baee042 100644 --- a/products/breg/contracts/security-invariant-matrix.yaml +++ b/products/breg/contracts/security-invariant-matrix.yaml @@ -37,7 +37,7 @@ invariants: - {id: BREG-SEC-33, state: enforced, targetWave: W5, threat: "A request with an ambiguous profile selects broader authority implicitly.", enforcementPoint: "compiled optional route default and HTTP profile selection", refusal: "Require an explicit accessProfile when multiple profiles admit the caller and none is an admitting route default. Answer route-wide ambiguity with 400 access-profile.ambiguous and the admitting profile IDs before Record I/O.", negativeId: BREG-NEG-33, negativeTest: {path: crates/registry-breg/tests/http_auth.rs, name: an_ambiguous_route_answers_400_with_the_admitted_profile_ids}} - {id: BREG-SEC-34, state: enforced, targetWave: W5, threat: "Approval from another authority request policy subject proposal version submission or terminal status is substituted for the configured review result.", enforcementPoint: "frozen source policy selection checked by the Review client and submission worker; immutable accepted binding and exact result correlation before application", refusal: "Require the configured authority and policy ID; compare explicit bounded provider producer metadata before accepting the exact submission digest. An explicit disagreement is a distinct configuration failure and never proof that the remote mutation rolled back. ID-only selection delegates concrete version and digest to the provider at first durable acceptance throughout pending delivery and recovery (30 days by default; operator resubmit restarts the window); optional complete pins require an exact match before acceptance. Refuse mismatched acceptance without retaining a binding, preserve an existing exact acceptance across recovery, and require every retained request subject policy proposal submission and approved-status binding before application.", negativeId: BREG-NEG-34, negativeTest: {path: crates/registry-breg/tests/postgres_proposal_review_delivery.rs, name: first_acceptance_refuses_wrong_policy_id_or_exact_pin}} - {id: BREG-SEC-35, state: enforced, targetWave: W5, threat: A related-record acceptance decision races with a referenced record update or bypasses its declared processing authority., enforcementPoint: compiled action requirements and existing ordered target locks before effects, refusal: Refuse an unmet requirement without committing any action effects and preserve its original acceptance result on exact replay., negativeId: BREG-NEG-35, negativeTest: {path: crates/registry-breg/tests/postgres_immediate_action_requirements.rs, name: action_requirements_hold_reference_lock_against_concurrent_inactivation}} - - {id: BREG-SEC-36, state: enforced, targetWave: W5, threat: A revoked membership retains protected read access or a membership probe discloses its processing rows., enforcementPoint: compiled read-only membership boundaries and generated RLS helpers plus explicit historical predicates, refusal: Deny new protected reads after committed revocation and keep membership processing separate from record disclosure., negativeId: BREG-NEG-36, negativeTest: {path: crates/registry-breg/tests/postgres_membership_access.rs, name: real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs}} + - {id: BREG-SEC-36, state: enforced, targetWave: W5, threat: A revoked membership retains protected read access or a membership probe discloses its processing rows., enforcementPoint: compiled membership boundaries for reads and generated RLS helpers plus explicit historical predicates, refusal: Deny new protected reads after committed revocation and keep membership processing separate from record disclosure., negativeId: BREG-NEG-36, negativeTest: {path: crates/registry-breg/tests/postgres_membership_access.rs, name: real_postgres_membership_reads_recheck_live_membership_and_hide_processing_inputs}} - {id: BREG-SEC-37, state: enforced, targetWave: W5, threat: A computed action widens a compiled write slot or commits effects outside the caller authority and transaction boundary., enforcementPoint: compiled action candidate verification target contexts native RLS and atomic mutation evidence, refusal: Refuse undeclared effects or authority and recover the original committed receipt without rerunning the handler., negativeId: BREG-NEG-37, negativeTest: {path: crates/registry-breg/tests/postgres_action_handlers.rs, name: action_handlers_compute_refuse_retry_recover_and_preserve_compiled_authority}} - {id: BREG-SEC-38, state: enforced, targetWave: W5, threat: A handler leaks script values through a dynamic business refusal or mixes a refusal with writes., enforcementPoint: exclusive effects-or-refusal decoder and governed code label catalogue, refusal: Refuse unknown codes fields or output details and keep script errors value-free., negativeId: BREG-NEG-38, negativeTest: {path: crates/registry-breg/tests/immediate_action_handler.rs, name: handler_business_refusal_is_exclusive_bounded_and_governed}} - {id: BREG-SEC-39, state: enforced, targetWave: W5, threat: Stored field format integrity is bypassed or activation accepts violating existing rows., enforcementPoint: native PostgreSQL field checks and governed validated migration with retained maintenance recovery, refusal: Refuse invalid stored values and preserve exact-target recovery after a failed activation., negativeId: BREG-NEG-39, negativeTest: {path: crates/registry-breg/tests/postgres_migration.rs, name: native_patterns_validate_empty_tables_existing_rows_and_exact_target_recovery}} @@ -263,3 +263,31 @@ invariants: - {id: BREG-SEC-244, state: enforced, targetWave: W5, threat: "A signed hook is sent in plaintext to a non-loopback destination.", enforcementPoint: "BReg networkProfile decoding and shared destination policy construction before key resolution.", refusal: "Refuse non-loopback HTTP in both postures, including when the origin falls within allowedPrivateCidrs.", negativeId: BREG-NEG-244, negativeTest: {path: crates/registry-breg/tests/runtime_config.rs, name: event_destinations_refuse_non_loopback_plaintext_in_both_postures}} - {id: BREG-SEC-245, state: enforced, targetWave: W5, threat: "A field addition or reclassification widens a gated permission under the same consent scope.", enforcementPoint: "The compiler checks direct and read-path readableFields on every composed permission with requireConsent.", refusal: "Refuse a classification ceiling with breg.consent.readable-fields-explicit-required. Require explicit field lists on the gated permission.", negativeId: BREG-NEG-245, negativeTest: {path: crates/registry-breg/tests/consent_access.rs, name: a_consent_scope_requires_explicit_fields_on_direct_reads_and_read_paths}} - {id: BREG-SEC-246, state: enforced, targetWave: W5, threat: "An immediate Action create outside the caller's target row boundary answers in a way that depends on the Action's guards or on records the caller cannot read, turning the refusal into an oracle.", enforcementPoint: "The Action Invoke validates typed target boundary claims, then checks request-only Create candidates using caller inputs, Plan values and reserved identifiers before target reads, guards, Evidence acquisition or writes. Commit-only Evidence leaves the Plan request-only. Evidence preflight and finalization share the candidate and reserved identifiers.", refusal: "Refuse with the value-free 403 write.outside-boundary, the same for a passing guard, a failing guard the caller reads or cannot read, and a visible, hidden or missing target. A create that needs another effect's record, a boundary on a generated field, a timer firing and an Evidence-computed plan keep the generic 412 at the write.", negativeId: BREG-NEG-246, negativeTest: {path: crates/registry-breg/tests/postgres_immediate_actions.rs, name: an_action_create_outside_the_boundary_is_refused_before_targets_and_guards}} + - {"id": "BREG-SEC-247", "state": "enforced", "targetWave": "W5", "threat": "An unauthenticated or misbound caller gains a membership-mediated write.", "enforcementPoint": "Production project compilation checks the principal boundary of open membership-bounded writes.", "refusal": "Refuse open writes that do not bind the principal to sub.", "negativeId": "BREG-NEG-247", "negativeTest": {"path": "crates/registry-breg/tests/membership_authoring.rs", "name": "an_open_membership_target_requires_sub_even_for_immediate_invoke"}} + - {"id": "BREG-SEC-248", "state": "enforced", "targetWave": "W5", "threat": "A Record writer moves a Record to a key outside its membership.", "enforcementPoint": "The mutation transaction checks the existing row and proposed key under the selected profile, with generated Record RLS.", "refusal": "Refuse the move and preserve the existing Record.", "negativeId": "BREG-NEG-248", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_patch_moving_a_row_to_a_key_the_caller_is_not_a_member_of_is_refused"}} + - {"id": "BREG-SEC-249", "state": "enforced", "targetWave": "W5", "threat": "A writer commits on the strength of a membership already revoked by a concurrent transaction.", "enforcementPoint": "The write holds source membership row locks through settlement. A writer waiting behind removal checks the current source row.", "refusal": "Refuse the write when removal takes effect first.", "negativeId": "BREG-NEG-249", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "record_removal_first_refuses_the_write"}} + - {"id": "BREG-SEC-250", "state": "enforced", "targetWave": "W5", "threat": "The serving database role uses the privileges needed to lock membership rows to edit their authority data.", "enforcementPoint": "The generated membership lock helper and row policy permit the lock while normal update authority remains separate.", "refusal": "Allow the matching lock without allowing the same role and context to update the membership row.", "negativeId": "BREG-NEG-250", "negativeTest": {"path": "crates/registry-breg/tests/support/postgres_membership_writes.rs", "name": "the_runtime_role_can_lock_a_membership_row_it_cannot_update"}} + - {"id": "BREG-SEC-251", "state": "enforced", "targetWave": "W5", "threat": "An immediate Action changes the membership proof its own effects rely on.", "enforcementPoint": "The Action acquires the source locks, checks effects under the selected target grant and rechecks used authority after effect execution.", "refusal": "Refuse an Action that invalidates its own membership proof and roll back its effects.", "negativeId": "BREG-NEG-251", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "an_action_cannot_invalidate_its_own_membership_proof"}} + - {"id": "BREG-SEC-252", "state": "enforced", "targetWave": "W5", "threat": "An approved Proposal moves a Record to a key outside the applying caller's membership.", "enforcementPoint": "Caller Apply locks memberships for current and frozen proposed keys and checks the selected caller's target grant before effect settlement.", "refusal": "Refuse the key move if only the old key is admitted.", "negativeId": "BREG-NEG-252", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted"}} + - {"id": "BREG-SEC-253", "state": "enforced", "targetWave": "W5", "threat": "An immediate Action acquires external Evidence without a satisfiable membership-bound effect.", "enforcementPoint": "Evidence preflight checks membership feasibility under the selected Action grant before acquisition; the mutation transaction checks current authority independently.", "refusal": "Refuse an unsatisfiable Action before Evidence acquisition.", "negativeId": "BREG-NEG-253", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "evidence_admission_refuses_unsatisfiable_membership_and_replays_without_acquisition"}} + - {"id": "BREG-SEC-254", "state": "enforced", "targetWave": "W5", "threat": "A denied membership-bound Action stages file bytes or creates a Record attachment reference.", "enforcementPoint": "Immediate Action admission and transaction membership checks precede its S3 staging and primary attachment write.", "refusal": "A membership denial leaves staging, references and external storage calls unchanged.", "negativeId": "BREG-NEG-254", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_membership_refusal_leaves_s3_staging_unchanged"}} + - {"id": "BREG-SEC-255", "state": "enforced", "targetWave": "W5", "threat": "A Proposal hook callback uses a target grant for which it cannot supply a claim or membership boundary.", "enforcementPoint": "Hook target authority requires the reviewed profile's target grants to have neither boundary kind.", "refusal": "Refuse the bounded target grant through the existing hook authority rejection.", "negativeId": "BREG-NEG-255", "negativeTest": {"path": "crates/registry-breg/src/mutation/action.rs", "name": "hooks_refuse_claim_and_membership_boundaries_on_the_same_path"}} + - {"id": "BREG-SEC-256", "state": "planned", "targetWave": "W5", "threat": "An immediate Action and Proposal Apply wait on each other when storing shared attachment content.", "enforcementPoint": "Planned common order for immediate Action staging and attachment writes and Proposal Apply promotion before history allocation, with durable staging before external upload.", "refusal": "Require the shared-content order and bounded failure recovery to preserve transaction effects and replay before treating this invariant as enforced.", "negativeId": "BREG-NEG-256"} + - {"id": "BREG-SEC-257", "state": "enforced", "targetWave": "W5", "threat": "A membership source's own authority depends on another membership source that is itself bounded, or on itself, so a probe chain reaches past one level or loops.", "enforcementPoint": "Project compilation of membership declarations and of Record, Action and Proposal target entries.", "refusal": "Refuse with breg.access.membership-source-recursive unless the source is bounded only over a different leaf that has no membership entries and no incoming read paths.", "negativeId": "BREG-NEG-257", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_two_level_chain_through_an_action_target_is_refused"}} + - {"id": "BREG-SEC-258", "state": "enforced", "targetWave": "W5", "threat": "A membership boundary on the protected Record's own identifier authorizes a write whose key cannot be checked, or a key of another Record type.", "enforcementPoint": "Project compilation of membership entries decides the identifier field by type and by whether the grant writes the protected Record type.", "refusal": "Refuse with breg.access.membership-key-type unless the key references the protected Record type and the grant only reads it or references it as an Action or Proposal target.", "negativeId": "BREG-NEG-258", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "the_identifier_field_bounds_reads_and_referenced_targets_only"}} + - {"id": "BREG-SEC-259", "state": "enforced", "targetWave": "W5", "threat": "A member whose membership was deactivated keeps access through a read, a list, a direct create or patch, an Action target, or a probe nested in another source's policy.", "enforcementPoint": "Generated membership probes match only active rows with active lifecycle, and reads, lists, direct writes, Action targets and nested probes take their membership checks from them.", "refusal": "Answer the removed member exactly as a caller who never had a membership.", "negativeId": "BREG-NEG-259", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_removed_member_gets_a_strangers_answer_on_every_membership_path"}} + - {"id": "BREG-SEC-260", "state": "enforced", "targetWave": "W5", "threat": "A profile bounded through a membership source, whether the project or a module declares it, creates rows of that source or writes the fields its probe reads, and so promotes, restores or moves its own or another's authority.", "enforcementPoint": "Project compilation derives the probe fields from the membership declaration and checks every Record, Action, Proposal and function-plan write the bounded profile holds on that source.", "refusal": "Refuse with breg.access.membership-source-write unless the write carries a membership entry on the source's key over a different source, while admitting writes that only remove authority.", "negativeId": "BREG-NEG-260", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_member_cannot_write_the_fields_their_membership_probe_reads"}} + - {"id": "BREG-SEC-261", "state": "enforced", "targetWave": "W5", "threat": "Two active rows for one key and principal let a removal of one row leave access in place.", "enforcementPoint": "A generated unique partial index over the key and principal of active rows of every membership source, and a positioned refusal of a successor that meets existing duplicates.", "refusal": "Refuse the second active row with 409 and refuse activation with breg.membership.duplicate-live-rows until duplicates are repaired.", "negativeId": "BREG-NEG-261", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "two_concurrent_appointments_of_one_person_leave_one_live_row"}} + - {"id": "BREG-SEC-262", "state": "enforced", "targetWave": "W5", "threat": "A member removed after a Record write or Batch replays its idempotency key and receives the stored success.", "enforcementPoint": "The replay branch rechecks current membership for each written row before returning the stored response.", "refusal": "Answer 412 precondition.failed and leave durable state unchanged.", "negativeId": "BREG-NEG-262", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_removed_member_cannot_replay_a_stored_record_write_or_batch"}} + - {"id": "BREG-SEC-263", "state": "enforced", "targetWave": "W5", "threat": "A grant bounded only by claims on a membership source's own rows chooses who that row names, and for which key.", "enforcementPoint": "Project compilation of Record grants and of Action, Proposal and function-plan writes on membership sources, where a grant counts as key-bounded only through a membership entry on the source's key.", "refusal": "Refuse with breg.access.membership-source-key-write unless the key comes from an Action's reference input, or the grant is unrestricted or bounded on the key; on an existing row such a grant can only set active to false.", "negativeId": "BREG-NEG-263", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_claim_bounded_grant_cannot_set_a_sources_key_or_principal"}} + - {"id": "BREG-SEC-264", "state": "enforced", "targetWave": "W5", "threat": "A membership source requires consent from a consent record that membership bounds, so each probe needs the other.", "enforcementPoint": "Project compilation of membership declarations.", "refusal": "Refuse with breg.access.membership-source-recursive.", "negativeId": "BREG-NEG-264", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_membership_source_requiring_consent_read_through_itself_is_refused"}} + - {"id": "BREG-SEC-265", "state": "enforced", "targetWave": "W5", "threat": "A caller whose verified principal equals an ordinary Action input reads, lists or answers a Proposal someone else filed.", "enforcementPoint": "Proposal admission matches a party only by the stored owner reference or the bound subject reference, never by an input value.", "refusal": "Conceal with 404 resource.not-found and omit the Proposal from List.", "negativeId": "BREG-NEG-265", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_review_asks.rs", "name": "matching_an_action_input_does_not_make_a_caller_the_proposal_subject"}} + - {"id": "BREG-SEC-266", "state": "enforced", "targetWave": "W5", "threat": "A caller with the same profile as a Proposal's subject reads, lists or commands a Proposal filed about someone else.", "enforcementPoint": "The governing party entry is chosen per Proposal from the stored owner and subject references, and the Proposal transaction rechecks the chosen party.", "refusal": "Conceal Get and commands with 404 resource.not-found and omit the Proposal from List.", "negativeId": "BREG-NEG-266", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "a_citizen_follows_a_proposal_the_desk_filed_and_a_neighbour_sees_nothing"}} + - {"id": "BREG-SEC-267", "state": "enforced", "targetWave": "W5", "threat": "A self-service filer names another person as the subject and so hands that person's Proposal access to work they did not file, or files in someone else's name.", "enforcementPoint": "Submit compares the subject value with the submitter's verified principal unless the submitting grant says submitsFor: anyone.", "refusal": "Answer 403 proposal.subject-not-caller and leave the draft unbound.", "negativeId": "BREG-NEG-267", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "submit_names_someone_else_only_under_submits_for_anyone"}} + - {"id": "BREG-SEC-268", "state": "enforced", "targetWave": "W5", "threat": "A filer moves a bound subject through Edit, Revise or Rebase and hands answers and files to another person.", "enforcementPoint": "Edit, Revise and Rebase compare the subject input with the stored input once a subject is bound; Submit compares the bound reference.", "refusal": "Answer 400 request.invalid naming the subject input.", "negativeId": "BREG-NEG-268", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "the_subject_is_frozen_at_the_first_submit"}} + - {"id": "BREG-SEC-269", "state": "enforced", "targetWave": "W5", "threat": "The Record a field-form subject reads changes holder and the next Submit silently rebinds the Proposal to the new holder.", "enforcementPoint": "Submit reads the field inside the transaction and compares its reference with the bound one.", "refusal": "Answer 409 proposal.subject-changed.", "negativeId": "BREG-NEG-269", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "the_field_form_reads_the_holder_and_refuses_a_moved_holder"}} + - {"id": "BREG-SEC-270", "state": "enforced", "targetWave": "W5", "threat": "An agent, a service or a delegated token carrying the subject's principal is admitted as the subject.", "enforcementPoint": "Subject matching requires the admission's human test: a verified person acting for no one else and under no task grant.", "refusal": "Refuse at admission or conceal with 404 resource.not-found.", "negativeId": "BREG-NEG-270", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "only_a_person_acting_for_themselves_is_matched_as_the_subject"}} + - {"id": "BREG-SEC-271", "state": "enforced", "targetWave": "W5", "threat": "A subject entry edits, submits, revises or applies work someone else filed.", "enforcementPoint": "Project compilation of party: subject entries.", "refusal": "Refuse with breg.proposal.subject-operation-forbidden.", "negativeId": "BREG-NEG-271", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_subject_entry_holds_only_the_follower_operations"}} + - {"id": "BREG-SEC-272", "state": "enforced", "targetWave": "W5", "threat": "Audit records the subject's identifier or its internal reference.", "enforcementPoint": "The binding Submit records only a keyed, database-scoped subject pseudonym; later requests record partyRole.", "refusal": "Never write the identifier or the unkeyed reference to audit.", "negativeId": "BREG-NEG-272", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "audit_names_the_subject_by_pseudonym_and_each_later_request_by_party"}} + - {"id": "BREG-SEC-273", "state": "enforced", "targetWave": "W5", "threat": "A writer whose row boundaries let them name anyone sets the Record field a Proposal subject is read from, and so chooses who follows Proposals about that Record.", "enforcementPoint": "Project compilation of direct Record write grants, and of Action grants whose plan sets a field any `subject.field` names with no person deciding: an immediate Action, or a Proposal Action without required review that is applied automatically.", "refusal": "Refuse with breg.proposal.subject-field-write unless the grant is unrestricted or bounded on that field by its own principal claim.", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} + - {"id": "BREG-SEC-274", "state": "enforced", "targetWave": "W5", "threat": "A party downloads an attachment its governing entry does not read, through another entry of the same profile.", "enforcementPoint": "The attachment route selects the entry that admitted the caller, party included, and the download transaction rechecks that entry's readable slots.", "refusal": "Conceal with 404 resource.not-found.", "negativeId": "BREG-NEG-274", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "attachment_downloads_follow_the_entry_that_admitted_the_caller"}} diff --git a/products/breg/contracts/security-test-traceability.yaml b/products/breg/contracts/security-test-traceability.yaml index 7429f25359..a079d77ecd 100644 --- a/products/breg/contracts/security-test-traceability.yaml +++ b/products/breg/contracts/security-test-traceability.yaml @@ -305,3 +305,31 @@ traceability: - {id: BREG-SEC-245, state: enforced, negativeId: BREG-NEG-245, negativeTest: {path: crates/registry-breg/tests/consent_access.rs, name: a_consent_scope_requires_explicit_fields_on_direct_reads_and_read_paths}} # Commit Evidence proof: crates/registry-breg/tests/postgres_action_evidence.rs::commit_evidence_is_guard_only_and_replay_never_reacquires - {id: BREG-SEC-246, state: enforced, negativeId: BREG-NEG-246, negativeTest: {path: crates/registry-breg/tests/postgres_immediate_actions.rs, name: an_action_create_outside_the_boundary_is_refused_before_targets_and_guards}} + - {"id": "BREG-SEC-247", "state": "enforced", "negativeId": "BREG-NEG-247", "negativeTest": {"path": "crates/registry-breg/tests/membership_authoring.rs", "name": "an_open_membership_target_requires_sub_even_for_immediate_invoke"}} + - {"id": "BREG-SEC-248", "state": "enforced", "negativeId": "BREG-NEG-248", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_patch_moving_a_row_to_a_key_the_caller_is_not_a_member_of_is_refused"}} + - {"id": "BREG-SEC-249", "state": "enforced", "negativeId": "BREG-NEG-249", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "record_removal_first_refuses_the_write"}} + - {"id": "BREG-SEC-250", "state": "enforced", "negativeId": "BREG-NEG-250", "negativeTest": {"path": "crates/registry-breg/tests/support/postgres_membership_writes.rs", "name": "the_runtime_role_can_lock_a_membership_row_it_cannot_update"}} + - {"id": "BREG-SEC-251", "state": "enforced", "negativeId": "BREG-NEG-251", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "an_action_cannot_invalidate_its_own_membership_proof"}} + - {"id": "BREG-SEC-252", "state": "enforced", "negativeId": "BREG-NEG-252", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "proposal_apply_refuses_a_key_move_when_only_the_old_key_is_admitted"}} + - {"id": "BREG-SEC-253", "state": "enforced", "negativeId": "BREG-NEG-253", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "evidence_admission_refuses_unsatisfiable_membership_and_replays_without_acquisition"}} + - {"id": "BREG-SEC-254", "state": "enforced", "negativeId": "BREG-NEG-254", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_membership_refusal_leaves_s3_staging_unchanged"}} + - {"id": "BREG-SEC-255", "state": "enforced", "negativeId": "BREG-NEG-255", "negativeTest": {"path": "crates/registry-breg/src/mutation/action.rs", "name": "hooks_refuse_claim_and_membership_boundaries_on_the_same_path"}} + - {"id": "BREG-SEC-256", "state": "planned", "negativeId": "BREG-NEG-256"} + - {"id": "BREG-SEC-257", "state": "enforced", "negativeId": "BREG-NEG-257", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_two_level_chain_through_an_action_target_is_refused"}} + - {"id": "BREG-SEC-258", "state": "enforced", "negativeId": "BREG-NEG-258", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "the_identifier_field_bounds_reads_and_referenced_targets_only"}} + - {"id": "BREG-SEC-259", "state": "enforced", "negativeId": "BREG-NEG-259", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_removed_member_gets_a_strangers_answer_on_every_membership_path"}} + - {"id": "BREG-SEC-260", "state": "enforced", "negativeId": "BREG-NEG-260", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_member_cannot_write_the_fields_their_membership_probe_reads"}} + - {"id": "BREG-SEC-261", "state": "enforced", "negativeId": "BREG-NEG-261", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "two_concurrent_appointments_of_one_person_leave_one_live_row"}} + - {"id": "BREG-SEC-262", "state": "enforced", "negativeId": "BREG-NEG-262", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_removed_member_cannot_replay_a_stored_record_write_or_batch"}} + - {"id": "BREG-SEC-263", "state": "enforced", "negativeId": "BREG-NEG-263", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_claim_bounded_grant_cannot_set_a_sources_key_or_principal"}} + - {"id": "BREG-SEC-264", "state": "enforced", "negativeId": "BREG-NEG-264", "negativeTest": {"path": "crates/registry-breg/tests/steward_authoring.rs", "name": "a_membership_source_requiring_consent_read_through_itself_is_refused"}} + - {"id": "BREG-SEC-265", "state": "enforced", "negativeId": "BREG-NEG-265", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_review_asks.rs", "name": "matching_an_action_input_does_not_make_a_caller_the_proposal_subject"}} + - {"id": "BREG-SEC-266", "state": "enforced", "negativeId": "BREG-NEG-266", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "a_citizen_follows_a_proposal_the_desk_filed_and_a_neighbour_sees_nothing"}} + - {"id": "BREG-SEC-267", "state": "enforced", "negativeId": "BREG-NEG-267", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "submit_names_someone_else_only_under_submits_for_anyone"}} + - {"id": "BREG-SEC-268", "state": "enforced", "negativeId": "BREG-NEG-268", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "the_subject_is_frozen_at_the_first_submit"}} + - {"id": "BREG-SEC-269", "state": "enforced", "negativeId": "BREG-NEG-269", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "the_field_form_reads_the_holder_and_refuses_a_moved_holder"}} + - {"id": "BREG-SEC-270", "state": "enforced", "negativeId": "BREG-NEG-270", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "only_a_person_acting_for_themselves_is_matched_as_the_subject"}} + - {"id": "BREG-SEC-271", "state": "enforced", "negativeId": "BREG-NEG-271", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_subject_entry_holds_only_the_follower_operations"}} + - {"id": "BREG-SEC-272", "state": "enforced", "negativeId": "BREG-NEG-272", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "audit_names_the_subject_by_pseudonym_and_each_later_request_by_party"}} + - {"id": "BREG-SEC-273", "state": "enforced", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} + - {"id": "BREG-SEC-274", "state": "enforced", "negativeId": "BREG-NEG-274", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "attachment_downloads_follow_the_entry_that_admitted_the_caller"}} diff --git a/products/breg/examples/README.md b/products/breg/examples/README.md index c072b0f88a..73f1227112 100644 --- a/products/breg/examples/README.md +++ b/products/breg/examples/README.md @@ -20,6 +20,9 @@ journey. project with live and indexed external Person and shareholding views. Its synthetic source and journey are acceptance fixtures for a disposable deployment. +[`organisation-stewardship/`](organisation-stewardship/README.md) shows stewards +who manage an organisation's members through two Actions, with the organisation +each person stewards or belongs to held as a record in the registry. The `minimal/` and `facility/` shipped starters include their own development plans, local callers and authored journeys. @@ -35,6 +38,7 @@ cargo run --locked -p registry-bregctl -- check products/breg/examples/minimal cargo run --locked -p registry-bregctl -- check products/breg/examples/reviewed-change cargo run --locked -p registry-bregctl -- check products/breg/examples/facility cargo run --locked -p registry-bregctl -- check products/breg/examples/future-activation --production +cargo run --locked -p registry-bregctl -- check products/breg/examples/organisation-stewardship --production cargo run --locked -p registry-bregctl -- --format json explain actions products/breg/examples/facility cargo run --locked -p registry-bregctl -- --format json explain proposals products/breg/examples/facility ``` diff --git a/products/breg/examples/facility/registry.yaml b/products/breg/examples/facility/registry.yaml index 9862655b18..ead99bda7b 100644 --- a/products/breg/examples/facility/registry.yaml +++ b/products/breg/examples/facility/registry.yaml @@ -295,14 +295,14 @@ accessProfiles: readableInputs: [facility, address-line, city, postal-code] readableAttachments: [supporting-document] writableAttachments: [supporting-document] - ownership: caller + party: owner targets: - recordType: facility rowBoundaries: {rowBoundarySet: same-jurisdiction} - action: deactivate-facility operations: [get, list, edit, submit, revise, rebase, retry, cancel, get-review-status] readableInputs: [facility] - ownership: caller + party: owner targets: - recordType: facility rowBoundaries: {rowBoundarySet: same-jurisdiction} diff --git a/products/breg/examples/minimal/registry.yaml b/products/breg/examples/minimal/registry.yaml index 7f472a051c..615a10c265 100644 --- a/products/breg/examples/minimal/registry.yaml +++ b/products/breg/examples/minimal/registry.yaml @@ -97,7 +97,7 @@ accessProfiles: - action: register-contact operations: [get, list, edit, submit, cancel] readableInputs: [name, email, jurisdiction] - ownership: caller + party: owner targets: - recordType: contact rowBoundaries: diff --git a/products/breg/examples/organisation-stewardship/README.md b/products/breg/examples/organisation-stewardship/README.md new file mode 100644 index 0000000000..b7814b5c9d --- /dev/null +++ b/products/breg/examples/organisation-stewardship/README.md @@ -0,0 +1,55 @@ +# Organisation stewardship + +A steward manages who belongs to an organisation. The registry, not the +token, decides which organisation that is. + +- `registrar` registers organisations in their jurisdiction. They register + facilities, rename organisations, and name and end each organisation's + stewards through Actions: `register-facility`, `rename-organisation`, + `name-steward`, which creates an active `stewardship` record, and + `end-stewardship`, which deactivates one. Only the registrar changes + stewardships, so a steward can never appoint a steward, themselves + included. The Actions that name an organisation accept only one in the + registrar's jurisdiction, and the registrar holds no direct write on + `facility` or `stewardship`. +- `organisation-steward` reads the organisations a live stewardship names for + them, by each organisation's own identifier, and reads their members. It + changes members only through two Actions: `appoint-member` creates an active + membership, and `remove-member` deactivates one. The profile holds no direct + record write. +- `member` reads the facilities of the organisations a live membership names + for them. + +`service.yaml` defines one role per job. The issuer decides who may hold a +job. No role lists a claim that names an organisation: which organisations a +person stewards or belongs to are records in the registry, checked live in the +same transaction as each request. Removing a member or ending a stewardship +takes effect on the next request, not when a token expires. + +BReg allows one active row per organisation and principal in every +membership source, so a person holds at most one active appointment per +organisation. Removing a member deactivates the row, and appointing the same +person again creates a new one, so the earlier rows remain as the record of +past appointments. + +Organisations, facilities and stewardships each carry a `jurisdiction`, and +every registrar grant is bounded by the registrar's `jurisdiction` claim, so a +registrar registers and names stewards only in their own jurisdiction. + +Check the project and its journey, then run it with `rstack dev`: + +```bash +bregctl check . +bregctl check . --file tests/journeys.yaml +rstack dev start . --ttl 1h +``` + +`rstack dev start` runs `tests/journeys.yaml` before serving the package: the +registrar names a steward, the steward appoints and removes a member, and the +removed member is refused. The steward cannot appoint into an organisation +they do not steward, a second steward without a stewardship cannot appoint +into the first organisation, and a registrar cannot name a steward of, or +register a facility for, another jurisdiction's organisation. Stop the run with `rstack dev stop RUN`. + +See [Require a current membership](https://docs.registrystack.org/configure/breg-access/#require-a-current-membership) +for the membership rules this example uses. diff --git a/products/breg/examples/organisation-stewardship/dev-journeys.yaml b/products/breg/examples/organisation-stewardship/dev-journeys.yaml new file mode 100644 index 0000000000..9aa82ba0c6 --- /dev/null +++ b/products/breg/examples/organisation-stewardship/dev-journeys.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/rstack/journeys/journeys.v1alpha1.schema.json +apiVersion: id.registrystack.org/formats/rstack/journeys/v1alpha1 +kind: RStackJourneys +# The authored journeys in tests/journeys.yaml carry the example's checks. This +# HTTP journey only proves the served registry answers the registrar. +journeys: + - id: registrar-lists-organisations + steps: + - id: list-organisations + product: breg + as: registrar + method: GET + path: /v1/records/organizations + expect: {status: 200} diff --git a/products/breg/examples/organisation-stewardship/dev.yaml b/products/breg/examples/organisation-stewardship/dev.yaml new file mode 100644 index 0000000000..22dc6296ce --- /dev/null +++ b/products/breg/examples/organisation-stewardship/dev.yaml @@ -0,0 +1,45 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/rstack/dev/dev.v1alpha1.schema.json +apiVersion: id.registrystack.org/formats/rstack/dev/v1alpha1 +kind: RStackDev +# The run signs test tokens with a throwaway local key under this logical +# issuer. It runs tests/journeys.yaml before serving the package, then the +# HTTP request in dev-journeys.yaml. +issuer: https://identity.organisations.example.test +products: + breg: + projects: + breg: + path: . +audiences: + breg: "urn:example:organisation-stewardship" +people: + registrar: + subject: synthetic-registrar + client: registrar + roles: [registrar] + claims: + breg: {jurisdiction: north-district} + purposes: {breg: organisation-administration} + south-registrar: + subject: synthetic-south-registrar + client: registrar + roles: [registrar] + claims: + breg: {jurisdiction: south-district} + purposes: {breg: organisation-administration} + steward: + subject: synthetic-steward + client: organisation-steward + roles: [organisation-steward] + purposes: {breg: organisation-administration} + second-steward: + subject: synthetic-second-steward + client: organisation-steward + roles: [organisation-steward] + purposes: {breg: organisation-administration} + member: + subject: synthetic-member + client: member + roles: [member] + purposes: {breg: organisation-administration} +journeyFile: dev-journeys.yaml diff --git a/products/breg/examples/organisation-stewardship/registry.yaml b/products/breg/examples/organisation-stewardship/registry.yaml new file mode 100644 index 0000000000..c67dcd467b --- /dev/null +++ b/products/breg/examples/organisation-stewardship/registry.yaml @@ -0,0 +1,286 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/breg/project/project.v1alpha1.schema.json +apiVersion: id.registrystack.org/formats/breg/project/v1alpha1 +kind: BRegProject +project: + id: organisation-stewardship + canonicalBaseIri: https://organisations.example.gov + version: 0.1.0 + defaultLanguage: en + display: + label: Organisation stewardship + description: Organisations whose stewards manage who belongs to them, and members who read their facilities. + +package: + sourceRevision: organisation-stewardship-0.1.0 + +datasets: + organisations: + display: {label: Organisations, description: "Registered organisations, their stewards and members, and their facilities."} + +recordTypes: + organization: + route: organizations + primaryDataset: organisations + mutationMode: mutable + display: {label: Organisation, description: A registered organisation.} + fields: + - {id: name, type: string, required: true, minimumLength: 1, maximumLength: 160, classification: internal} + - {id: jurisdiction, type: string, required: true, minimumLength: 1, maximumLength: 40, classification: internal} + + # Who stewards which organisation. Only the registrar writes it, so a + # steward can never appoint a steward, themselves included. + stewardship: + route: stewardships + primaryDataset: organisations + mutationMode: mutable + classification: restricted + display: {label: Stewardship, description: A person named as steward of one organisation.} + membership: {key: organization, principal: principal, active: active} + fields: + - {id: organization, type: reference, target: organization, required: true, classification: internal} + - {id: principal, type: string, required: true, minimumLength: 1, maximumLength: 80, classification: restricted} + - {id: active, type: boolean, required: true, classification: internal} + - {id: jurisdiction, type: string, required: true, minimumLength: 1, maximumLength: 40, classification: internal} + + # Who belongs to which organisation. Stewards change it only through the + # two Actions below. Removal deactivates the row. BReg keeps at most one + # active row per organisation and principal for every membership source. + membership: + route: memberships + primaryDataset: organisations + mutationMode: mutable + classification: restricted + display: {label: Membership, description: A person's current membership of one organisation.} + membership: {key: organization, principal: principal, active: active} + fields: + - {id: organization, type: reference, target: organization, required: true, classification: internal} + - {id: principal, type: string, required: true, minimumLength: 1, maximumLength: 80, classification: restricted} + - {id: active, type: boolean, required: true, classification: internal} + + facility: + route: facilities + primaryDataset: organisations + mutationMode: mutable + display: {label: Facility, description: A facility one organisation operates.} + fields: + - {id: organization, type: reference, target: organization, required: true, classification: internal} + - {id: label, type: string, required: true, minimumLength: 1, maximumLength: 160, classification: internal} + - {id: jurisdiction, type: string, required: true, minimumLength: 1, maximumLength: 40, classification: internal} + +actions: + # The registrar registers facilities, renames organisations, and names + # and ends stewardships through Actions whose target grants scope every + # Record they write or name to the registrar's jurisdiction. + register-facility: + display: {label: Register facility, description: Register a facility of an organisation in your jurisdiction.} + execution: {mode: immediate} + inputs: + - {id: organization, apiName: organizationId, type: reference, target: organization, required: true, classification: internal} + - {id: label, type: string, required: true, minimumLength: 1, maximumLength: 160, classification: internal} + - {id: jurisdiction, type: string, required: true, minimumLength: 1, maximumLength: 40, classification: internal} + plan: + type: fixed + effects: + - id: facility + target: {recordType: facility} + operation: create + set: + organization: {fromInput: organization} + label: {fromInput: label} + jurisdiction: {fromInput: jurisdiction} + rename-organisation: + display: {label: Rename organisation, description: Change the name of an organisation in your jurisdiction.} + execution: {mode: immediate} + inputs: + - {id: organization, apiName: organizationId, type: reference, target: organization, required: true, classification: internal} + - {id: name, type: string, required: true, minimumLength: 1, maximumLength: 160, classification: internal} + commitGuards: + targets: + - {input: organization, revision: unchanged} + plan: + type: fixed + effects: + - id: organization + target: {fromInput: organization} + operation: patch + set: + name: {fromInput: name} + name-steward: + display: {label: Name steward, description: "Name a person, by their verified identifier, as steward of an organisation in your jurisdiction."} + execution: {mode: immediate} + inputs: + - {id: organization, apiName: organizationId, type: reference, target: organization, required: true, classification: internal} + - {id: principal, type: string, required: true, minimumLength: 1, maximumLength: 80, classification: restricted} + - {id: jurisdiction, type: string, required: true, minimumLength: 1, maximumLength: 40, classification: internal} + plan: + type: fixed + effects: + - id: stewardship + target: {recordType: stewardship} + operation: create + set: + organization: {fromInput: organization} + principal: {fromInput: principal} + active: {value: true} + jurisdiction: {fromInput: jurisdiction} + end-stewardship: + display: {label: End stewardship, description: End one active stewardship in your jurisdiction.} + execution: {mode: immediate, concurrency: current-revision} + inputs: + - {id: stewardship, apiName: stewardshipId, type: reference, target: stewardship, required: true, classification: internal} + commitGuards: + targets: + - {input: stewardship, field: active, equals: true, reason: stewardship-inactive} + plan: + type: fixed + effects: + - id: stewardship + target: {fromInput: stewardship} + operation: patch + set: + active: {value: false} + appoint-member: + display: {label: Appoint member, description: "Name a person, by their verified identifier, as a member of an organisation you steward."} + execution: {mode: immediate} + inputs: + - {id: organization, apiName: organizationId, type: reference, target: organization, required: true, classification: internal} + - {id: principal, type: string, required: true, minimumLength: 1, maximumLength: 80, classification: restricted} + plan: + type: fixed + effects: + - id: membership + target: {recordType: membership} + operation: create + set: + organization: {fromInput: organization} + principal: {fromInput: principal} + active: {value: true} + remove-member: + display: {label: Remove member, description: End one active membership of an organisation you steward.} + execution: {mode: immediate, concurrency: current-revision} + inputs: + - {id: membership, apiName: membershipId, type: reference, target: membership, required: true, classification: internal} + commitGuards: + targets: + - {input: membership, field: active, equals: true, reason: membership-inactive} + plan: + type: fixed + effects: + - id: membership + target: {fromInput: membership} + operation: patch + set: + active: {value: false} + +accessProfiles: + # The registrar registers organisations in their jurisdiction, and + # changes everything else there through the registrar Actions. + registrar: + principalClaim: registry_principal + requiredScopes: ["registry:organisations:register"] + requiredPurposes: [organisation-administration] + permissions: + records: + - recordType: organization + operations: [create, get, list] + readableFields: [name, jurisdiction] + writableFields: [name, jurisdiction] + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - recordType: facility + operations: [get, list] + readableFields: [organization, label, jurisdiction] + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - recordType: stewardship + operations: [get, list] + readableFields: [organization, principal, active, jurisdiction] + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + actions: + - action: register-facility + operations: [invoke] + results: [facility] + targets: + - recordType: facility + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - recordType: organization + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - action: rename-organisation + operations: [invoke] + results: [organization] + targets: + - recordType: organization + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - action: name-steward + operations: [invoke] + results: [stewardship] + targets: + - recordType: stewardship + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - recordType: organization + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + - action: end-stewardship + operations: [invoke] + results: [stewardship] + targets: + - recordType: stewardship + rowBoundaries: + - {field: jurisdiction, claim: jurisdiction, operator: equals} + + # A steward reaches the organisations a live stewardship names for them: + # the organisation itself by its identifier, its members, and the two + # Actions. The profile holds no direct write. + organisation-steward: + principalClaim: registry_principal + requiredScopes: ["registry:organisations:steward"] + requiredPurposes: [organisation-administration] + permissions: + records: + - recordType: organization + operations: [get, list] + readableFields: [name, jurisdiction] + rowBoundaries: + - {field: id, membership: stewardship} + - recordType: membership + operations: [get, list] + readableFields: [organization, principal, active] + rowBoundaries: + - {field: organization, membership: stewardship} + actions: + - action: appoint-member + operations: [invoke] + results: [membership] + targets: + - recordType: membership + rowBoundaries: + - {field: organization, membership: stewardship} + - recordType: organization + rowBoundaries: + - {field: id, membership: stewardship} + - action: remove-member + operations: [invoke] + results: [membership] + targets: + - recordType: membership + rowBoundaries: + - {field: organization, membership: stewardship} + + # A member reads the facilities of the organisations a live membership + # names for them. + member: + principalClaim: registry_principal + requiredScopes: ["registry:organisations:member"] + requiredPurposes: [organisation-administration] + permissions: + records: + - recordType: facility + operations: [get, list] + readableFields: [organization, label] + rowBoundaries: + - {field: organization, membership: membership} diff --git a/products/breg/examples/organisation-stewardship/service.yaml b/products/breg/examples/organisation-stewardship/service.yaml new file mode 100644 index 0000000000..9e2cc4905d --- /dev/null +++ b/products/breg/examples/organisation-stewardship/service.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/rstack/service/service.v1alpha1.schema.json +apiVersion: id.registrystack.org/formats/rstack/service/v1alpha1 +kind: RStackService +# The issuer decides who may hold each job. Which organisation a steward or +# member acts for is a record in the registry, so no role lists a claim that +# names one. +roles: + registrar: + actorKind: human + claims: [jurisdiction] + accessProfiles: + breg: [registrar] + organisation-steward: + actorKind: human + accessProfiles: + breg: [organisation-steward] + member: + actorKind: human + accessProfiles: + breg: [member] diff --git a/products/breg/examples/organisation-stewardship/tests/journeys.yaml b/products/breg/examples/organisation-stewardship/tests/journeys.yaml new file mode 100644 index 0000000000..730506500f --- /dev/null +++ b/products/breg/examples/organisation-stewardship/tests/journeys.yaml @@ -0,0 +1,186 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/breg/journeys/journeys.v1.schema.json +apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: organisation-steward + steps: + # The registrar registers two organisations and a facility of the first, and + # names the first organisation's steward by their verified identifier. + - id: register-organisation + actor: registrar + recordType: organization + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: create, data: {name: North cooperative, jurisdiction: north-district}} + expect: {outcome: success, status: 201} + capture: organisation + - id: register-other-organisation + actor: registrar + recordType: organization + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: create, data: {name: Other cooperative, jurisdiction: north-district}} + expect: {outcome: success, status: 201} + capture: other-organisation + - id: register-facility + actor: registrar + action: register-facility + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: invoke, idempotencyKey: register-facility, input: {organizationId: {recordCapture: organisation}, label: North depot, jurisdiction: north-district}} + expect: {outcome: success, status: 200} + captureResults: {facility: facility} + - id: name-steward + actor: registrar + action: name-steward + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: invoke, idempotencyKey: name-steward, input: {organizationId: {recordCapture: organisation}, principal: synthetic-steward, jurisdiction: north-district}} + expect: {outcome: success, status: 200} + # A registrar names stewards only in their own jurisdiction. + - id: register-south-organisation + actor: south-registrar + recordType: organization + accessProfile: registrar + claims: + principal: synthetic-south-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: south-district} + request: {type: create, data: {name: South cooperative, jurisdiction: south-district}} + expect: {outcome: success, status: 201} + capture: south-organisation + - id: registrar-cannot-name-a-steward-elsewhere + actor: registrar + action: name-steward + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: invoke, idempotencyKey: name-steward-elsewhere, input: {organizationId: {recordCapture: south-organisation}, principal: synthetic-steward, jurisdiction: north-district}} + expect: {outcome: refusal, status: 412, problemCode: precondition.failed} + - id: registrar-cannot-register-a-facility-elsewhere + actor: registrar + action: register-facility + accessProfile: registrar + claims: + principal: synthetic-registrar + scopes: [registry:organisations:register] + purpose: organisation-administration + directClaims: {jurisdiction: north-district} + request: {type: invoke, idempotencyKey: register-facility-elsewhere, input: {organizationId: {recordCapture: south-organisation}, label: South depot, jurisdiction: north-district}} + expect: {outcome: refusal, status: 412, problemCode: precondition.failed} + # The steward sees their organisation and no other. + - id: steward-reads-their-organisation + actor: steward + recordType: organization + accessProfile: organisation-steward + claims: + principal: synthetic-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: get, recordCapture: organisation} + expect: {outcome: success, status: 200} + - id: steward-cannot-read-another-organisation + actor: steward + recordType: organization + accessProfile: organisation-steward + claims: + principal: synthetic-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: get, recordCapture: other-organisation} + expect: {outcome: refusal, status: 404, problemCode: resource.not-found} + - id: member-reads-nothing-before-appointment + actor: member + recordType: facility + accessProfile: member + claims: + principal: synthetic-member + scopes: [registry:organisations:member] + purpose: organisation-administration + request: {type: get, recordCapture: facility} + expect: {outcome: refusal, status: 404, problemCode: resource.not-found} + # The steward appoints a member, who then reads the organisation's facility. + - id: steward-appoints-member + actor: steward + action: appoint-member + accessProfile: organisation-steward + claims: + principal: synthetic-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: invoke, idempotencyKey: appoint-member, input: {organizationId: {recordCapture: organisation}, principal: synthetic-member}} + expect: {outcome: success, status: 200} + captureResults: {membership: membership} + - id: member-reads-facility + actor: member + recordType: facility + accessProfile: member + claims: + principal: synthetic-member + scopes: [registry:organisations:member] + purpose: organisation-administration + request: {type: get, recordCapture: facility} + expect: {outcome: success, status: 200} + # Removing the member ends their access on the next request. + - id: steward-removes-member + actor: steward + action: remove-member + accessProfile: organisation-steward + claims: + principal: synthetic-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: invoke, idempotencyKey: remove-member, input: {membershipId: {recordCapture: membership}}} + expect: {outcome: success, status: 200} + - id: removed-member-is-refused + actor: member + recordType: facility + accessProfile: member + claims: + principal: synthetic-member + scopes: [registry:organisations:member] + purpose: organisation-administration + request: {type: get, recordCapture: facility} + expect: {outcome: refusal, status: 404, problemCode: resource.not-found} + # Stewardship is per organisation: the steward cannot appoint elsewhere, and + # a second steward without a stewardship record cannot appoint here. + - id: steward-cannot-appoint-into-another-organisation + actor: steward + action: appoint-member + accessProfile: organisation-steward + claims: + principal: synthetic-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: invoke, idempotencyKey: appoint-elsewhere, input: {organizationId: {recordCapture: other-organisation}, principal: synthetic-member}} + expect: {outcome: refusal, status: 412, problemCode: precondition.failed} + - id: second-steward-cannot-appoint + actor: second-steward + action: appoint-member + accessProfile: organisation-steward + claims: + principal: synthetic-second-steward + scopes: [registry:organisations:steward] + purpose: organisation-administration + request: {type: invoke, idempotencyKey: second-steward-appoint, input: {organizationId: {recordCapture: organisation}, principal: synthetic-member}} + expect: {outcome: refusal, status: 412, problemCode: precondition.failed} diff --git a/products/breg/examples/required-attachment/registry.yaml b/products/breg/examples/required-attachment/registry.yaml index 6b2f9afb33..e2a1a51ad3 100644 --- a/products/breg/examples/required-attachment/registry.yaml +++ b/products/breg/examples/required-attachment/registry.yaml @@ -59,7 +59,7 @@ accessProfiles: proposals: - action: correct-name operations: [get, list, edit, submit, revise, rebase, cancel, apply] - ownership: caller + party: owner readableInputs: [target, value] readableAttachments: [support] writableAttachments: [support] diff --git a/products/breg/examples/reviewed-change/registry.yaml b/products/breg/examples/reviewed-change/registry.yaml index 6361218567..a1f37a2c0a 100644 --- a/products/breg/examples/reviewed-change/registry.yaml +++ b/products/breg/examples/reviewed-change/registry.yaml @@ -89,7 +89,7 @@ accessProfiles: - action: correct-name operations: [get, list, submit, cancel] readableInputs: [contact, name] - ownership: caller + party: owner targets: - recordType: contact rowBoundaries: diff --git a/products/breg/fixtures/action-plan-branches/registry.yaml b/products/breg/fixtures/action-plan-branches/registry.yaml index 535333490b..959b40fd00 100644 --- a/products/breg/fixtures/action-plan-branches/registry.yaml +++ b/products/breg/fixtures/action-plan-branches/registry.yaml @@ -58,7 +58,7 @@ accessProfiles: author: default: true principalClaim: sub - requiredScopes: unrestricted + requiredScopes: [entries:write] permissions: actions: - {action: create-entry, operations: [invoke], targets: [{recordType: entry, rowBoundaries: unrestricted}], results: [entry]} diff --git a/products/breg/fixtures/authoring-display/registry.yaml b/products/breg/fixtures/authoring-display/registry.yaml index 7831203d74..84b4512e77 100644 --- a/products/breg/fixtures/authoring-display/registry.yaml +++ b/products/breg/fixtures/authoring-display/registry.yaml @@ -103,6 +103,6 @@ accessProfiles: - action: register-entry operations: [get, list, edit, submit, cancel] readableInputs: [code, active, recorded-on] - ownership: caller + party: owner targets: - {recordType: entry, rowBoundaries: unrestricted} diff --git a/products/breg/fixtures/consent-land-registry/modules/consent-tenure-right/module.yaml b/products/breg/fixtures/consent-land-registry/modules/consent-tenure-right/module.yaml index 4770546dac..0f50d9ba18 100644 --- a/products/breg/fixtures/consent-land-registry/modules/consent-tenure-right/module.yaml +++ b/products/breg/fixtures/consent-land-registry/modules/consent-tenure-right/module.yaml @@ -151,6 +151,11 @@ ] }, "tenure-right-consent-link": { + "membership": { + "key": "subject", + "principal": "principal", + "active": "active" + }, "primaryDataset": "consent", "route": "tenure-right-consent-links", "mutationMode": "mutable", diff --git a/products/breg/fixtures/consent-land-registry/registry.yaml b/products/breg/fixtures/consent-land-registry/registry.yaml index 0e6ecc4197..d316dd5417 100644 --- a/products/breg/fixtures/consent-land-registry/registry.yaml +++ b/products/breg/fixtures/consent-land-registry/registry.yaml @@ -67,7 +67,7 @@ ], "distributions": [] }, - "modules": {"consent-land-registry-core":{"digest":"sha256:3b04597b187b7085830952c5b76d14ee8f9d48c6395df0b88f7eeb865906c04f","version":"0.1.0"},"consent-tenure-right":{"digest":"sha256:957c95afa8b02dfb9b02e92e7ca23ad0ee59564ae1c36c4fbffafc9a09dfe1cc","version":"0.1.0"}}, + "modules": {"consent-land-registry-core":{"digest":"sha256:3b04597b187b7085830952c5b76d14ee8f9d48c6395df0b88f7eeb865906c04f","version":"0.1.0"},"consent-tenure-right":{"digest":"sha256:bc22d4efab34bd3a5c9311049c241544137395017b7672776c3f332512c431c8","version":"0.1.0"}}, "recipients": { "organizations": [ { @@ -234,14 +234,10 @@ "records": [ { "recordType": "tenure-right-consent-decision", - "rowBoundaries": "unrestricted", - "membershipBoundaries": [ + "rowBoundaries": [ { "field": "subject", - "membershipRecordType": "tenure-right-consent-link", - "membershipKeyField": "subject", - "principalField": "principal", - "activeField": "active" + "membership": "tenure-right-consent-link" } ], "operations": [ diff --git a/products/breg/fixtures/consent-person-registry/modules/consent-person/module.yaml b/products/breg/fixtures/consent-person-registry/modules/consent-person/module.yaml index 0ea8f27197..242e340e2d 100644 --- a/products/breg/fixtures/consent-person-registry/modules/consent-person/module.yaml +++ b/products/breg/fixtures/consent-person-registry/modules/consent-person/module.yaml @@ -39,6 +39,7 @@ recordTypes: - {id: data-life, type: string, maximumLength: 80, classification: public} - {id: description, type: text, maximumLength: 4000, required: true, classification: public} person-consent-link: + membership: {key: subject, principal: principal, active: active} primaryDataset: consent route: person-consent-links mutationMode: mutable diff --git a/products/breg/fixtures/consent-person-registry/registry.yaml b/products/breg/fixtures/consent-person-registry/registry.yaml index db58c07a07..75d2a6a0c2 100644 --- a/products/breg/fixtures/consent-person-registry/registry.yaml +++ b/products/breg/fixtures/consent-person-registry/registry.yaml @@ -44,7 +44,7 @@ manifestProjection: modules: "consent-person": version: "0.1.0" - digest: "sha256:3ece798eaae6ee97f7e2d946cbf17fb8b7c1dc23bb8382d7aecb423dce755c24" + digest: "sha256:dfeb0408b8a3a5c4959e63377787cd01c558bb33943b6c9d822522950cb8a879" "consent-person-registry-core": version: "0.1.0" digest: "sha256:853a419af5b6fdd4e336a5f334accc754dde3a47eb81fd67c89b7fdfcfc6c7fe" @@ -109,9 +109,8 @@ accessProfiles: permissions: records: - recordType: person-consent-decision - rowBoundaries: unrestricted - membershipBoundaries: - - {field: subject, membershipRecordType: person-consent-link, membershipKeyField: subject, principalField: principal, activeField: active} + rowBoundaries: + - {field: subject, membership: person-consent-link} operations: [get, list] readableFields: [subject, notice, clause, recipient, purpose, scope, decision, effective-at, expires-at, channel] - recordType: person-consent-link diff --git a/products/breg/fixtures/organization-membership-access/registry.yaml b/products/breg/fixtures/organization-membership-access/registry.yaml index 86e4cd74b2..a4526e0146 100644 --- a/products/breg/fixtures/organization-membership-access/registry.yaml +++ b/products/breg/fixtures/organization-membership-access/registry.yaml @@ -23,6 +23,11 @@ ] }, "membership": { + "membership": { + "key": "organization", + "principal": "principal", + "active": "active" + }, "primaryDataset": "test-dataset", "route": "memberships", "mutationMode": "mutable", @@ -114,7 +119,12 @@ "records": [ { "recordType": "facility", - "rowBoundaries": "unrestricted", + "rowBoundaries": [ + { + "field": "organization", + "membership": "membership" + } + ], "operations": [ "get", "list", @@ -138,15 +148,6 @@ "selector": "label", "valueOrigin": "request" } - ], - "membershipBoundaries": [ - { - "field": "organization", - "membershipRecordType": "membership", - "membershipKeyField": "organization", - "principalField": "principal", - "activeField": "active" - } ] } ] diff --git a/products/breg/scripts/test-adopter-workflow.sh b/products/breg/scripts/test-adopter-workflow.sh index ddefecdd82..396a19edf8 100755 --- a/products/breg/scripts/test-adopter-workflow.sh +++ b/products/breg/scripts/test-adopter-workflow.sh @@ -165,8 +165,9 @@ write_jwt() { local key_id=$2 local principal=$3 local purpose=$4 - local output=$5 - python3 - "$key_id" "$principal" "$purpose" "$output.signing-input" <<'PY' + local scope=$5 + local output=$6 + python3 - "$key_id" "$principal" "$purpose" "$scope" "$output.signing-input" <<'PY' import base64 import json import sys @@ -185,12 +186,13 @@ claims = { "jti": f"adopter-{now}-{sys.argv[2]}-{sys.argv[3] or 'none'}", "registry_actor_kind": "service", "registry_principal": sys.argv[2], + "scope": sys.argv[4], "sub": sys.argv[2], } if sys.argv[3]: claims["registry_purpose"] = sys.argv[3] header = {"alg": "EdDSA", "kid": sys.argv[1], "typ": "JWT"} -open(sys.argv[4], "w", encoding="ascii").write(f"{b64(header)}.{b64(claims)}") +open(sys.argv[5], "w", encoding="ascii").write(f"{b64(header)}.{b64(claims)}") PY openssl pkeyutl -sign -rawin -inkey "$private_key" -in "$output.signing-input" -out "$output.signature" python3 - "$output.signing-input" "$output.signature" "$output" <<'PY' @@ -577,9 +579,9 @@ chmod 600 "$temporary_root/oidc-signer.pem" write_public_jwk "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "$temporary_root/oidc-signer.public.jwk" write_jwks "$temporary_root/oidc-signer.public.jwk" "$temporary_root/secrets/oidc-jwks" -write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-asset-operator" "asset-management" "$temporary_root/secrets/operator-token" -write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-site-planner" "site-planning" "$temporary_root/secrets/planner-token" -write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-site-planner" "" "$temporary_root/secrets/planner-no-purpose-token" +write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-asset-operator" "asset-management" "asset:manage" "$temporary_root/secrets/operator-token" +write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-site-planner" "site-planning" "asset:plan" "$temporary_root/secrets/planner-token" +write_jwt "$temporary_root/oidc-signer.pem" "adopter-oidc-key" "synthetic-site-planner" "" "asset:plan" "$temporary_root/secrets/planner-no-purpose-token" cat >"$temporary_root/schema-test-credentials.yaml" <<'EOF' apiVersion: id.registrystack.org/formats/breg/schema-test-credentials/v1 diff --git a/products/breg/scripts/test-postgres.sh b/products/breg/scripts/test-postgres.sh index 2b07fdf3ff..3e62cc3bcc 100755 --- a/products/breg/scripts/test-postgres.sh +++ b/products/breg/scripts/test-postgres.sh @@ -120,6 +120,7 @@ postgres_targets=( postgres_proposal_review_delivery postgres_proposal_guard_failure postgres_proposal_security + postgres_proposal_subject postgres_proposal_s3 postgres_record_attachments postgres_facility_proposal diff --git a/products/breg/scripts/test_validate_product.py b/products/breg/scripts/test_validate_product.py index d68b68b432..15b9b16689 100644 --- a/products/breg/scripts/test_validate_product.py +++ b/products/breg/scripts/test_validate_product.py @@ -74,16 +74,17 @@ def test_security_range_and_negative_ids_are_closed(self) -> None: ) extension_rows = matrix["invariants"][24:] self.assertEqual( - [f"BREG-NEG-{index:02d}" for index in range(25, 247) if index not in {61, 62}], + [f"BREG-NEG-{index:02d}" for index in range(25, 275) if index not in {61, 62}], [invariant["negativeId"] for invariant in extension_rows], ) for invariant in extension_rows: with self.subTest(invariant=invariant["id"]): - self.assertEqual("enforced", invariant["state"]) + planned = invariant["id"] == "BREG-SEC-256" + self.assertEqual("planned" if planned else "enforced", invariant["state"]) + self.assertEqual(not planned, "negativeTest" in invariant) self.assertTrue(invariant["threat"]) self.assertTrue(invariant["enforcementPoint"]) self.assertTrue(invariant["refusal"]) - self.assertIn("negativeTest", invariant) def test_w0_crate_boundary_includes_clients_and_opt_in_runtime(self) -> None: root = tomllib.loads( diff --git a/products/breg/scripts/validate_product.py b/products/breg/scripts/validate_product.py index 6d3e4979cc..78cc3b1525 100644 --- a/products/breg/scripts/validate_product.py +++ b/products/breg/scripts/validate_product.py @@ -31,7 +31,7 @@ CONTRACT_STATES = {"enforced", "partial", "planned"} V1_REQUIREMENT_IDS = tuple(f"BREG-V1-{index:02d}" for index in range(1, 45)) ACCEPTANCE_JOURNEY_IDS = tuple(f"BREG-J{index:02d}" for index in range(1, 25)) -SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 247) if index not in {61, 62}) +SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 275) if index not in {61, 62}) ACCEPTANCE_FIXTURES = { "BREG-J01": ("asset-site-placement", "acceptance/asset-site-placement"), "BREG-J02": ("asset-site-placement", "acceptance/asset-site-placement"), @@ -171,6 +171,7 @@ "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_review_delivery", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_guard_failure", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_security", + "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_subject", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_s3", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_record_attachments", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_facility_proposal", diff --git a/products/casework/examples/canonical-review/README.md b/products/casework/examples/canonical-review/README.md index b1f887b649..f1e5311fe2 100644 --- a/products/casework/examples/canonical-review/README.md +++ b/products/casework/examples/canonical-review/README.md @@ -75,7 +75,7 @@ reviewer identity and check the receipt before attempting another write. On your copy of the paired facility project, enable `readableReviewProgress: true` on the `facility-correction-author` grant for `correct-address`. -That grant already declares `ownership: caller` and `get-review-status`. +That grant already declares `party: owner` and `get-review-status`. In the paired Casework project, configure the stages of `facility-address-review` with the codes you want applicants to see. diff --git a/products/coordinator/scripts/real_service_fixtures.py b/products/coordinator/scripts/real_service_fixtures.py index 6848f4efca..8fc08c9b45 100644 --- a/products/coordinator/scripts/real_service_fixtures.py +++ b/products/coordinator/scripts/real_service_fixtures.py @@ -180,7 +180,7 @@ def proposal_action(identifier, value_field, value_type, target_field): ] profiles[0]["permissions"]["proposals"] = [ {"action": action["id"], "operations": ["get", "submit", "cancel"], - "ownership": "caller", "targets": targets} + "party": "owner", "targets": targets} for action in actions ] profiles[2]["permissions"]["proposals"] = [{"action": "correct-email", diff --git a/products/evidence/OPERATOR-CONTRACT.md b/products/evidence/OPERATOR-CONTRACT.md index ed704378fc..3be532f3ef 100644 --- a/products/evidence/OPERATOR-CONTRACT.md +++ b/products/evidence/OPERATOR-CONTRACT.md @@ -1076,7 +1076,7 @@ series and one refusal counter are published: | `evidence_http_request_duration_seconds` | histogram | Duration of those requests | | `evidence_request_refusals_total{check}` | counter | Requests refused with `401`, `403` or `429`, by the check that refused them | -The refusal counter has one label, `check`. Its values are the closed set of 45 +The refusal counter has one label, `check`. Its values are the closed set of 46 failed-check names (for example `credential-missing`, `token-signature`, `scope`, `access-profile`, `purpose`, `revision-pin` and `rate-limit`), and every value is published at zero from startup. No caller value becomes a label. Each refusal diff --git a/products/platform/CHANGELOG.md b/products/platform/CHANGELOG.md index 2e4d59f2a5..748029e7da 100644 --- a/products/platform/CHANGELOG.md +++ b/products/platform/CHANGELOG.md @@ -149,6 +149,7 @@ The runner pins the checked numeric address in the generated product URLs. Verified TLS remains the default. Production and `provision` keep their existing transport rules. +- The closed set of refusal checks includes `membership` in the admission class. ## 0.50.0 - 2026-12-01 diff --git a/products/platform/journeys/projects/composed_fixtures.py b/products/platform/journeys/projects/composed_fixtures.py index c501a2126d..b5c5ca73d2 100644 --- a/products/platform/journeys/projects/composed_fixtures.py +++ b/products/platform/journeys/projects/composed_fixtures.py @@ -310,7 +310,7 @@ def permission(operations, fields, *, writable=False): { "action": "correct-email", "operations": ["get", "submit", "cancel"], - "ownership": "caller", + "party": "owner", "targets": targets, } ], From 1bf4a9908772e0f71c31bb14392a79100afdd052 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 00:57:12 +0000 Subject: [PATCH 02/96] feat(breg): preflight archived reader and applicant replay Provisional source checkpoint for protected replay. Regenerate product and binding outputs and establish native proof on the protected integration before release. Signed-off-by: Jeremi Joslin --- .github/workflows/ci.yml | 2 +- clients/typescript/tests/casework.test.ts | 42 + clients/typescript/tests/live/harness.ts | 2 + .../__test__/additions.test.js | 55 +- .../__test__/review-documents.test.js | 2 +- .../__test__/review-messages.test.js | 72 + crates/registry-breg-client-node/client.d.ts | 46 +- crates/registry-breg-client-node/client.js | 4 +- crates/registry-breg-client-node/src/lib.rs | 209 +- .../python/registry_breg_client/__init__.pyi | 34 +- crates/registry-breg-client-py/src/lib.rs | 235 +- .../tests/python/test_additions.py | 58 +- .../tests/python/test_review_documents.py | 2 +- crates/registry-breg-client/src/client.rs | 13 +- crates/registry-breg-client/src/error.rs | 18 +- crates/registry-breg-client/src/metadata.rs | 53 + crates/registry-breg-client/src/proposal.rs | 89 +- .../registry-breg-client/src/proposal/asks.rs | 58 +- .../src/proposal/forms.rs | 145 ++ .../src/proposal/messages.rs | 435 ++++ .../src/proposal/review_asks.rs | 7 +- .../tests/proposal_document_boundary.rs | 1 + .../tests/write_http_boundary.rs | 5 + crates/registry-breg/src/api/attachments.rs | 2 + crates/registry-breg/src/api/mod.rs | 17 + crates/registry-breg/src/api/proposals.rs | 98 +- .../src/api/proposals/answers.rs | 48 +- .../registry-breg/src/api/proposals/forms.rs | 138 ++ .../src/api/proposals/messages.rs | 376 ++++ crates/registry-breg/src/artifacts.rs | 143 +- crates/registry-breg/src/audit.rs | 3 +- .../registry-breg/src/authoring_integrity.rs | 21 + crates/registry-breg/src/compiler.rs | 12 +- .../src/compiler/review_context.rs | 21 + crates/registry-breg/src/contract.rs | 389 +++- crates/registry-breg/src/fixtures.rs | 292 ++- .../registry-breg/src/fixtures/proposals.rs | 557 ++++- crates/registry-breg/src/hooks.rs | 5 + crates/registry-breg/src/idempotency.rs | 82 +- crates/registry-breg/src/immediate_actions.rs | 227 +- crates/registry-breg/src/lib.rs | 2 + crates/registry-breg/src/lifecycle.rs | 46 +- crates/registry-breg/src/membership.rs | 3 +- crates/registry-breg/src/model.rs | 23 + crates/registry-breg/src/mutation.rs | 14 +- crates/registry-breg/src/mutation/proposal.rs | 260 ++- .../src/mutation/proposal/asks.rs | 131 +- .../mutation/proposal/context_projection.rs | 16 + .../src/mutation/proposal/forms.rs | 394 ++++ .../src/mutation/proposal/messages.rs | 1023 +++++++++ crates/registry-breg/src/package.rs | 525 ++++- .../src/package/tests/predecessor_sources.rs | 768 +++++++ crates/registry-breg/src/postgres/catalog.rs | 1 + crates/registry-breg/src/postgres/mutation.rs | 21 + crates/registry-breg/src/postgres/proposal.rs | 28 +- .../src/postgres/proposal_context.rs | 9 + .../src/postgres/proposal_messages.rs | 210 ++ crates/registry-breg/src/problem.rs | 19 +- crates/registry-breg/src/problem_location.rs | 21 + .../registry-breg/src/proposal_artifacts.rs | 254 ++- crates/registry-breg/src/proposal_ddl.rs | 1 + crates/registry-breg/src/proposal_events.rs | 21 +- crates/registry-breg/src/proposal_hooks.rs | 9 +- crates/registry-breg/src/proposal_messages.rs | 362 ++++ .../registry-breg/src/proposal_retention.rs | 170 +- crates/registry-breg/src/proposal_store.rs | 36 +- crates/registry-breg/src/proposal_workflow.rs | 19 + crates/registry-breg/src/review_store.rs | 5 + crates/registry-breg/src/review_store/asks.rs | 72 +- crates/registry-breg/src/startup.rs | 51 +- .../registry-breg/tests/compiled_ddl_pins.rs | 2 + .../registry-breg/tests/compiler_contract.rs | 3 + .../automatic-application/journeys.yaml | 35 + .../automatic-application/never-applied.yaml | 25 + .../automatic-application/project.yaml | 54 + .../fixtures/message-journeys/journeys.yaml | 52 + .../fixtures/message-journeys/project.yaml | 50 + .../tests/native_inspection_inventory.rs | 3 +- .../tests/postgres_fixture_journeys.rs | 339 ++- .../tests/postgres_proposal_messages.rs | 1881 +++++++++++++++++ .../tests/postgres_record_timer_metrics.rs | 3 + .../tests/postgres_record_timer_native.rs | 19 +- .../tests/proposal_additional_forms.rs | 398 ++++ crates/registry-breg/tests/proposal_asks.rs | 32 + .../tests/proposal_messages_compiler.rs | 233 ++ .../tests/schema_fingerprint_rehearsal.rs | 4 +- .../tests/support/proposal_additions.rs | 443 ++++ .../support/proposal_additions_authority.rs | 2 +- .../tests/support/proposal_review_asks.rs | 471 ++++- .../tests/support/webhook_retention_logs.rs | 7 +- crates/registry-bregctl/src/hook_lifecycle.rs | 8 +- crates/registry-bregctl/src/lib.rs | 2 +- .../tests/explain_contract.rs | 4 +- .../tests/wasm_test_lifecycle.rs | 343 ++- crates/registry-casework-breg/src/lib.rs | 7 + .../tests/context_provider.rs | 86 + .../__test__/ask-limit.test.js | 35 +- .../registry-casework-client-node/client.d.ts | 6 +- .../registry_casework_client/__init__.pyi | 14 +- .../tests/python/test_ask_limit.py | 35 +- crates/registry-casework-client/src/error.rs | 27 +- crates/registry-casework-client/src/wire.rs | 18 + crates/registry-casework-core/src/adapter.rs | 6 + crates/registry-casework-core/src/review.rs | 88 + .../src/review_answer.rs | 15 + crates/registry-casework/src/http.rs | 4 + .../src/http/source_credentials.rs | 2 + crates/registry-casework/src/problem.rs | 7 + crates/registry-casework/src/review.rs | 34 + crates/registry-casework/src/review/asks.rs | 18 +- .../src/review/source_answers.rs | 37 + .../src/task_grants/http_tests.rs | 2 + .../src/task_grants/native_exchange_tests.rs | 2 + .../tests/review_acceptance_postgres.rs | 2 + crates/registry-casework/tests/review_http.rs | 14 + .../tests/review_postgres.rs | 2 + .../tests/support/ask_form_http.rs | 110 + .../tests/support/source_ask_answers.rs | 51 +- crates/registry-review-client/src/client.rs | 1 + .../tests/http_boundary.rs | 81 + crates/registry-review-protocol/src/lib.rs | 30 +- .../tests/form_want.rs | 26 + .../content/docs/configure/breg-journeys.mdx | 56 +- .../content/docs/configure/breg-proposals.mdx | 132 +- .../src/content/docs/configure/casework.mdx | 2 +- .../content/docs/operate/breg-webhooks.mdx | 3 +- .../src/content/docs/reference/breg-api.mdx | 54 +- docs/site/src/content/docs/security/breg.mdx | 93 +- .../src/content/docs/security/casework.mdx | 11 + docs/site/src/data/breg-api.yaml | 3 + docs/site/src/data/breg-events.yaml | 3 +- docs/site/src/data/casework-api.yaml | 1 + products/breg/CHANGELOG.md | 11 +- .../explain/EventsExplanation.schema.json | 3 +- .../explain/LifecycleExplanation.schema.json | 12 +- .../contracts/security-invariant-matrix.yaml | 15 + .../contracts/security-test-traceability.yaml | 16 + .../breg/examples/minimal/tests/journeys.yaml | 29 + products/breg/scripts/test-postgres.sh | 1 + .../breg/scripts/test_validate_product.py | 2 +- products/breg/scripts/validate_product.py | 3 +- products/casework/CHANGELOG.md | 3 + .../identifiers/contracts/catalog-source.json | 2 +- products/platform/config-formats.yaml | 6 +- 144 files changed, 13722 insertions(+), 444 deletions(-) create mode 100644 crates/registry-breg-client-node/__test__/review-messages.test.js create mode 100644 crates/registry-breg-client/src/proposal/forms.rs create mode 100644 crates/registry-breg-client/src/proposal/messages.rs create mode 100644 crates/registry-breg/src/api/proposals/forms.rs create mode 100644 crates/registry-breg/src/api/proposals/messages.rs create mode 100644 crates/registry-breg/src/mutation/proposal/forms.rs create mode 100644 crates/registry-breg/src/mutation/proposal/messages.rs create mode 100644 crates/registry-breg/src/postgres/proposal_messages.rs create mode 100644 crates/registry-breg/src/proposal_messages.rs create mode 100644 crates/registry-breg/tests/fixtures/automatic-application/journeys.yaml create mode 100644 crates/registry-breg/tests/fixtures/automatic-application/never-applied.yaml create mode 100644 crates/registry-breg/tests/fixtures/automatic-application/project.yaml create mode 100644 crates/registry-breg/tests/fixtures/message-journeys/journeys.yaml create mode 100644 crates/registry-breg/tests/fixtures/message-journeys/project.yaml create mode 100644 crates/registry-breg/tests/postgres_proposal_messages.rs create mode 100644 crates/registry-breg/tests/proposal_additional_forms.rs create mode 100644 crates/registry-breg/tests/proposal_messages_compiler.rs create mode 100644 crates/registry-casework/tests/support/ask_form_http.rs create mode 100644 crates/registry-review-protocol/tests/form_want.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec0ea39c7c..4e7905196d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2012,7 +2012,7 @@ jobs: # of this feature set. - name: Base Registry Engine schema-gated tests if: matrix.lane == 'contracts' - run: cargo test --locked -p registry-breg --features runtime,tooling,schema --lib --test action_evidence_compiler --test proposal_hooks --test value_type_consistency + run: cargo test --locked -p registry-breg --features runtime,tooling,schema --lib --test action_evidence_compiler --test proposal_additional_forms --test proposal_hooks --test value_type_consistency - name: BReg client contract consistency if: matrix.lane == 'contracts' diff --git a/clients/typescript/tests/casework.test.ts b/clients/typescript/tests/casework.test.ts index cdf5d1d2cf..435ffe302e 100644 --- a/clients/typescript/tests/casework.test.ts +++ b/clients/typescript/tests/casework.test.ts @@ -78,3 +78,45 @@ test('Casework returns an empty pending answer and rejects an undeclared bare st assert.equal(data, undefined) await assert.rejects(client(410).call('getReviewAsk', { path: ask }), { kind: 'unexpected', status: 410 }) }) + +test('Casework accepts source threads with absent optional fields and still requires message identity', async () => { + const digest = 'sha256:' + '0'.repeat(64) + const policy = { id: 'address-review', version: '1', digest } + const taskContext = { + taskId: id, requestId: id, requesterReference: 'case-1', policy, + subject: { id, source: 'registry', type: 'proposal', version: '1', digest }, + context: { mode: 'current-source', reference: 'proposal-ref', bindingStatus: 'current' }, + policyClosure: { + identity: policy, purpose: 'approval', stages: [], displaySchema: { type: 'object' }, + context: { mode: 'current-source', provider: 'registry', contract: { id: 'context', revision: digest, schemaDigest: digest } }, + retention: { terminalRetentionDays: 30, accountabilityRetentionDays: 30 }, + dependencies: { + accessProfiles: [], queues: [], teams: [], clocks: [], calendars: [], + contextProvider: null, taskTemplates: [], trustedProducers: [], + inbox: { defaultPageSize: 25, maximumCandidateScan: 100, maximumSourceReads: 25, + maximumConcurrentSourceReads: 4, pageDeadlineMilliseconds: 2000 }, + }, + }, + } + const sentAt = '2026-12-01T10:00:00.000000Z' + const official = { id, from: 'official', mine: true, sentAt, text: 'Received' } + const erased = { id: '00000000-0000-4000-8000-000000000002', from: 'party', partyRole: 'owner', mine: false, sentAt } + const link = { path: '/v1/proposals/' + id + '/messages', accessProfile: 'reviewer', operation: 'message' } + const availability = { available: true, observedRevision: 2 } + const links = { + message: { ...link, method: 'POST', ifMatch: '"proposal-2"', availability }, + markRead: { ...link, method: 'POST', path: link.path + '/read', availability }, + list: { ...link, method: 'GET', availability }, + } + const readContext = (messages: unknown) => client(200, JSON.stringify({ ...taskContext, messages }), + { 'content-type': 'application/json', traceparent }).call('getReviewTaskContext', { path: { task_id: id } }) + + const thread = { count: 2, unread: 1, lastSentAt: sentAt, items: [erased, official], links } + assert.equal((await readContext(undefined)).data.messages, undefined) + for (const messages of [{ count: 0, unread: 0, items: [], links }, { count: 2, unread: 1, lastSentAt: sentAt }, thread]) { + const { data } = await readContext(messages) + assert.deepEqual(data.messages, messages) + } + const { id: _id, ...withoutIdentity } = official + await assert.rejects(readContext({ ...thread, items: [withoutIdentity] }), { kind: 'unexpected', reason: 'schema', status: 200 }) +}) diff --git a/clients/typescript/tests/live/harness.ts b/clients/typescript/tests/live/harness.ts index 8ace60a5d8..a430a53fd3 100644 --- a/clients/typescript/tests/live/harness.ts +++ b/clients/typescript/tests/live/harness.ts @@ -1029,6 +1029,8 @@ export function stageMainPlan(root: string, dhis2Origin: string): string { 'read-updated-contact': 'editor', 'start-registration': 'editor', 'submit-registration': 'editor', + 'await-registration': 'editor', + 'read-registered-contact': 'editor', }, }, journeyFile: 'dev-journeys.yaml', diff --git a/crates/registry-breg-client-node/__test__/additions.test.js b/crates/registry-breg-client-node/__test__/additions.test.js index b8d16ef376..7803220f31 100644 --- a/crates/registry-breg-client-node/__test__/additions.test.js +++ b/crates/registry-breg-client-node/__test__/additions.test.js @@ -16,6 +16,11 @@ test('additions preserve the submitted version and use exact binary exchanges', const document = {id, actionId: 'correct', actionRevision: revision, submissionVersion: 1, revision: 2, state: 'submitted', effectDigest: revision, links: {}, additions: {other: {id: 'other', maximumBytes: 64, maximumCount: 2, contentTypes: ['text/plain'], classification: 'restricted', items: [], links: {add: {method: 'POST', path: `/v1/proposals/${id}/additions/other`, accessProfile: 'writer', operation: 'add', ifMatch: '"condition"'}}}}}; + const formId = 'details'; + const formEntryId = '00000000-0000-4000-8000-000000000004'; + const formPath = `/v1/proposals/${id}/additional-forms/${formId}`; + const messageId = '00000000-0000-4000-8000-000000000005'; + const threadPath = `/v1/proposals/${id}/messages`; const requests = []; const server = http.createServer(async (request, response) => { const chunks = []; for await (const chunk of request) chunks.push(chunk); @@ -27,7 +32,30 @@ test('additions preserve the submitted version and use exact binary exchanges', response.setHeader('x-content-type-options', 'nosniff'); response.setHeader('vary', 'authorization'); return response.end(bytes); } - if (request.method === 'POST') { + if (request.url.includes(threadPath)) { + response.setHeader('content-type', 'application/json'); response.setHeader('vary', 'authorization, accept'); + if (request.method === 'GET') return response.end(JSON.stringify({items: document.messages.items})); + if (!request.url.includes(threadPath + '/read')) { + const {text} = JSON.parse(requests.at(-1).body.toString()); + document.revision++; + for (const link of Object.values(document.messages.links)) link.availability.observedRevision = document.revision; + document.additions.other.links.add.availability.observedRevision = document.revision; + document.additionalForms[formId].links.add.availability.observedRevision = document.revision; + document.messages.count++; + document.messages.items.unshift({id: messageId, from: 'party', partyRole: 'owner', + mine: true, sentAt: '2026-11-27T00:00:00Z', text}); + } + return response.end(JSON.stringify(document)); + } + if (request.method === 'POST' && request.url.includes(formPath)) { + document.revision++; + document.formEntryId = formEntryId; + document.additions.other.links.add.availability.observedRevision = document.revision; + const slot = document.additionalForms[formId]; + slot.items.push({id: formEntryId, submissionVersion: 1, addedAt: '2026-11-27T00:00:00Z', + input: JSON.parse(requests.at(-1).body.toString()).input}); + slot.links.add.availability.observedRevision = document.revision; + } else if (request.method === 'POST') { document.revision++; document.additions.other.items.push({id: file, submissionVersion: 1, sha256: createHash('sha256').update(bytes).digest('hex'), byteSize: bytes.length, contentType: 'text/plain', addedAt: '2026-11-27T00:00:00Z', verificationStatus: 'notRequired', @@ -60,5 +88,30 @@ test('additions preserve the submitted version and use exact binary exchanges', const retained = await client.getProposal(contract.selectProposalGet('writer'), id); assert.equal(JSON.parse(retained.documentJson).additions.other.items.length, 2); assert.deepEqual((await client.downloadProposalAddition(retained, file)).body, bytes); + document.additionalForms = {[formId]: {id: formId, maximumCount: 2, items: [], + links: {add: {method: 'POST', path: formPath, accessProfile: 'writer', operation: 'add', + ifMatch: '"form-condition"', availability: {available: true, observedRevision: document.revision}}}}}; + const withForm = await client.getProposal(contract.selectProposalGet('writer'), id); + const sent = await client.addProposalFormEntry(withForm, formId, {confirmed: true}, 'form-one'); + assert.equal(JSON.parse(sent.documentJson).formEntryId, formEntryId); + assert.deepEqual(JSON.parse(requests.at(-1).body.toString()), {input: {confirmed: true}}); + assert.equal(requests.at(-1).headers['idempotency-key'], 'form-one'); + assert.equal(requests.at(-1).headers['if-match'], '"form-condition"'); + const threadLink = (method, tail = '') => ({method, path: threadPath + tail, accessProfile: 'writer', + operation: 'message', availability: {available: true, observedRevision: document.revision}}); + document.messages = {count: 0, unread: 0, items: [], links: { + message: {...threadLink('POST'), ifMatch: '"message-condition"'}, + markRead: threadLink('POST', '/read'), list: threadLink('GET'), + }}; + const current = await client.getProposal(contract.selectProposalGet('writer'), id); + const delivered = await client.sendProposalMessage(current, 'literal', 'send-one'); + assert.equal(JSON.parse(delivered.documentJson).messages.items[0].text, 'literal'); + assert.equal(requests.at(-1).headers['idempotency-key'], 'send-one'); + const page = await client.listProposalMessages(delivered, null, 2); + assert.equal(page.value.items[0].id, messageId); + await client.markProposalMessagesRead(delivered, messageId); + assert.deepEqual(JSON.parse(requests.at(-1).body.toString()), {through: messageId}); + assert.equal(requests.at(-1).headers['if-match'], undefined); + assert.equal(requests.at(-1).headers['idempotency-key'], undefined); } finally { await new Promise(resolve => server.close(resolve)); } }); diff --git a/crates/registry-breg-client-node/__test__/review-documents.test.js b/crates/registry-breg-client-node/__test__/review-documents.test.js index ee23492e7a..75d6fedaa0 100644 --- a/crates/registry-breg-client-node/__test__/review-documents.test.js +++ b/crates/registry-breg-client-node/__test__/review-documents.test.js @@ -53,7 +53,7 @@ test('review-only binding reads context and exact document without Proposal Get' const binding = contract.selectProposalReviewContext('reviewer', 'correct'); assert.ok(binding instanceof BRegProposalReviewBinding); const observed = (await client.readProposalReviewById(binding, id)).value; - assert.equal(new URL(requests.at(-1), 'http://local').searchParams.get('include'), 'answers'); + assert.deepEqual(new URL(requests.at(-1), 'http://local').searchParams.getAll('include'), ['answers', 'messages']); const batch = await client.readProposalReviewContextBatch(binding, [id, concealedId]); assert.deepEqual(batch.value, [observed, null]); const batchUrl = new URL(requests.at(-1), 'http://local'); diff --git a/crates/registry-breg-client-node/__test__/review-messages.test.js b/crates/registry-breg-client-node/__test__/review-messages.test.js new file mode 100644 index 0000000000..1264878da1 --- /dev/null +++ b/crates/registry-breg-client-node/__test__/review-messages.test.js @@ -0,0 +1,72 @@ +'use strict'; +const assert = require('node:assert/strict'); +const http = require('node:http'); +const { test } = require('node:test'); +const { BaseRegistryClient } = require('..'); + +// A reviewer writes through the review context's thread link. BReg answers +// with the review context, with the Proposal document when the profile also +// holds Get, or with the thread alone while no review context is readable. +test('a review-context thread write accepts each answer BReg gives a reviewer', async () => { + const id = '00000000-0000-4000-8000-000000000001'; + const question = '00000000-0000-4000-8000-000000000002'; + const reply = '00000000-0000-4000-8000-000000000003'; + const revision = `sha256:${'a'.repeat(64)}`; + const threadPath = `/v1/proposals/${id}/messages`; + const metadata = { id: 'review-messages', version: '1', revision, metadataVersion: '2', + recordTypes: [], operations: [], actions: [], proposals: { actions: [ + { actionId: 'correct', accessProfile: 'reviewer', operations: ['get-review-context', 'message'], + readableInputs: [], readableContextFields: [] }, + ] } }; + let observed = 2; + const link = (method, tail = '') => ({ method, path: threadPath + tail, accessProfile: 'reviewer', + operation: 'message', availability: { available: true, observedRevision: observed } }); + const thread = items => ({ count: items.length, unread: 0, items, links: { + message: { ...link('POST'), ifMatch: `"condition-${observed}"` }, + markRead: link('POST', '/read'), list: link('GET') } }); + const party = { id: question, from: 'party', partyRole: 'owner', mine: false, + sentAt: '2026-12-01T10:00:00Z', text: 'Is a scan enough?' }; + const mine = text => ({ id: reply, from: 'official', mine: true, sentAt: '2026-12-01T10:01:00Z', text }); + const context = items => ({ id, actionId: 'correct', actionRevision: revision, submissionVersion: 1, + revision: observed, effectDigest: revision, + subject: { source: 'review-messages', subjectType: 'proposal', id, version: '1', digest: revision }, + reviewable: true, context: { reference: 'opaque', + contract: { id: 'urn:registry:breg:review-context:review-messages:correct:review', revision, schemaDigest: revision }, + fields: {}, messages: thread(items) } }); + const proposal = items => ({ id, actionId: 'correct', actionRevision: revision, submissionVersion: 1, + revision: observed, state: 'submitted', effectDigest: revision, links: {}, messages: thread(items) }); + let answer = 'review'; + const requests = []; + const server = http.createServer(async (request, response) => { + const chunks = []; for await (const chunk of request) chunks.push(chunk); + requests.push({ method: request.method, url: request.url, body: Buffer.concat(chunks) }); + response.setHeader('traceparent', '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'); + response.setHeader('cache-control', 'no-store'); + response.setHeader('vary', 'authorization, accept'); + response.setHeader('content-type', 'application/json'); + if (request.url.includes('/registry?')) return response.end(JSON.stringify(metadata)); + if (request.method === 'GET') return response.end(JSON.stringify(context([party]))); + observed += 1; + const items = [mine(JSON.parse(requests.at(-1).body.toString()).text), party]; + const body = answer === 'review' ? context(items) : answer === 'proposal' ? proposal(items) : thread(items); + return response.end(JSON.stringify(body)); + }); + await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); + try { + const client = new BaseRegistryClient({ baseUrl: `http://127.0.0.1:${server.address().port}/tenant/` }); + const contract = await client.registryContract('reviewer'); + const binding = contract.selectProposalReviewContext('reviewer', 'correct'); + for (const [kind, member] of [['review', value => value.context.messages], ['proposal', value => value.messages], + ['thread', value => value]]) { + answer = kind; + observed = 2; + const read = (await client.readProposalReviewById(binding, id)).value; + const sent = await client.sendProposalMessageFromReview(binding, read, `Reply as ${kind}`, `reply-${kind}`); + const items = member(sent.value).items; + assert.equal(items[0].text, `Reply as ${kind}`, kind); + assert.equal(items[0].mine, true, kind); + assert.equal(requests.at(-1).url, `/tenant${threadPath}?accessProfile=reviewer`); + if (kind === 'thread') assert.equal(sent.value.context, undefined); + } + } finally { await new Promise(resolve => server.close(resolve)); } +}); diff --git a/crates/registry-breg-client-node/client.d.ts b/crates/registry-breg-client-node/client.d.ts index b8b235cb19..2d44d6a4fc 100644 --- a/crates/registry-breg-client-node/client.d.ts +++ b/crates/registry-breg-client-node/client.d.ts @@ -537,6 +537,8 @@ export interface BRegActionAttachmentDescriptor { } export interface BRegActionDescriptor { + readonly messages: {readonly maximumCount: number; readonly maximumTextBytes: 2000} | null + readonly additionalForms: Readonly> readonly attachments: ReadonlyArray readonly apiName: string readonly revision: string @@ -1020,6 +1022,13 @@ export declare class BaseRegistryClient { downloadProposalAttachment(proposal: BRegProposal, slot: string): Promise answerProposalAsk(proposal: BRegProposal, askId: string, body: BRegProposalAnswerRequest, key: string): Promise downloadProposalAddition(proposal: BRegProposal, addition: string): Promise + sendProposalMessage(proposal: BRegProposal, text: string, key: string): Promise + listProposalMessages(proposal: BRegProposal, after?: string | null, limit?: number): Promise + markProposalMessagesRead(proposal: BRegProposal, through: string): Promise + sendProposalMessageFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, text: string, key: string): Promise + listProposalMessagesFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, after?: string | null, limit?: number): Promise + markProposalMessagesReadFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, through: string): Promise + addProposalFormEntry(proposal: BRegProposal, formId: string, input: JsonObject, key: string): Promise addProposalAddition(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise readProposalReviewStatus(proposal: BRegProposal, request?: ReadRequestOptions): Promise> readProposalReviewStatusWithProgress(proposal: BRegProposal, request?: ReadRequestOptions): Promise> @@ -1101,11 +1110,30 @@ export interface BRegProposalApplicationStatus { readonly recovery?: 'retry' | 'rebase' | 'revise' | 'correct-input' readonly automaticRetry?: {readonly scheduled: boolean; readonly attempts: number; readonly maximumAttempts: number} } +export interface BRegProposalMessage { + readonly id: string; readonly from: 'party' | 'official'; readonly partyRole?: 'owner' | 'subject'; + readonly mine: boolean; readonly sentAt: string; readonly text?: string; +} +export interface BRegProposalMessages { + readonly count: number; readonly unread: number; readonly lastSentAt?: string; + readonly items?: ReadonlyArray; + readonly links?: Readonly>>; +} +export interface BRegProposalMessagePage { + readonly items: ReadonlyArray; readonly nextCursor?: string; +} +export interface BRegMessagePageOutcome { + readonly kind: 'complete'; readonly value: BRegProposalMessagePage; readonly traceId: string; +} +export interface BRegReviewMessageOutcome { + readonly kind: 'complete'; readonly value: BRegProposalReviewDocument; + readonly traceId: string; readonly etag?: string; +} export interface BRegProposalReviewDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string readonly submissionVersion: number; readonly revision: number; readonly effectDigest: string; readonly reviewable: boolean readonly subject: {readonly source: string; readonly subjectType: 'proposal'; readonly id: string; readonly version: string; readonly digest: string} - readonly context: {readonly reference: string; readonly contract?: {readonly id: string; readonly revision: string; readonly schemaDigest: string}; readonly fields?: Readonly>; readonly asks?: ReadonlyArray} + readonly context: {readonly reference: string; readonly contract?: {readonly id: string; readonly revision: string; readonly schemaDigest: string}; readonly fields?: Readonly>; readonly additionalForms?: Readonly>; readonly messages?: BRegProposalMessages; readonly asks?: ReadonlyArray} readonly requestId?: string /** Present only on an explicit progress status read while the accepted request remains pending. */ readonly progressCode?: string @@ -1130,7 +1158,7 @@ export interface BRegProposalSubmission { readonly decision?: BRegProposalDecision readonly handoffRefusal?: BRegProposalHandoffRefusal } -export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } +export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly additionalForms?: Readonly>; readonly formEntryId?: string; readonly messages?: BRegProposalMessages; readonly asks?: ReadonlyArray } export declare class BRegProposal { private constructor(); private readonly __opaque: void; readonly responseEtag: string | null; readonly identifier: string; readonly actionIdentifier: string; readonly documentJson: string; readonly inputJson?: string | null } export declare class BRegProposalGetBinding { private constructor(); private readonly __opaque: void } export declare class BRegProposalReviewBinding { private constructor(); private readonly __opaque: void } @@ -1155,9 +1183,15 @@ export declare class BRegPreparedProposal { private constructor(); private reado export type BRegProposalAskState = 'open' | 'answered' | 'expired' | 'closed' -export type BRegProposalAskWant = {readonly kind: 'answer'} | {readonly kind: 'document'} -export interface BRegProposalAnswerRequest {readonly text?: string; readonly additions?: ReadonlyArray} -export interface BRegProposalAskAnswer {readonly text?: string; readonly additions: ReadonlyArray; readonly answeredAt: string} +export type BRegProposalAskWant = {readonly kind: 'answer'} | {readonly kind: 'document'} | {readonly kind: 'form'; readonly form: string} +export interface BRegReviewFormEntry { readonly id: string; readonly addedAt: string; readonly input?: JsonObject; readonly contractChanged?: boolean } +export interface BRegProposalFormEntry extends BRegReviewFormEntry { readonly submissionVersion: number } +export interface BRegProposalForm { + readonly id: string; readonly maximumCount: number; readonly items?: ReadonlyArray; + readonly links?: Readonly>>; +} +export interface BRegProposalAnswerRequest {readonly text?: string; readonly additions?: ReadonlyArray; readonly formEntries?: ReadonlyArray} +export interface BRegProposalAskAnswer {readonly text?: string; readonly additions: ReadonlyArray; readonly formEntries?: ReadonlyArray; readonly answeredAt: string} export interface BRegProposalAsk { readonly id: string; readonly text: string; readonly wants: ReadonlyArray readonly askedAt: string; readonly dueAt?: string; readonly state: BRegProposalAskState @@ -1168,5 +1202,5 @@ export interface BRegProposalReviewAnswerDocument { readonly id: string; readonly sha256: string; readonly contentType: string; readonly byteSize: number readonly verificationStatus: 'notRequired' | 'pending' | 'approved' | 'rejected'; readonly download?: BRegProposalReviewAnswerDownload } -export interface BRegProposalReviewAnswer {readonly text?: string; readonly documents: ReadonlyArray; readonly answeredAt: string} +export interface BRegProposalReviewAnswer {readonly text?: string; readonly documents: ReadonlyArray; readonly formEntries?: ReadonlyArray; readonly answeredAt: string} export interface BRegProposalReviewAsk extends Omit {readonly answer?: BRegProposalReviewAnswer} diff --git a/crates/registry-breg-client-node/client.js b/crates/registry-breg-client-node/client.js index 4382702991..837311f27c 100644 --- a/crates/registry-breg-client-node/client.js +++ b/crates/registry-breg-client-node/client.js @@ -304,7 +304,9 @@ for (const [method, jsonIndexes, requiredIndexes] of [ ['startProposal', [1], [1]], ['readProposal'], ['readProposalSubmission'], ['getProposal'], ['listProposals', [1], [1]], ['executeProposal'], ['listProposalsJson'], ['downloadProposalAttachment'], ['uploadProposalAttachment'], ['deleteProposalAttachment'], ['answerProposalAsk'], - ['addProposalAddition'], ['downloadProposalAddition'], + ['sendProposalMessage'], ['listProposalMessages'], ['markProposalMessagesRead'], + ['sendProposalMessageFromReview'], ['listProposalMessagesFromReview'], ['markProposalMessagesReadFromReview'], + ['addProposalFormEntry'], ['addProposalAddition'], ['downloadProposalAddition'], ['downloadRecordAttachment'], ['readProposalReviewStatus'], ['readProposalReviewStatusWithProgress'], ['readProposalReviewContext'], ['readProposalReviewContextBatch', [1], [1]], diff --git a/crates/registry-breg-client-node/src/lib.rs b/crates/registry-breg-client-node/src/lib.rs index 81ce45814e..59ab389c49 100644 --- a/crates/registry-breg-client-node/src/lib.rs +++ b/crates/registry-breg-client-node/src/lib.rs @@ -1683,6 +1683,47 @@ fn metadata_parts( ) } +fn review_message_document( + value: Value, +) -> Result { + serde_json::from_value(value) + .map_err(|_| binding_error("invalid-request", "Expected a Proposal review document")) +} + +fn review_message_result( + result: BRegComplete, +) -> Result { + // The answer follows the reviewer's profile: the review context, the + // Proposal document when it also holds Get, or the thread alone while + // no review context is readable. + match result.value { + registry_breg_client::BRegProposalMessageOutcome::Review(document) => { + complete_value(*document, result.metadata) + } + registry_breg_client::BRegProposalMessageOutcome::Proposal(proposal) => { + complete_value(*proposal, result.metadata) + } + registry_breg_client::BRegProposalMessageOutcome::Thread(thread) => { + complete_value(*thread, result.metadata) + } + } +} + +fn proposal_message_result( + result: BRegComplete, +) -> Result { + let registry_breg_client::BRegProposalMessageOutcome::Proposal(inner) = result.value else { + return Err(binding_error( + "protocol", + "Expected a Proposal message response", + )); + }; + Ok(Proposal { + response_etag: result.metadata.etag().map(|etag| etag.as_str().to_owned()), + inner: *inner, + }) +} + fn complete_value( value: T, metadata: registry_breg_client::BRegResponseMetadata, @@ -2346,6 +2387,16 @@ impl IngestionPrefixDigest { } } +fn form_input_value(input: ®istry_breg_client::BRegActionInputDescriptor) -> Value { + json!({ + "id": input.identifier(), "apiName": input.api_name(), + "label": input.label(), "description": input.description(), + "schemaJson": input.schema().to_string(), + "fieldTypeJson": input.field_type().to_string(), "required": input.required(), + "nullable": input.nullable(), "classification": input.classification(), + }) +} + fn action_descriptor_value(value: ®istry_breg_client::BRegActionDescriptor) -> Value { let bounds = value.bounds(); json!({ @@ -2355,13 +2406,11 @@ fn action_descriptor_value(value: ®istry_breg_client::BRegActionDescriptor) - "inputMode": value.input_mode(), "maximumInputStringBytes": value.maximum_input_string_bytes(), "attachments": value.attachments(), - "inputs": value.inputs().iter().map(|input| json!({ - "id": input.identifier(), "apiName": input.api_name(), - "label": input.label(), "description": input.description(), - "schemaJson": input.schema().to_string(), - "fieldTypeJson": input.field_type().to_string(), "required": input.required(), - "nullable": input.nullable(), "classification": input.classification(), - })).collect::>(), + "inputs": value.inputs().iter().map(form_input_value).collect::>(), + "messages": value.maximum_message_count().map(|limit| json!({"maximumCount":limit,"maximumTextBytes":2000})), + "additionalForms": value.additional_forms().iter().map(|(id, inputs)| { + (id, inputs.iter().map(form_input_value).collect::>()) + }).collect::>(), "referenceInputs": value.reference_inputs().iter().map(|input| json!({ "input": input.input_identifier(), "apiName": input.api_name(), "targetRecordType": input.target_record_type(), @@ -3584,6 +3633,152 @@ impl BaseRegistryClient { .map_err(client_error) } + #[napi] + pub async fn send_proposal_message( + &self, + proposal: &Proposal, + text: String, + key: String, + ) -> Result { + let key = idempotency_key(key)?; + let result = self + .inner + .send_proposal_message( + registry_breg_client::BRegProposalMessageTarget::Proposal(&proposal.inner), + &text, + &key, + ) + .await + .map_err(client_error)?; + proposal_message_result(result) + } + + #[napi] + pub async fn list_proposal_messages( + &self, + proposal: &Proposal, + after: Option, + limit: Option, + ) -> Result { + let result = self + .inner + .list_proposal_messages( + registry_breg_client::BRegProposalMessageTarget::Proposal(&proposal.inner), + after.as_deref(), + limit.unwrap_or(20), + ) + .await + .map_err(client_error)?; + complete_value(result.value, result.metadata) + } + + #[napi] + pub async fn mark_proposal_messages_read( + &self, + proposal: &Proposal, + through: String, + ) -> Result { + let result = self + .inner + .mark_proposal_messages_read( + registry_breg_client::BRegProposalMessageTarget::Proposal(&proposal.inner), + &through, + ) + .await + .map_err(client_error)?; + proposal_message_result(result) + } + + #[napi] + pub async fn send_proposal_message_from_review( + &self, + binding: &ProposalReviewBinding, + context: Value, + text: String, + key: String, + ) -> Result { + let document = review_message_document(context)?; + let key = idempotency_key(key)?; + let target = registry_breg_client::BRegProposalMessageTarget::Review { + binding: &binding.inner, + document: &document, + }; + let result = self + .inner + .send_proposal_message(target, &text, &key) + .await + .map_err(client_error)?; + review_message_result(result) + } + + #[napi] + pub async fn list_proposal_messages_from_review( + &self, + binding: &ProposalReviewBinding, + context: Value, + after: Option, + limit: Option, + ) -> Result { + let document = review_message_document(context)?; + let target = registry_breg_client::BRegProposalMessageTarget::Review { + binding: &binding.inner, + document: &document, + }; + let result = self + .inner + .list_proposal_messages(target, after.as_deref(), limit.unwrap_or(20)) + .await + .map_err(client_error)?; + complete_value(result.value, result.metadata) + } + + #[napi] + pub async fn mark_proposal_messages_read_from_review( + &self, + binding: &ProposalReviewBinding, + context: Value, + through: String, + ) -> Result { + let document = review_message_document(context)?; + let target = registry_breg_client::BRegProposalMessageTarget::Review { + binding: &binding.inner, + document: &document, + }; + let result = self + .inner + .mark_proposal_messages_read(target, &through) + .await + .map_err(client_error)?; + review_message_result(result) + } + + #[napi( + ts_args_type = "proposal: BRegProposal, formId: string, input: Record, key: string" + )] + pub async fn add_proposal_form_entry( + &self, + proposal: &Proposal, + form_id: String, + input: Value, + key: String, + ) -> Result { + let input = input.as_object().ok_or_else(|| { + binding_error("invalid-request", "Proposal form input must be an object") + })?; + let key = idempotency_key(key)?; + self.inner + .add_proposal_form_entry(&proposal.inner, &form_id, input, &key) + .await + .map(|response| Proposal { + response_etag: response + .metadata + .etag() + .map(|etag| etag.as_str().to_owned()), + inner: response.value, + }) + .map_err(client_error) + } + #[napi] pub async fn add_proposal_addition( &self, diff --git a/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi b/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi index 546d385d60..ec0f1b4e6b 100644 --- a/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi +++ b/crates/registry-breg-client-py/python/registry_breg_client/__init__.pyi @@ -325,6 +325,19 @@ class BRegProposalActionDescriptor(TypedDict): writable_inputs: Sequence[str] | None readable_context_fields: Sequence[str] +BRegProposalMessage = TypedDict('BRegProposalMessage', { + 'id': str, 'from': Literal['party', 'official'], + 'partyRole': NotRequired[Literal['owner', 'subject']], + 'mine': bool, 'sentAt': str, 'text': NotRequired[str], +}) +class BRegProposalMessagePage(TypedDict): + items: list[BRegProposalMessage] + nextCursor: NotRequired[str] +class BRegMessagePageOutcome(TypedDict): + kind: Literal['complete'] + value: BRegProposalMessagePage + trace_id: str + class BRegProposalReviewDocument(TypedDict): id: str actionId: str @@ -697,6 +710,13 @@ class BaseRegistryClient: def download_proposal_attachment(self, proposal: BRegProposal, slot: str) -> dict[str, Any]: ... def answer_proposal_ask(self, proposal: BRegProposal, ask_id: str, body: BRegProposalAnswerRequest, key: str) -> BRegProposal: ... def download_proposal_addition(self, proposal: BRegProposal, addition: str) -> dict[str, Any]: ... + def send_proposal_message(self, proposal: BRegProposal, text: str, key: str) -> BRegProposal: ... + def list_proposal_messages(self, proposal: BRegProposal, after: str | None = None, limit: int = 20) -> BRegMessagePageOutcome: ... + def mark_proposal_messages_read(self, proposal: BRegProposal, through: str) -> BRegProposal: ... + def send_proposal_message_from_review(self, binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, text: str, key: str) -> BRegProposalReviewCompleteOutcome: ... + def list_proposal_messages_from_review(self, binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, after: str | None = None, limit: int = 20) -> BRegMessagePageOutcome: ... + def mark_proposal_messages_read_from_review(self, binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, through: str) -> BRegProposalReviewCompleteOutcome: ... + def add_proposal_form_entry(self, proposal: BRegProposal, form_id: str, input: dict[str, JsonValue], key: str) -> BRegProposal: ... def add_proposal_addition(self, proposal: BRegProposal, slot: str, content_type: str, bytes: bytes, key: str) -> BRegProposal: ... def read_proposal_review_status(self, proposal: BRegProposal) -> dict[str, Any]: ... def read_proposal_review_status_with_progress(self, proposal: BRegProposal) -> BRegProposalReviewCompleteOutcome: ... @@ -804,14 +824,20 @@ class BRegPreparedProposal: def to_bytes(self) -> bytes: ... BRegProposalAskState = Literal['open', 'answered', 'expired', 'closed'] -class BRegProposalAskWant(TypedDict): +class _BRegProposalBasicAskWant(TypedDict): kind: Literal['answer', 'document'] +class _BRegProposalFormAskWant(TypedDict): + kind: Literal['form'] + form: str +BRegProposalAskWant = _BRegProposalBasicAskWant | _BRegProposalFormAskWant class BRegProposalAnswerRequest(TypedDict): text: NotRequired[str] additions: NotRequired[list[str]] + formEntries: NotRequired[list[str]] class BRegProposalAskAnswer(TypedDict): text: NotRequired[str] additions: list[str] + formEntries: NotRequired[list[str]] answeredAt: str class BRegProposalAsk(TypedDict): id: str @@ -834,9 +860,15 @@ class BRegProposalReviewAnswerDocument(TypedDict): byteSize: int verificationStatus: Literal['notRequired', 'pending', 'approved', 'rejected'] download: NotRequired[BRegProposalReviewAnswerDownload] +class BRegReviewFormEntry(TypedDict): + id: str + addedAt: str + input: NotRequired[dict[str, JsonValue]] + contractChanged: NotRequired[bool] class BRegProposalReviewAnswer(TypedDict): text: NotRequired[str] documents: list[BRegProposalReviewAnswerDocument] + formEntries: NotRequired[list[BRegReviewFormEntry]] answeredAt: str class BRegProposalReviewAsk(TypedDict): id: str diff --git a/crates/registry-breg-client-py/src/lib.rs b/crates/registry-breg-client-py/src/lib.rs index 7c598def4e..d52d0dd701 100644 --- a/crates/registry-breg-client-py/src/lib.rs +++ b/crates/registry-breg-client-py/src/lib.rs @@ -480,6 +480,48 @@ fn projection_from_python( serde_json::from_value(value).map_err(|_| invalid(py, format!("{what} is invalid"))) } +fn review_message_document( + py: Python<'_>, + context: &Bound<'_, PyAny>, +) -> PyResult { + let bad = || invalid(py, "Expected a Proposal review document"); + let value = python_to_json(context).map_err(|_| bad())?; + serde_json::from_value(value).map_err(|_| bad()) +} + +fn review_message_result<'py>( + py: Python<'py>, + result: breg_client_sdk::BRegComplete, +) -> PyResult> { + // The answer follows the reviewer's profile: the review context, the + // Proposal document when it also holds Get, or the thread alone while + // no review context is readable. + match result.value { + breg_client_sdk::BRegProposalMessageOutcome::Review(document) => { + complete_value(py, &*document, &result.metadata) + } + breg_client_sdk::BRegProposalMessageOutcome::Proposal(proposal) => { + complete_value(py, &*proposal, &result.metadata) + } + breg_client_sdk::BRegProposalMessageOutcome::Thread(thread) => { + complete_value(py, &*thread, &result.metadata) + } + } +} + +fn proposal_message_result( + py: Python<'_>, + result: breg_client_sdk::BRegComplete, +) -> PyResult { + let breg_client_sdk::BRegProposalMessageOutcome::Proposal(inner) = result.value else { + return Err(invalid(py, "Expected a Proposal message response")); + }; + Ok(Proposal { + response_etag: result.metadata.etag().map(|etag| etag.as_str().to_owned()), + inner: *inner, + }) +} + fn complete_value<'py, T: Serialize>( py: Python<'py>, value: &T, @@ -1258,6 +1300,20 @@ fn metadata_operation_value(value: &breg_client_sdk::BRegMetadataOperation) -> V }) } +fn form_input_value(input: &breg_client_sdk::BRegActionInputDescriptor) -> Value { + json!({ + "id": input.identifier(), + "api_name": input.api_name(), + "label": input.label(), + "description": input.description(), + "schema": input.schema(), + "field_type": input.field_type(), + "required": input.required(), + "nullable": input.nullable(), + "classification": input.classification(), + }) +} + fn action_value(value: &breg_client_sdk::BRegActionDescriptor) -> Value { let bounds = value.bounds(); json!({ @@ -1270,17 +1326,11 @@ fn action_value(value: &breg_client_sdk::BRegActionDescriptor) -> Value { "id": slot.identifier(), "required": slot.required(), "content_types": slot.content_types(), "maximum_bytes": slot.maximum_bytes(), })).collect::>(), - "inputs": value.inputs().iter().map(|input| json!({ - "id": input.identifier(), - "api_name": input.api_name(), - "label": input.label(), - "description": input.description(), - "schema": input.schema(), - "field_type": input.field_type(), - "required": input.required(), - "nullable": input.nullable(), - "classification": input.classification(), - })).collect::>(), + "inputs": value.inputs().iter().map(form_input_value).collect::>(), + "messages": value.maximum_message_count().map(|limit| json!({"maximumCount":limit,"maximumTextBytes":2000})), + "additional_forms": value.additional_forms().iter().map(|(id, inputs)| { + (id, inputs.iter().map(form_input_value).collect::>()) + }).collect::>(), "reference_inputs": value.reference_inputs().iter().map(|input| json!({ "input": input.input_identifier(), "api_name": input.api_name(), @@ -3065,6 +3115,169 @@ impl BaseRegistryClient { }) } + fn send_proposal_message( + &self, + py: Python<'_>, + proposal: PyRef<'_, Proposal>, + text: &str, + key: &str, + ) -> PyResult { + let proposal = proposal.inner.clone(); + let key = BRegIdempotencyKey::parse(key).map_err(|error| invalid(py, error.to_string()))?; + let result = py + .detach(|| { + self.runtime.block_on(self.inner.send_proposal_message( + breg_client_sdk::BRegProposalMessageTarget::Proposal(&proposal), + text, + &key, + )) + }) + .map_err(|error| sdk_error(py, error))?; + proposal_message_result(py, result) + } + + #[pyo3(signature = (proposal, after=None, limit=20))] + fn list_proposal_messages<'py>( + &self, + py: Python<'py>, + proposal: PyRef<'_, Proposal>, + after: Option<&str>, + limit: u8, + ) -> PyResult> { + let proposal = proposal.inner.clone(); + let result = py + .detach(|| { + self.runtime.block_on(self.inner.list_proposal_messages( + breg_client_sdk::BRegProposalMessageTarget::Proposal(&proposal), + after, + limit, + )) + }) + .map_err(|error| sdk_error(py, error))?; + complete_value(py, &result.value, &result.metadata) + } + + fn mark_proposal_messages_read( + &self, + py: Python<'_>, + proposal: PyRef<'_, Proposal>, + through: &str, + ) -> PyResult { + let proposal = proposal.inner.clone(); + let result = py + .detach(|| { + self.runtime + .block_on(self.inner.mark_proposal_messages_read( + breg_client_sdk::BRegProposalMessageTarget::Proposal(&proposal), + through, + )) + }) + .map_err(|error| sdk_error(py, error))?; + proposal_message_result(py, result) + } + + fn send_proposal_message_from_review<'py>( + &self, + py: Python<'py>, + binding: PyRef<'_, ProposalReviewBinding>, + context: &Bound<'_, PyAny>, + text: &str, + key: &str, + ) -> PyResult> { + let document = review_message_document(py, context)?; + let binding = binding.inner.clone(); + let key = BRegIdempotencyKey::parse(key).map_err(|error| invalid(py, error.to_string()))?; + let target = breg_client_sdk::BRegProposalMessageTarget::Review { + binding: &binding, + document: &document, + }; + let result = py + .detach(|| { + self.runtime + .block_on(self.inner.send_proposal_message(target, text, &key)) + }) + .map_err(|error| sdk_error(py, error))?; + review_message_result(py, result) + } + + #[pyo3(signature = (binding, context, after=None, limit=20))] + fn list_proposal_messages_from_review<'py>( + &self, + py: Python<'py>, + binding: PyRef<'_, ProposalReviewBinding>, + context: &Bound<'_, PyAny>, + after: Option<&str>, + limit: u8, + ) -> PyResult> { + let document = review_message_document(py, context)?; + let binding = binding.inner.clone(); + let target = breg_client_sdk::BRegProposalMessageTarget::Review { + binding: &binding, + document: &document, + }; + let result = py + .detach(|| { + self.runtime + .block_on(self.inner.list_proposal_messages(target, after, limit)) + }) + .map_err(|error| sdk_error(py, error))?; + complete_value(py, &result.value, &result.metadata) + } + + fn mark_proposal_messages_read_from_review<'py>( + &self, + py: Python<'py>, + binding: PyRef<'_, ProposalReviewBinding>, + context: &Bound<'_, PyAny>, + through: &str, + ) -> PyResult> { + let document = review_message_document(py, context)?; + let binding = binding.inner.clone(); + let target = breg_client_sdk::BRegProposalMessageTarget::Review { + binding: &binding, + document: &document, + }; + let result = py + .detach(|| { + self.runtime + .block_on(self.inner.mark_proposal_messages_read(target, through)) + }) + .map_err(|error| sdk_error(py, error))?; + review_message_result(py, result) + } + + fn add_proposal_form_entry( + &self, + py: Python<'_>, + proposal: PyRef<'_, Proposal>, + form_id: &str, + input: &Bound<'_, PyAny>, + key: &str, + ) -> PyResult { + let proposal = proposal.inner.clone(); + let value = python_to_json(input) + .map_err(|_| invalid(py, "Proposal form input must be exact JSON"))?; + let input = value + .as_object() + .ok_or_else(|| invalid(py, "Proposal form input must be an object"))?; + let key = BRegIdempotencyKey::parse(key).map_err(|error| invalid(py, error.to_string()))?; + let response = py + .detach(|| { + self.runtime.block_on( + self.inner + .add_proposal_form_entry(&proposal, form_id, input, &key), + ) + }) + .map_err(|error| sdk_error(py, error))?; + Ok(Proposal { + response_etag: response + .metadata + .etag() + .map(|etag| etag.as_str().to_owned()), + inner: response.value, + }) + } + fn add_proposal_addition( &self, py: Python<'_>, diff --git a/crates/registry-breg-client-py/tests/python/test_additions.py b/crates/registry-breg-client-py/tests/python/test_additions.py index f7d3e461fa..3995ae6e1f 100644 --- a/crates/registry-breg-client-py/tests/python/test_additions.py +++ b/crates/registry-breg-client-py/tests/python/test_additions.py @@ -16,6 +16,10 @@ def test_addition_and_download_keep_the_exact_submission(self): addition_id = '00000000-0000-4000-8000-000000000002' revision = 'sha256:' + 'a' * 64 content = b'support' + form_entry_id = '00000000-0000-4000-8000-000000000004' + form_path = f'/v1/proposals/{proposal_id}/additional-forms/details' + message_id = '00000000-0000-4000-8000-000000000005' + thread_path = f'/v1/proposals/{proposal_id}/messages' requests = [] metadata = {'id': 'additions', 'version': '1', 'revision': revision, 'metadataVersion': '2', 'recordTypes': [], 'operations': [], 'actions': [], 'proposals': { @@ -30,7 +34,9 @@ def test_addition_and_download_keep_the_exact_submission(self): class Handler(BaseHTTPRequestHandler): def do_GET(self): requests.append(('GET', self.path, dict(self.headers), b'')) - if f'/additions/{addition_id}?' in self.path: + if thread_path in self.path: + self.respond(json.dumps({'items': document['messages']['items']}).encode()) + elif f'/additions/{addition_id}?' in self.path: self.respond(content, 'text/plain', True) else: self.respond(json.dumps(metadata if '/registry?' in self.path else document).encode()) @@ -38,7 +44,29 @@ def do_GET(self): def do_POST(self): body = self.rfile.read(int(self.headers['content-length'])) requests.append(('POST', self.path, dict(self.headers), body)) + if thread_path in self.path: + if f'{thread_path}/read' not in self.path: + document['revision'] += 1 + document['additions']['other']['links']['add']['availability']['observedRevision'] = document['revision'] + document['additionalForms']['details']['links']['add']['availability']['observedRevision'] = document['revision'] + for link in document['messages']['links'].values(): + link['availability']['observedRevision'] = document['revision'] + document['messages']['count'] += 1 + document['messages']['items'].insert(0, {'id': message_id, 'from': 'party', + 'partyRole': 'owner', 'mine': True, 'sentAt': '2026-11-27T00:00:00Z', + 'text': json.loads(body)['text']}) + self.respond(json.dumps(document).encode()) + return document['revision'] += 1 + if form_path in self.path: + document['formEntryId'] = form_entry_id + document['additions']['other']['links']['add']['availability']['observedRevision'] = document['revision'] + slot = document['additionalForms']['details'] + slot['links']['add']['availability']['observedRevision'] = document['revision'] + slot['items'].append({'id': form_entry_id, 'submissionVersion': 1, + 'addedAt': '2026-11-27T00:00:00Z', 'input': json.loads(body)['input']}) + self.respond(json.dumps(document).encode()) + return document['additions']['other']['items'].append({'id': addition_id, 'submissionVersion': 1, 'sha256': hashlib.sha256(content).hexdigest(), 'byteSize': len(content), 'contentType': 'text/plain', 'addedAt': '2026-11-27T00:00:00Z', 'verificationStatus': 'notRequired', 'links': {'download': { @@ -92,6 +120,34 @@ def log_message(self, *args): retained = client.get_proposal(contract.select_proposal_get('writer'), proposal_id) self.assertEqual(len(retained.document['additions']['other']['items']), 2) self.assertEqual(client.download_proposal_addition(retained, addition_id)['body'], content) + document['additionalForms'] = {'details': {'id': 'details', 'maximumCount': 2, 'items': [], + 'links': {'add': {'method': 'POST', 'path': form_path, 'accessProfile': 'writer', + 'operation': 'add', 'ifMatch': '"form-condition"', + 'availability': {'available': True, 'observedRevision': document['revision']}}}}} + with_form = client.get_proposal(contract.select_proposal_get('writer'), proposal_id) + sent = client.add_proposal_form_entry(with_form, 'details', {'confirmed': True}, 'form-one') + self.assertEqual(sent.document['formEntryId'], form_entry_id) + self.assertEqual(json.loads(requests[-1][3]), {'input': {'confirmed': True}}) + headers = {key.lower(): value for key, value in requests[-1][2].items()} + self.assertEqual(headers['if-match'], '"form-condition"') + self.assertEqual(headers['idempotency-key'], 'form-one') + def thread_link(method, tail=''): + return {'method': method, 'path': thread_path + tail, 'accessProfile': 'writer', + 'operation': 'message', 'availability': {'available': True, 'observedRevision': document['revision']}} + + document['messages'] = {'count': 0, 'unread': 0, 'items': [], 'links': { + 'message': {**thread_link('POST'), 'ifMatch': '"message-condition"'}, + 'markRead': thread_link('POST', '/read'), 'list': thread_link('GET')}} + current = client.get_proposal(contract.select_proposal_get('writer'), proposal_id) + delivered = client.send_proposal_message(current, 'literal', 'send-one') + self.assertEqual(delivered.document['messages']['items'][0]['text'], 'literal') + page = client.list_proposal_messages(delivered, limit=2) + self.assertEqual(page['value']['items'][0]['id'], message_id) + client.mark_proposal_messages_read(delivered, message_id) + self.assertEqual(json.loads(requests[-1][3]), {'through': message_id}) + headers = {key.lower(): value for key, value in requests[-1][2].items()} + self.assertNotIn('if-match', headers) + self.assertNotIn('idempotency-key', headers) finally: server.shutdown() thread.join() diff --git a/crates/registry-breg-client-py/tests/python/test_review_documents.py b/crates/registry-breg-client-py/tests/python/test_review_documents.py index 37369b52c7..f8ff884cc8 100644 --- a/crates/registry-breg-client-py/tests/python/test_review_documents.py +++ b/crates/registry-breg-client-py/tests/python/test_review_documents.py @@ -77,7 +77,7 @@ def do_GET(self): binding = contract.select_proposal_review_context('reviewer', 'correct') self.assertIsInstance(binding, BRegProposalReviewBinding) observed = client.read_proposal_review_by_id(binding, identifier)['value'] - self.assertEqual(parse_qs(urlsplit(requests[-1]).query)['include'], ['answers']) + self.assertEqual(parse_qs(urlsplit(requests[-1]).query)['include'], ['answers', 'messages']) batch = client.read_proposal_review_context_batch(binding, [identifier, concealed_id]) self.assertEqual(batch['value'], [observed, None]) batch_url = urlsplit(requests[-1]) diff --git a/crates/registry-breg-client/src/client.rs b/crates/registry-breg-client/src/client.rs index de0422ecb5..d2479c5d4d 100644 --- a/crates/registry-breg-client/src/client.rs +++ b/crates/registry-breg-client/src/client.rs @@ -1451,7 +1451,7 @@ impl BaseRegistryClient { &self, link: &BRegProposalLink, ) -> Result, BaseRegistryClientError> { - self.proposal_review_include_exchange(link, "get-review-status", "progress") + self.proposal_review_include_exchange(link, "get-review-status", &["progress"]) .await } @@ -1459,7 +1459,8 @@ impl BaseRegistryClient { &self, link: &BRegProposalLink, ) -> Result, BaseRegistryClientError> { - self.proposal_review_include_exchange(link, "get-review-context", "answers") + // The displayed context carries the live answers and message thread. + self.proposal_review_include_exchange(link, "get-review-context", &["answers", "messages"]) .await } @@ -1467,7 +1468,7 @@ impl BaseRegistryClient { &self, link: &BRegProposalLink, operation: &str, - include: &str, + includes: &[&str], ) -> Result, BaseRegistryClientError> { if link.method() != "GET" || link.operation() != operation { return Err(BaseRegistryClientError::invalid_request( @@ -1476,7 +1477,11 @@ impl BaseRegistryClient { } let segments = fixed_operation_segments(link.path())?; let mut pairs = access_profile_query(Some(link.access_profile()))?; - pairs.push(("include".to_owned(), include.to_owned())); + pairs.extend( + includes + .iter() + .map(|include| ("include".to_owned(), (*include).to_owned())), + ); let url = self.url_with_query(&segments, &pairs)?; let builder = self .authorize( diff --git a/crates/registry-breg-client/src/error.rs b/crates/registry-breg-client/src/error.rs index fdf70c275c..9dd819531e 100644 --- a/crates/registry-breg-client/src/error.rs +++ b/crates/registry-breg-client/src/error.rs @@ -166,6 +166,9 @@ pub enum BRegProblemCode { PreconditionFailed, PreconditionRequired, ProfileNotAuthorized, + ProposalFormLimitReached, + ProposalFormUndeclared, + ProposalMessageLimitReached, ProposalRejected, ProposalReviewResultMismatch, ProposalSubjectChanged, @@ -191,7 +194,7 @@ pub enum BRegProblemCode { } impl BRegProblemCode { - pub const ALL: [Self; 50] = [ + pub const ALL: [Self; 53] = [ Self::AccessProfileAmbiguous, Self::ActionEvidenceFailed, Self::ActionGuardFailed, @@ -220,6 +223,9 @@ impl BRegProblemCode { Self::PreconditionFailed, Self::PreconditionRequired, Self::ProfileNotAuthorized, + Self::ProposalFormLimitReached, + Self::ProposalFormUndeclared, + Self::ProposalMessageLimitReached, Self::ProposalRejected, Self::ProposalReviewResultMismatch, Self::ProposalSubjectChanged, @@ -275,6 +281,9 @@ impl BRegProblemCode { Self::PreconditionFailed => "precondition.failed", Self::PreconditionRequired => "precondition.required", Self::ProfileNotAuthorized => "profile.not-authorized", + Self::ProposalFormLimitReached => "proposal.form-limit-reached", + Self::ProposalFormUndeclared => "proposal.form-undeclared", + Self::ProposalMessageLimitReached => "proposal.message-limit-reached", Self::ProposalRejected => "proposal.rejected", Self::ProposalReviewResultMismatch => "proposal.review-result-mismatch", Self::ProposalSubjectChanged => "proposal.subject-changed", @@ -312,7 +321,7 @@ impl BRegProblemCode { Self::ActionEvidenceFailed => 503, Self::ActionHandlerFailed => 500, Self::AuthenticationRefused | Self::DevelopmentTaskAssertion => 401, - Self::LookupUnresolved | Self::ResourceNotFound => 404, + Self::LookupUnresolved | Self::ResourceNotFound | Self::ProposalFormUndeclared => 404, Self::IngestionProfileMismatch | Self::ProfileNotAuthorized | Self::ProposalSubjectNotCaller @@ -325,6 +334,8 @@ impl BRegProblemCode { | Self::IngestionRunBlocked | Self::IngestionRunNotOpen | Self::MutationConflict + | Self::ProposalFormLimitReached + | Self::ProposalMessageLimitReached | Self::ProposalRejected | Self::ProposalSubjectChanged | Self::StatisticalDatasetVersionConflict => 409, @@ -438,6 +449,9 @@ impl BRegProblemCode { } Self::PreconditionFailed => "The mutation precondition failed.", Self::ProposalReviewResultMismatch => "The current review result does not match the retained approval.", + Self::ProposalFormLimitReached => "The submission has reached the entry limit for this form.", + Self::ProposalFormUndeclared => "The Action does not declare this additional form.", + Self::ProposalMessageLimitReached => "This Proposal's message thread is full.", Self::ProposalSubjectChanged => "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.", Self::ProposalSubjectNotCaller => "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.", Self::PreconditionRequired => "The mutation precondition is required.", diff --git a/crates/registry-breg-client/src/metadata.rs b/crates/registry-breg-client/src/metadata.rs index 103388cfe0..c9004cc3d4 100644 --- a/crates/registry-breg-client/src/metadata.rs +++ b/crates/registry-breg-client/src/metadata.rs @@ -1116,6 +1116,8 @@ pub struct BRegActionDescriptor { input_mode: Option, maximum_input_string_bytes: Option, inputs: Vec, + additional_forms: BTreeMap>, + maximum_message_count: Option, attachments: Vec, reference_inputs: Vec, required_condition_keys: Vec, @@ -1130,6 +1132,14 @@ pub struct BRegActionDescriptor { } impl BRegActionDescriptor { + pub fn maximum_message_count(&self) -> Option { + self.maximum_message_count + } + + pub fn additional_forms(&self) -> &BTreeMap> { + &self.additional_forms + } + pub fn api_name(&self) -> &str { &self.api_name } @@ -3457,6 +3467,47 @@ fn parse_actions(value: Value) -> Result, BRegMetadata .collect::, _>>()?; ensure_unique(inputs.iter().map(|input| input.id.as_str()))?; ensure_unique(inputs.iter().map(|input| input.api_name.as_str()))?; + let maximum_message_count = action + .remove("messages") + .map(|value| { + let mut messages = object(value)?; + let maximum = positive_integer(required(&mut messages, "maximumCount")?)?; + let text_bytes = positive_integer(required(&mut messages, "maximumTextBytes")?)?; + finish(messages)?; + if mode != BRegActionMode::Proposal || maximum > 1000 || text_bytes != 2000 { + return Err(metadata_error(BRegMetadataErrorKind::Shape)); + } + Ok(maximum as u16) + }) + .transpose()?; + let additional_forms = action + .remove("additionalForms") + .map(object) + .transpose()? + .unwrap_or_default(); + if additional_forms.len() > 8 + || mode == BRegActionMode::Immediate && !additional_forms.is_empty() + { + return Err(metadata_error(BRegMetadataErrorKind::Shape)); + } + let additional_forms = additional_forms + .into_iter() + .map(|(id, value)| { + let id = identifier(Value::String(id))?; + let mut form = object(value)?; + let inputs = array(required(&mut form, "inputs")?)? + .into_iter() + .map(parse_action_input) + .collect::, _>>()?; + if !(1..=16).contains(&inputs.len()) { + return Err(metadata_error(BRegMetadataErrorKind::Shape)); + } + ensure_unique(inputs.iter().map(|input| input.id.as_str()))?; + ensure_unique(inputs.iter().map(|input| input.api_name.as_str()))?; + finish(form)?; + Ok((id, inputs)) + }) + .collect::, BRegMetadataError>>()?; let reference_inputs = array(required(&mut action, "referenceInputs")?)? .into_iter() .map(parse_action_reference_input) @@ -3599,6 +3650,8 @@ fn parse_actions(value: Value) -> Result, BRegMetadata input_mode, maximum_input_string_bytes, inputs, + additional_forms, + maximum_message_count, attachments, reference_inputs, required_condition_keys, diff --git a/crates/registry-breg-client/src/proposal.rs b/crates/registry-breg-client/src/proposal.rs index 26b72a152d..11509edef2 100644 --- a/crates/registry-breg-client/src/proposal.rs +++ b/crates/registry-breg-client/src/proposal.rs @@ -10,6 +10,13 @@ use time::{format_description::well_known::Rfc3339, OffsetDateTime}; use zeroize::Zeroizing; mod additions; +mod forms; +mod messages; +pub use forms::{BRegProposalForm, BRegProposalFormEntry}; +pub use messages::{ + BRegProposalMessage, BRegProposalMessageOutcome, BRegProposalMessagePage, + BRegProposalMessageSide, BRegProposalMessageTarget, BRegProposalMessages, +}; mod asks; pub use asks::{ BRegProposalAnswerRequest, BRegProposalAsk, BRegProposalAskAnswer, BRegProposalAskState, @@ -408,6 +415,12 @@ pub struct BRegProposalReviewContext { pub fields: Option>, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub asks: Vec, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub additional_forms: BTreeMap, + /// The Proposal's message thread, read live: its newest messages and + /// links on a displayed context, its counts on a batch read. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub messages: Option, } /// Exact local interface exported by the governed producer, independent of a review policy pin. #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] @@ -616,6 +629,12 @@ pub struct BRegProposal { attachments: BTreeMap, #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] additions: BTreeMap, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + additional_forms: BTreeMap, + #[serde(default, skip_serializing_if = "Option::is_none")] + form_entry_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + messages: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] asks: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -901,6 +920,14 @@ impl BRegProposal { } } self.validate_additions()?; + self.validate_forms()?; + if self + .messages + .as_ref() + .is_some_and(|thread| !messages::valid_thread(thread, &self.id, self.revision)) + { + return Err(refusal()); + } self.validate_asks()?; Ok(()) } @@ -994,6 +1021,16 @@ impl BRegProposal { .flat_map(|slot| slot.links.values()), ) .chain(self.addition_links()) + .chain( + self.additional_forms + .values() + .flat_map(|form| form.links.values()), + ) + .chain( + self.messages + .iter() + .flat_map(|thread| thread.links.values()), + ) .chain(self.asks.iter().flat_map(|ask| ask.links.values())) .any(|link| link.access_profile != profile) { @@ -1424,7 +1461,8 @@ impl BaseRegistryClient { serde_json::from_value(value).map_err(|_| refusal())?; let is_context = binding.operation == "get-review-context"; if document.id != id - || (!include_answers && !document.context.asks.is_empty()) + || (!include_answers + && (!document.context.asks.is_empty() || document.context.messages.is_some())) || document.action_id != binding.action || !valid_review_document(&document, is_context, false) || !review_asks::profiles(&document, &binding.profile) @@ -1493,6 +1531,9 @@ impl BaseRegistryClient { && context.id == id && context.action_id == binding.action && valid_review_document(&context, true, false) + && context.context.messages.as_ref().is_none_or(|thread| { + thread.items.is_none() && thread.links.is_empty() + }) && review_asks::profiles(&context, &binding.profile) => { values.push(Some(*context)) @@ -2155,6 +2196,12 @@ fn valid_review_document( is_context: bool, include_progress: bool, ) -> bool { + if document.context.messages.as_ref().is_some_and(|thread| { + !is_context || !messages::valid_thread(thread, &document.id, document.revision) + }) { + return false; + } + canonical_proposal_id(&document.id) && identifier(&document.action_id) && digest(&document.action_revision) @@ -4474,6 +4521,46 @@ mod tests { } } + #[tokio::test] + async fn proposal_get_accepts_both_sides_of_the_thread_and_enforces_message_bounds() { + let mut value = document(); + value["messages"] = json!({ + "count": 1001, "unread": 1000, "lastSentAt": "2026-12-01T10:00:00Z", + "items": [{"id": ID, "from": "official", "mine": false, + "sentAt": "2026-12-01T10:00:00Z", "text": "Received"}], + "links": {"list": {"method": "GET", "path": format!("/v1/proposals/{ID}/messages"), + "accessProfile": "author", "operation": "message", + "availability": {"available": true, "observedRevision": 2}}} + }); + let (client, response, server) = proposal_response_client(value.clone()).await; + let binding = BRegProposalGetBinding::from_metadata( + &json!({"method":"GET","path":"/v1/proposals/{proposal_id}","accessProfiles":["author"]}), + &client.source_binding(), + "author", + ) + .unwrap(); + for count in [1001, 2000] { + value["messages"]["count"] = json!(count); + *response.lock().unwrap() = value.clone(); + let proposal = client.get_proposal(&binding, ID).await.unwrap().value; + let messages = proposal.messages().unwrap(); + assert_eq!((messages.count, messages.unread), (count, 1000)); + } + for (count, unread) in [(2001, 1000), (2000, 1001), (12, 13)] { + value["messages"]["count"] = json!(count); + value["messages"]["unread"] = json!(unread); + *response.lock().unwrap() = value.clone(); + assert!( + matches!( + client.get_proposal(&binding, ID).await, + Err(BaseRegistryClientError::InvalidRequest { .. }) + ), + "count={count}, unread={unread}" + ); + } + server.abort(); + } + #[tokio::test] async fn proposal_uuid_lookup_refuses_foreign_bindings_and_noncanonical_ids_before_io() { let source = client("https://registry.example/tenant/"); diff --git a/crates/registry-breg-client/src/proposal/asks.rs b/crates/registry-breg-client/src/proposal/asks.rs index 635904a129..27b089f10d 100644 --- a/crates/registry-breg-client/src/proposal/asks.rs +++ b/crates/registry-breg-client/src/proposal/asks.rs @@ -27,6 +27,8 @@ pub struct BRegProposalAskAnswer { #[serde(default, skip_serializing_if = "Option::is_none")] pub text: Option, pub additions: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub form_entries: Vec, pub answered_at: String, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] @@ -41,6 +43,8 @@ pub struct BRegProposalAnswerRequest { pub text: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub additions: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub form_entries: Vec, } impl fmt::Debug for BRegProposalAsk { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -58,20 +62,30 @@ impl fmt::Debug for BRegProposalAnswerRequest { } } -fn valid_answer(text: Option<&str>, additions: &[String], wants: &[BRegProposalAskWant]) -> bool { - (text.is_some() || !additions.is_empty()) +fn valid_answer( + text: Option<&str>, + additions: &[String], + forms: &[String], + wants: &[BRegProposalAskWant], +) -> bool { + (text.is_some() || !additions.is_empty() || !forms.is_empty()) && text.is_none_or(|text| { !text.trim().is_empty() && text.len() <= 2000 && !text.contains('\0') }) && (text.is_some() || !wants.contains(&BRegProposalAskWant::Answer {})) - && additions.len() <= 32 - && additions.iter().all(|id| canonical_proposal_id(id)) - && additions - .iter() - .collect::>() - .len() - == additions.len() + && valid_entry_ids(additions) + && valid_entry_ids(forms) && (!additions.is_empty() || !wants.contains(&BRegProposalAskWant::Document {})) + && (!forms.is_empty() + || !wants + .iter() + .any(|want| matches!(want, BRegProposalAskWant::Form { .. }))) +} + +fn valid_entry_ids(ids: &[String]) -> bool { + ids.len() <= 32 + && ids.iter().all(|id| canonical_proposal_id(id)) + && ids.iter().collect::>().len() == ids.len() } impl BRegProposal { @@ -103,7 +117,12 @@ impl BRegProposal { if ask.state != BRegProposalAskState::Answered || at < asked || !at.nanosecond().is_multiple_of(1000) - || !valid_answer(answer.text.as_deref(), &answer.additions, &ask.wants) + || !valid_answer( + answer.text.as_deref(), + &answer.additions, + &answer.form_entries, + &ask.wants, + ) { return Err(refusal()); } @@ -163,7 +182,12 @@ impl BaseRegistryClient { } if ask.state != BRegProposalAskState::Open || ask.answer.is_some() - || !valid_answer(body.text.as_deref(), &body.additions, &ask.wants) + || !valid_answer( + body.text.as_deref(), + &body.additions, + &body.form_entries, + &ask.wants, + ) { return Err(refusal()); } @@ -194,6 +218,14 @@ impl BaseRegistryClient { && candidate.due_at == ask.due_at && candidate.answer.as_ref().is_some_and(|answer| { answer.text == body.text + && answer + .form_entries + .iter() + .collect::>() + == body + .form_entries + .iter() + .collect::>() && answer .additions .iter() @@ -229,7 +261,7 @@ mod tests { use super::*; #[test] fn an_answer_without_wants_still_needs_content_before_io() { - assert!(!valid_answer(None, &[], &[])); - assert!(valid_answer(Some("explanation"), &[], &[])); + assert!(!valid_answer(None, &[], &[], &[])); + assert!(valid_answer(Some("explanation"), &[], &[], &[])); } } diff --git a/crates/registry-breg-client/src/proposal/forms.rs b/crates/registry-breg-client/src/proposal/forms.rs new file mode 100644 index 0000000000..bd588ac3cd --- /dev/null +++ b/crates/registry-breg-client/src/proposal/forms.rs @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: Apache-2.0 +use super::*; +use serde_json::json; + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct BRegProposalForm { + pub id: String, + pub maximum_count: u8, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub items: Option>, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub links: BTreeMap, +} + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct BRegProposalFormEntry { + pub id: String, + pub submission_version: u32, + pub added_at: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub input: Option>, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub contract_changed: bool, +} + +impl BRegProposal { + pub fn additional_forms(&self) -> &BTreeMap { + &self.additional_forms + } + + pub fn form_entry_id(&self) -> Option<&str> { + self.form_entry_id.as_deref() + } + + pub(super) fn validate_forms(&self) -> Result<(), BaseRegistryClientError> { + if self.additional_forms.len() > 8 + || self + .form_entry_id + .as_deref() + .is_some_and(|id| !canonical_proposal_id(id)) + { + return Err(refusal()); + } + let mut ids = std::collections::BTreeSet::new(); + for (id, form) in &self.additional_forms { + if !identifier(id) + || form.id != *id + || !(1..=32).contains(&form.maximum_count) + || form.items.is_none() && form.links.is_empty() + || form.items.as_ref().is_some_and(|entries| { + entries.len() > 32 + || entries.iter().any(|entry| { + !canonical_proposal_id(&entry.id) + || !ids.insert(&entry.id) + || entry.submission_version != self.submission_version + || proposal_instant(&entry.added_at).is_none() + || entry.contract_changed == entry.input.is_some() + }) + }) + { + return Err(refusal()); + } + for (name, link) in &form.links { + validate_link(link)?; + if name != "add" + || link.operation != "add" + || link.method != "POST" + || link.path != format!("/v1/proposals/{}/additional-forms/{id}", self.id) + || link + .availability + .as_ref() + .is_none_or(|value| !valid_availability(value, self.revision, self.state)) + { + return Err(refusal()); + } + } + } + Ok(()) + } +} + +impl BaseRegistryClient { + /// Append typed inputs using the selected Proposal's advertised form link. + pub async fn add_proposal_form_entry( + &self, + proposal: &BRegProposal, + form_id: &str, + input: &serde_json::Map, + key: &BRegIdempotencyKey, + ) -> Result, BaseRegistryClientError> { + if proposal.source.as_deref() != Some(self.source_binding().as_str()) + || proposal.state != BRegProposalState::Submitted + || input.is_empty() + || input.len() > 16 + { + return Err(refusal()); + } + let form = proposal.additional_forms.get(form_id).ok_or_else(refusal)?; + let link = form.links.get("add").ok_or_else(refusal)?; + if let Some(availability) = link.availability.as_ref().filter(|value| !value.available) { + return Err(unavailable(availability)); + } + let body = serde_json::to_vec(&json!({"input":input})).map_err(|_| refusal())?; + if body.len() > 16_384 { + return Err(refusal()); + } + let response = self.proposal_exchange(link, Some(body), Some(key)).await?; + let invalid = || { + BaseRegistryClientError::protocol( + 200, + BRegProtocolFailure::Body, + Some(response.metadata.trace_id().clone()), + ) + }; + let current = BRegProposal::from_slice(response.value.as_bytes()).map_err(|_| invalid())?; + let entry_id = current.form_entry_id().ok_or_else(invalid)?; + let slot = current.additional_forms.get(form_id).ok_or_else(invalid)?; + if current.discloses_application_actor() + || current.id != proposal.id + || current.action_id != proposal.action_id + || current.action_revision != proposal.action_revision + || current.submission_version != proposal.submission_version + || current.state != BRegProposalState::Submitted + || current.effect_digest != proposal.effect_digest + || Some(current.revision) != proposal.revision.checked_add(1) + || slot.items.as_ref().is_some_and(|entries| { + !entries + .iter() + .any(|entry| entry.id == entry_id && entry.input.as_ref() == Some(input)) + }) + { + return Err(invalid()); + } + Ok(BRegComplete { + value: current + .bind_profile(self.source_binding(), &link.access_profile) + .map_err(|_| invalid())?, + metadata: response.metadata, + }) + } +} diff --git a/crates/registry-breg-client/src/proposal/messages.rs b/crates/registry-breg-client/src/proposal/messages.rs new file mode 100644 index 0000000000..17f3e78dec --- /dev/null +++ b/crates/registry-breg-client/src/proposal/messages.rs @@ -0,0 +1,435 @@ +// SPDX-License-Identifier: Apache-2.0 +use super::*; +use serde_json::json; + +const MAX_MESSAGES_PER_SIDE: u16 = 1000; + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum BRegProposalMessageSide { + Party, + Official, +} + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct BRegProposalMessage { + pub id: String, + pub from: BRegProposalMessageSide, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub party_role: Option, + pub mine: bool, + pub sent_at: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub text: Option, +} + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct BRegProposalMessages { + pub count: u16, + pub unread: u16, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub last_sent_at: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub items: Option>, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub links: BTreeMap, +} + +#[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct BRegProposalMessagePage { + pub items: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_cursor: Option, + /// The thread's links, with the write's current condition. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub links: BTreeMap, +} + +pub enum BRegProposalMessageTarget<'a> { + Proposal(&'a BRegProposal), + Review { + binding: &'a BRegProposalReviewBinding, + document: &'a BRegProposalReviewDocument, + }, +} + +pub enum BRegProposalMessageOutcome { + Proposal(Box), + Review(Box), + /// The thread alone: the answer to a reviewer without Get while no + /// review context is readable, between rounds or after the Action + /// changed. + Thread(Box), +} + +impl BRegProposal { + pub fn messages(&self) -> Option<&BRegProposalMessages> { + self.messages.as_ref() + } +} + +/// The server's text rule: no control character but a line break or tab +/// (a carriage return only before a line feed), and no character that +/// reorders text or does not display. +fn valid_text(text: &str) -> bool { + let mut characters = text.chars().peekable(); + while let Some(character) = characters.next() { + let allowed = match character { + '\r' => characters.peek() == Some(&'\n'), + '\n' | '\t' => true, + _ => { + !character.is_control() + && !matches!( + character, + '\u{061C}' + | '\u{200B}'..='\u{200F}' + | '\u{2028}'..='\u{202E}' + | '\u{2060}'..='\u{2064}' + | '\u{2066}'..='\u{2069}' + | '\u{FEFF}' + | '\u{E0000}'..='\u{E007F}' + ) + } + }; + if !allowed { + return false; + } + } + !text.trim().is_empty() && text.len() <= 2000 +} + +fn valid_items(items: &[BRegProposalMessage], maximum: usize) -> bool { + let mut ids = std::collections::BTreeSet::new(); + items.len() <= maximum + && items.iter().all(|message| { + canonical_proposal_id(&message.id) + && ids.insert(&message.id) + && proposal_instant(&message.sent_at).is_some() + && (message.from == BRegProposalMessageSide::Party) == message.party_role.is_some() + && message.text.as_deref().is_none_or(valid_text) + }) +} + +pub(super) fn valid_thread(thread: &BRegProposalMessages, id: &str, revision: u64) -> bool { + thread.count <= 2 * MAX_MESSAGES_PER_SIDE + && thread.unread <= MAX_MESSAGES_PER_SIDE + && thread.unread <= thread.count + && thread + .last_sent_at + .as_deref() + .is_none_or(|value| proposal_instant(value).is_some()) + && thread + .items + .as_ref() + .is_none_or(|items| items.len() <= usize::from(thread.count) && valid_items(items, 20)) + && thread.links.iter().all(|(name, link)| { + let (method, tail, keyed) = match name.as_str() { + "message" => ("POST", "", true), + "markRead" => ("POST", "/read", false), + "list" => ("GET", "", false), + _ => return false, + }; + identifier(&link.access_profile) + && link.method == method + && link.operation == "message" + && link.path == format!("/v1/proposals/{id}/messages{tail}") + && (if keyed { + valid_condition(link.if_match.as_deref()) + } else { + link.if_match.is_none() + }) + && link + .availability + .as_ref() + .is_some_and(|value| value.observed_revision == revision) + }) +} + +impl<'a> BRegProposalMessageTarget<'a> { + fn identity(&self) -> (&str, &str, u64) { + match self { + Self::Proposal(value) => (&value.id, &value.action_id, value.revision), + Self::Review { document, .. } => (&document.id, &document.action_id, document.revision), + } + } + + fn link( + &self, + source: &str, + operation: &str, + ) -> Result<&BRegProposalLink, BaseRegistryClientError> { + match self { + Self::Proposal(value) if value.source.as_deref() == Some(source) => value + .messages() + .and_then(|thread| thread.links.get(operation)), + Self::Review { binding, document } + if binding.source == source + && binding.action == document.action_id + && binding.operation == "get-review-context" + && canonical_proposal_id(&document.id) + && valid_review_document(document, true, false) => + { + document + .context + .messages + .as_ref() + .and_then(|thread| thread.links.get(operation)) + .filter(|link| link.access_profile == binding.profile) + } + _ => None, + } + .ok_or_else(refusal) + } +} + +impl BaseRegistryClient { + pub async fn send_proposal_message( + &self, + target: BRegProposalMessageTarget<'_>, + text: &str, + key: &BRegIdempotencyKey, + ) -> Result, BaseRegistryClientError> { + if !valid_text(text) { + return Err(refusal()); + } + self.proposal_message_command(target, "message", json!({"text":text}), Some(key)) + .await + } + + pub async fn mark_proposal_messages_read( + &self, + target: BRegProposalMessageTarget<'_>, + through: &str, + ) -> Result, BaseRegistryClientError> { + if !canonical_proposal_id(through) { + return Err(refusal()); + } + self.proposal_message_command(target, "markRead", json!({"through":through}), None) + .await + } + + pub async fn list_proposal_messages( + &self, + target: BRegProposalMessageTarget<'_>, + after: Option<&str>, + limit: u8, + ) -> Result, BaseRegistryClientError> { + if !(1..=50).contains(&limit) || after.is_some_and(|value| cursor(value).is_none()) { + return Err(refusal()); + } + let source = self.source_binding(); + let link = target.link(&source, "list")?; + let mut query = vec![ + ("accessProfile".into(), link.access_profile.clone()), + ("limit".into(), limit.to_string()), + ]; + if let Some(after) = after { + query.push(("after".into(), after.into())); + } + let result = self.proposal_list_exchange(&link.path, &query).await?; + let invalid = || { + BaseRegistryClientError::protocol( + 200, + BRegProtocolFailure::Body, + Some(result.metadata.trace_id().clone()), + ) + }; + let page: BRegProposalMessagePage = + decode(result.value.as_bytes()).map_err(|_| invalid())?; + let observed = page + .links + .values() + .filter_map(|item| item.availability.as_ref()) + .map(|availability| availability.observed_revision) + .collect::>(); + if !valid_items(&page.items, usize::from(limit)) + || page.links.values().any(|item| { + item.access_profile != link.access_profile || item.availability.is_none() + }) + || observed.len() > 1 + || page.next_cursor.as_deref().is_some_and(|next| { + cursor(next).is_none() + || page.items.len() != usize::from(limit) + || after.is_some_and(|prior| cursor(next) >= cursor(prior)) + }) + { + return Err(invalid()); + } + Ok(BRegComplete { + value: page, + metadata: result.metadata, + }) + } + + async fn proposal_message_command( + &self, + target: BRegProposalMessageTarget<'_>, + operation: &str, + body: Value, + key: Option<&BRegIdempotencyKey>, + ) -> Result, BaseRegistryClientError> { + let source = self.source_binding(); + let link = target.link(&source, operation)?; + if let Some(availability) = link.availability.as_ref().filter(|value| !value.available) { + return Err(unavailable(availability)); + } + let (id, action, prior) = target.identity(); + let response = self + .proposal_exchange( + link, + Some(serde_json::to_vec(&body).map_err(|_| refusal())?), + key, + ) + .await?; + let invalid = || { + BaseRegistryClientError::protocol( + 200, + BRegProtocolFailure::Body, + Some(response.metadata.trace_id().clone()), + ) + }; + let valid_revision = |revision| { + if key.is_some() { + Some(revision) == prior.checked_add(1) + } else { + revision >= prior + } + }; + let text = body.get("text").and_then(Value::as_str); + let matches_outcome = |thread: &BRegProposalMessages| { + text.is_none_or(|text| { + thread + .items + .as_ref() + .and_then(|items| items.first()) + .is_some_and(|entry| entry.mine && entry.text.as_deref() == Some(text)) + }) + }; + let value = match target { + BRegProposalMessageTarget::Proposal(prior) => { + let current = + BRegProposal::from_slice(response.value.as_bytes()).map_err(|_| invalid())?; + if current.id != id + || current.action_id != action + || !valid_revision(current.revision) + || key.is_some() + && (current.action_revision != prior.action_revision + || current.submission_version != prior.submission_version + || current.effect_digest != prior.effect_digest) + || current + .messages + .as_ref() + .is_none_or(|thread| !matches_outcome(thread)) + || current.discloses_application_actor() + { + return Err(invalid()); + } + BRegProposalMessageOutcome::Proposal(Box::new( + current + .bind_profile(source, &link.access_profile) + .map_err(|_| invalid())?, + )) + } + // A reviewer whose profile also holds Get is answered with the + // Proposal document; one without Get is answered with the thread + // alone while no review context is readable. + BRegProposalMessageTarget::Review { .. } + if serde_json::from_slice::(response.value.as_bytes()) + .ok() + .is_some_and(|value| value.get("context").is_none()) => + { + let value: Value = + serde_json::from_slice(response.value.as_bytes()).map_err(|_| invalid())?; + if value.get("actionId").is_some() { + let current = BRegProposal::from_slice(response.value.as_bytes()) + .map_err(|_| invalid())?; + if current.id != id + || current.action_id != action + || !valid_revision(current.revision) + || current + .messages + .as_ref() + .is_none_or(|thread| !matches_outcome(thread)) + || current.discloses_application_actor() + { + return Err(invalid()); + } + BRegProposalMessageOutcome::Proposal(Box::new( + current + .bind_profile(source, &link.access_profile) + .map_err(|_| invalid())?, + )) + } else { + let thread: BRegProposalMessages = + decode(response.value.as_bytes()).map_err(|_| invalid())?; + let observed = thread + .links + .values() + .filter_map(|item| item.availability.as_ref()) + .map(|availability| availability.observed_revision) + .collect::>(); + if !matches_outcome(&thread) + || observed.len() != 1 + || observed.iter().any(|revision| !valid_revision(*revision)) + || !valid_thread(&thread, id, observed.into_iter().next().unwrap_or(0)) + || thread + .links + .values() + .any(|item| item.access_profile != link.access_profile) + { + return Err(invalid()); + } + BRegProposalMessageOutcome::Thread(Box::new(thread)) + } + } + BRegProposalMessageTarget::Review { + document: prior, .. + } => { + let current: BRegProposalReviewDocument = + decode(response.value.as_bytes()).map_err(|_| invalid())?; + if current.id != id + || current.action_id != action + || !valid_revision(current.revision) + || key.is_some() + && (current.action_revision != prior.action_revision + || current.submission_version != prior.submission_version + || current.effect_digest != prior.effect_digest) + || current.context.messages.as_ref().is_none_or(|thread| { + !matches_outcome(thread) + || thread + .links + .values() + .any(|item| item.access_profile != link.access_profile) + }) + || !valid_review_document(¤t, true, false) + || !current.context.asks.is_empty() + { + return Err(invalid()); + } + BRegProposalMessageOutcome::Review(Box::new(current)) + } + }; + Ok(BRegComplete { + value, + metadata: response.metadata, + }) + } +} + +fn cursor(value: &str) -> Option { + value + .parse::() + .ok() + .filter(|position| *position > 0 && position.to_string() == value) +} + +fn decode(bytes: &[u8]) -> Result { + let value = crate::strict_json::from_slice(bytes).map_err(|_| ())?; + serde_json::from_value(value).map_err(|_| ()) +} diff --git a/crates/registry-breg-client/src/proposal/review_asks.rs b/crates/registry-breg-client/src/proposal/review_asks.rs index 9c49ba744c..f18116187e 100644 --- a/crates/registry-breg-client/src/proposal/review_asks.rs +++ b/crates/registry-breg-client/src/proposal/review_asks.rs @@ -23,6 +23,8 @@ pub struct BRegProposalReviewAnswer { #[serde(default, skip_serializing_if = "Option::is_none")] pub text: Option, pub documents: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub form_entries: Vec, pub answered_at: String, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] @@ -93,7 +95,10 @@ pub(super) fn valid(document: &BRegProposalReviewDocument) -> bool { text.trim().is_empty() || text.len() > 2000 || text.contains('\0') }) || (answer.text.is_none() && ask.wants.contains(&BRegProposalAskWant::Answer {})) - || (answer.text.is_none() && answer.documents.is_empty()) + || (answer.text.is_none() + && answer.documents.is_empty() + && answer.form_entries.is_empty()) + || answer.form_entries.len() > 32 || answer.documents.len() > 32 || (answer.documents.is_empty() && ask.wants.contains(&BRegProposalAskWant::Document {})) diff --git a/crates/registry-breg-client/tests/proposal_document_boundary.rs b/crates/registry-breg-client/tests/proposal_document_boundary.rs index a5dfc8b519..29b93a97bf 100644 --- a/crates/registry-breg-client/tests/proposal_document_boundary.rs +++ b/crates/registry-breg-client/tests/proposal_document_boundary.rs @@ -2000,6 +2000,7 @@ async fn answer_commands_bind_the_selected_ask_and_validate_before_tokens_or_io( assert_eq!(fixture.token.0.load(Ordering::SeqCst), tokens); assert_eq!(fixture.requests.load(Ordering::SeqCst), requests); let body = BRegProposalAnswerRequest { + form_entries: Vec::new(), text: Some("explanation".into()), additions: vec![], }; diff --git a/crates/registry-breg-client/tests/write_http_boundary.rs b/crates/registry-breg-client/tests/write_http_boundary.rs index 36a654a892..2371d821b2 100644 --- a/crates/registry-breg-client/tests/write_http_boundary.rs +++ b/crates/registry-breg-client/tests/write_http_boundary.rs @@ -2251,6 +2251,11 @@ fn problem_detail(code: BRegProblemCode) -> &'static str { Code::PreconditionFailed => "The mutation precondition failed.", Code::PreconditionRequired => "The mutation precondition is required.", Code::ProfileNotAuthorized => "No access profile admits this caller for this request.", + Code::ProposalFormLimitReached => { + "The submission has reached the entry limit for this form." + } + Code::ProposalFormUndeclared => "The Action does not declare this additional form.", + Code::ProposalMessageLimitReached => "This Proposal's message thread is full.", Code::ProposalRejected => { "The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt." } diff --git a/crates/registry-breg/src/api/attachments.rs b/crates/registry-breg/src/api/attachments.rs index b287a926ad..dcecddc6d4 100644 --- a/crates/registry-breg/src/api/attachments.rs +++ b/crates/registry-breg/src/api/attachments.rs @@ -388,7 +388,9 @@ async fn mutate( reason: None, executor_lease: None, rebase_start_authority: None, + form: None, answer: None, + message: None, attachment: Some(crate::attachment::AttachmentMutation { slot_id: slot, content_type, diff --git a/crates/registry-breg/src/api/mod.rs b/crates/registry-breg/src/api/mod.rs index f80aa02145..45edd583b2 100644 --- a/crates/registry-breg/src/api/mod.rs +++ b/crates/registry-breg/src/api/mod.rs @@ -208,10 +208,22 @@ fn route_set(service: Arc) -> Router { get(proposals::review_context_batch), ) .route("/v1/proposals/{proposal_id}", get(proposals::get)) + .route( + "/v1/proposals/{proposal_id}/additional-forms/{form_id}", + post(proposals::add_form), + ) .route( "/v1/proposals/{proposal_id}/asks/{ask_id}/answer", post(proposals::answer), ) + .route( + "/v1/proposals/{proposal_id}/messages", + get(proposals::messages::list).post(proposals::messages::write), + ) + .route( + "/v1/proposals/{proposal_id}/messages/read", + post(proposals::messages::mark_read), + ) .route( "/v1/proposals/{proposal_id}/submissions/{submission_version}", get(proposals::submission), @@ -6167,10 +6179,15 @@ fn mutation_problem_response(error: MutationError) -> Response { FailedCheck::Ownership, ), MutationError::ProposalSubjectChanged => fixed_problem(ProblemCode::ProposalSubjectChanged), + MutationError::ProposalMessageLimitReached => { + fixed_problem(ProblemCode::ProposalMessageLimitReached) + } MutationError::AttachmentSlotWriteOnce => { fixed_problem(ProblemCode::AttachmentSlotWriteOnce) } MutationError::AttachmentTooLarge => fixed_problem(ProblemCode::AttachmentTooLarge), + MutationError::FormUndeclared => fixed_problem(ProblemCode::ProposalFormUndeclared), + MutationError::FormLimitReached => fixed_problem(ProblemCode::ProposalFormLimitReached), MutationError::AttachmentLimitReached => fixed_problem(ProblemCode::AttachmentLimitReached), MutationError::AttachmentRequired { slot } => { attachment_slot_problem(ProblemCode::AttachmentRequired, &slot) diff --git a/crates/registry-breg/src/api/proposals.rs b/crates/registry-breg/src/api/proposals.rs index 65fddb83c4..3bef869d84 100644 --- a/crates/registry-breg/src/api/proposals.rs +++ b/crates/registry-breg/src/api/proposals.rs @@ -5,12 +5,16 @@ use super::*; mod answers; +pub(super) mod messages; use crate::model::{ CompiledAction, CompiledActionExecution, CompiledActionRoute, CompiledProposalPermission, CompiledRegistry, HttpMethod, ProposalOperation, ProposalParty, }; use crate::postgres::{ProposalAuthority, ProposalAuthorityOperation, RowBoundaryContext}; pub(super) use answers::answer; +mod forms; +pub(super) use forms::add_form; +pub(crate) use forms::FormMutation; pub(super) fn proposal_problem(error: MutationError) -> Response { match error { @@ -47,7 +51,10 @@ pub(crate) struct ProposalMutationInput<'a> { pub executor_lease: Option, pub rebase_start_authority: Option<&'a ProposalAuthority>, pub attachment: Option, + pub form: Option>, pub answer: Option, + /// The text of a message written to the Proposal's thread. + pub message: Option, pub correlation: &'a RequestCorrelation, pub human_identity: Option<&'a registry_review_client::HumanIdentity>, pub claims: Option<&'a VerifiedRequestClaims>, @@ -732,10 +739,16 @@ fn authorize_checked_profile( profile_kind, None | Some(crate::contract::ActorKindSource::Human) ); + authority.receives_form_values = authority.receives_review_answers; // Answering is the applicant's own act and takes the same human test. - // The Proposal document's `asks` member follows this admission. - if operation == ProposalAuthorityOperation::Lifecycle(ProposalOperation::Answer) - && !authority.receives_review_answers + // The Proposal document's `asks` member follows this admission. The + // message thread is one person's text shown to another, both ways. + if matches!( + operation, + ProposalAuthorityOperation::Lifecycle( + ProposalOperation::Answer | ProposalOperation::Message + ) + ) && !authority.receives_review_answers { return Err(FailedCheck::ActorKind); } @@ -795,25 +808,36 @@ pub(super) fn selected_profile(raw: Option<&str>) -> Result, ()> } fn review_status_options(raw: Option<&str>) -> Result<(Option, bool), ()> { - review_include_options(raw, "progress") + review_include_options(raw, &["progress"]) + .map(|(selected, included)| (selected, !included.is_empty())) } -fn review_include_options(raw: Option<&str>, include: &str) -> Result<(Option, bool), ()> { +/// The selected profile and the optional members a review read asks for: +/// one `include` parameter for each, each one of `allowed`, none repeated. +fn review_include_options( + raw: Option<&str>, + allowed: &[&'static str], +) -> Result<(Option, BTreeSet<&'static str>), ()> { let Some(raw) = raw else { - return Ok((None, false)); + return Ok((None, BTreeSet::new())); }; if raw.is_empty() || raw.len() > MAX_RAW_QUERY_BYTES { return Err(()); } let mut ordinary = Vec::new(); - let mut included = false; + let mut included = BTreeSet::new(); for pair in raw.split('&') { let (name, value) = pair.split_once('=').ok_or(())?; if percent_decode(name).map_err(|_| ())? == "include" { - if included || percent_decode(value).map_err(|_| ())? != include { + let value = percent_decode(value).map_err(|_| ())?; + let known = allowed + .iter() + .copied() + .find(|include| *include == value) + .ok_or(())?; + if !included.insert(known) { return Err(()); } - included = true; } else { ordinary.push(pair); } @@ -1136,6 +1160,11 @@ pub(super) async fn authorize_target<'a>( .actions .iter() .find(|action| action.id == action_id) + // A Proposal whose Action declares no thread has no thread routes. + .filter(|action| { + operation != ProposalOperation::Message + || crate::mutation::thread_of(action).is_some() + }) .map(|action| (action, owner, subject)) }) else { return Err(audited_proposal_route_refusal( @@ -1342,7 +1371,9 @@ pub(super) async fn start( executor_lease: None, rebase_start_authority: None, attachment: None, + form: None, answer: None, + message: None, correlation: &correlation, human_identity: claims.human_identity(), claims: Some(&claims), @@ -1684,7 +1715,9 @@ pub(super) async fn transition( executor_lease: None, rebase_start_authority: rebase_start_authority.as_ref(), attachment: None, + form: None, answer: None, + message: None, correlation: &correlation, human_identity: claims.human_identity(), claims: Some(&claims), @@ -1846,6 +1879,7 @@ pub(super) async fn review_context_batch( profile.clone(), ProposalOperation::GetReviewContext, ReviewAnswers::Omitted, + ReviewMessages::Counts, correlation.clone(), ) .await; @@ -1890,6 +1924,7 @@ pub(super) async fn review_context( raw, ProposalOperation::GetReviewContext, ReviewAnswers::Served, + ReviewMessages::OnRequest, correlation, ) .await @@ -1909,6 +1944,7 @@ pub(super) async fn review_status( raw, ProposalOperation::GetReviewStatus, ReviewAnswers::Omitted, + ReviewMessages::Omitted, correlation, ) .await @@ -2075,6 +2111,16 @@ enum ReviewAnswers { Omitted, } +/// What a review read serves of the message thread, to a caller whose +/// profile holds `message`. The inbox batch serves counts and never text. +#[derive(Clone, Copy, Eq, PartialEq)] +pub(super) enum ReviewMessages { + /// The text and links, when the read asks with `include=messages`. + OnRequest, + Counts, + Omitted, +} + #[allow(clippy::too_many_arguments)] async fn review_read( service: Arc, @@ -2083,6 +2129,7 @@ async fn review_read( raw: Option, operation: ProposalOperation, answers: ReviewAnswers, + messages: ReviewMessages, correlation: RequestCorrelation, ) -> Response { let Some(mutations) = &service.mutations else { @@ -2091,12 +2138,21 @@ async fn review_read( let Ok(id) = Uuid::parse_str(&id) else { return concealed(FailedCheck::Visibility); }; - let Ok((selected, included)) = (if operation == ProposalOperation::GetReviewStatus { + let Ok((selected, included, thread)) = (if operation == ProposalOperation::GetReviewStatus { review_status_options(raw.as_deref()) + .map(|(selected, included)| (selected, included, false)) } else if operation == ProposalOperation::GetReviewContext { - review_include_options(raw.as_deref(), "answers") + review_include_options(raw.as_deref(), &["answers", "messages"]).map( + |(selected, included)| { + ( + selected, + included.contains("answers"), + included.contains("messages"), + ) + }, + ) } else { - selected_profile(raw.as_deref()).map(|selected| (selected, false)) + selected_profile(raw.as_deref()).map(|selected| (selected, false, false)) }) else { return concealed(FailedCheck::Visibility); }; @@ -2115,6 +2171,23 @@ async fn review_read( Ok(admitted) => admitted, Err(response) => return response, }; + let thread_text = match messages { + ReviewMessages::OnRequest if thread => Some(true), + ReviewMessages::Counts => Some(false), + _ => None, + }; + if let Some(text) = thread_text { + authority.review_messages = authorize( + &service.registry, + action, + &claims, + Some(authority.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Message), + Some(id), + PartySelection::Exact(authority.party), + ) + .map(|thread| (Box::new(thread), text)); + } if answers == ReviewAnswers::Omitted || !included { authority.receives_review_answers = false; } @@ -2176,6 +2249,7 @@ pub(crate) fn review_record_authorities( use crate::contract::ProposalContextValueSource; let target = match source { ProposalContextValueSource::Input { .. } + | ProposalContextValueSource::AdditionalForm { .. } | ProposalContextValueSource::Additions { .. } | ProposalContextValueSource::Document { .. } => continue, ProposalContextValueSource::Record { input, .. } => { diff --git a/crates/registry-breg/src/api/proposals/answers.rs b/crates/registry-breg/src/api/proposals/answers.rs index d0833f4533..b74db5166f 100644 --- a/crates/registry-breg/src/api/proposals/answers.rs +++ b/crates/registry-breg/src/api/proposals/answers.rs @@ -41,26 +41,8 @@ pub(in crate::api) async fn answer( Err(response) => return response, }; if let Err(error) = mutations.proposal_visible(id, &authority).await { - return match error { - MutationError::PreconditionFailed - | MutationError::AuthorizationRefused(_) - | MutationError::MembershipPreconditionFailed => { - let check = if matches!(error, MutationError::MembershipPreconditionFailed) { - FailedCheck::Membership - } else { - FailedCheck::Visibility - }; - admitted_http_refusal( - mutations, - &authority, - HttpMethod::Post, - &correlation, - concealed(check), - ) - .await - } - error => proposal_problem(error), - }; + return visibility_refusal(mutations, &authority, HttpMethod::Post, &correlation, error) + .await; } let refusal = async { if !single_content_type(&headers, "application/json") { @@ -113,7 +95,9 @@ pub(in crate::api) async fn answer( executor_lease: None, rebase_start_authority: None, attachment: None, + form: None, answer: Some(AnswerMutation { ask_id, body }), + message: None, correlation: &correlation, human_identity: claims.human_identity(), claims: Some(&claims), @@ -130,3 +114,27 @@ pub(in crate::api) async fn answer( Err(error) => proposal_target_problem(error), } } + +/// The answer to a caller the Proposal is hidden from after admission: the +/// same concealed `404` as for an unknown Proposal, audited as a refusal. +pub(super) async fn visibility_refusal( + mutations: &crate::postgres::PostgresRecordMutationService, + authority: &ProposalAuthority, + method: HttpMethod, + correlation: &RequestCorrelation, + error: MutationError, +) -> Response { + match error { + MutationError::PreconditionFailed + | MutationError::AuthorizationRefused(_) + | MutationError::MembershipPreconditionFailed => { + let check = if matches!(error, MutationError::MembershipPreconditionFailed) { + FailedCheck::Membership + } else { + FailedCheck::Visibility + }; + admitted_http_refusal(mutations, authority, method, correlation, concealed(check)).await + } + error => proposal_problem(error), + } +} diff --git a/crates/registry-breg/src/api/proposals/forms.rs b/crates/registry-breg/src/api/proposals/forms.rs new file mode 100644 index 0000000000..2edcc7f470 --- /dev/null +++ b/crates/registry-breg/src/api/proposals/forms.rs @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: Apache-2.0 +use super::*; + +pub(crate) struct FormMutation<'a> { + pub id: &'a str, + pub values: Map, +} + +#[derive(serde::Deserialize)] +#[serde(deny_unknown_fields)] +struct AddFormBody { + input: Map, +} + +pub(in crate::api) async fn add_form( + State(service): State>, + Path((id, form_id)): Path<(String, String)>, + Extension(correlation): Extension, + Authenticated(claims): Authenticated, + RawQuery(raw_query): RawQuery, + headers: HeaderMap, + body: Body, +) -> Response { + let Some(mutations) = &service.mutations else { + return concealed(FailedCheck::Visibility); + }; + let id = match Uuid::parse_str(&id) { + Ok(id) if !id.is_nil() => id, + _ => return concealed(FailedCheck::Visibility), + }; + let Ok(selected) = selected_profile(raw_query.as_deref()) else { + return concealed(FailedCheck::Visibility); + }; + let (action, authority) = match authorize_target( + &service, + mutations, + id, + &claims, + selected.as_deref(), + ProposalOperation::Add, + HttpMethod::Post, + &correlation, + ) + .await + { + Ok(admitted) => admitted, + Err(response) => return response, + }; + if let Err(error) = mutations.proposal_visible(id, &authority).await { + return answers::visibility_refusal( + mutations, + &authority, + HttpMethod::Post, + &correlation, + error, + ) + .await; + } + let request = async { + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Err(concealed(FailedCheck::Visibility)); + }; + if !proposal.additional_forms.contains_key(&form_id) { + return Err(proposal_problem(MutationError::FormUndeclared)); + } + if !authority + .permission(proposal) + .is_some_and(|grant| grant.writable_forms.contains(&form_id)) + { + return Err(profile_not_authorized(FailedCheck::AccessProfile)); + } + if !single_content_type(&headers, "application/json") { + return Err(unsupported_media_type()); + } + let key = single_header(&headers, "idempotency-key") + .filter(|key| valid_idempotency_key(key)) + .ok_or_else(missing_idempotency_key)?; + let etag = single_header(&headers, "if-match") + .filter(|etag| valid_if_match(etag)) + .ok_or_else(precondition_required)?; + let bytes = bounded_body_to(body, 16_384) + .await + .map_err(|_| invalid_request())?; + let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; + let body: AddFormBody = serde_json::from_value(value).map_err(|_| invalid_request())?; + Ok((key, etag, body.input)) + } + .await; + let (key, etag, values) = match request { + Ok(values) => values, + Err(response) => { + return admitted_http_refusal( + mutations, + &authority, + HttpMethod::Post, + &correlation, + response, + ) + .await + } + }; + match mutations + .proposal_mutation(ProposalMutationInput { + action_id: &action.id, + proposal_id: Some(id), + operation: ProposalAuthorityOperation::Lifecycle(ProposalOperation::Add), + authority: &authority, + idempotency_key: key, + expected_etag: Some(etag), + input: None, + submission_version: None, + effect_digest: None, + reason: None, + executor_lease: None, + rebase_start_authority: None, + attachment: None, + form: Some(FormMutation { + id: &form_id, + values, + }), + answer: None, + message: None, + correlation: &correlation, + human_identity: claims.human_identity(), + claims: Some(&claims), + }) + .await + { + Ok(outcome) => exact_mutation( + outcome.response(), + None, + "", + service.field_encryption.as_deref(), + ), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), + Err(error) => proposal_target_problem(error), + } +} diff --git a/crates/registry-breg/src/api/proposals/messages.rs b/crates/registry-breg/src/api/proposals/messages.rs new file mode 100644 index 0000000000..84e471e037 --- /dev/null +++ b/crates/registry-breg/src/api/proposals/messages.rs @@ -0,0 +1,376 @@ +// SPDX-License-Identifier: Apache-2.0 +//! The Proposal message thread: write, page and mark read. A write takes the +//! same admission, ETag and receipt boundary as every Proposal command; the +//! side it is written from follows the admitting entry, never the caller. +use super::*; + +/// Admit the caller to the thread of Proposal `id`, and confirm the +/// Proposal is visible to them before any part of the request is read. +async fn admit( + service: &HttpService, + id: &str, + claims: &VerifiedRequestClaims, + raw: Option<&str>, + method: HttpMethod, + correlation: &RequestCorrelation, +) -> Result<(Uuid, CompiledAction, ProposalAuthority), Response> { + let Some(mutations) = &service.mutations else { + return Err(concealed(FailedCheck::Visibility)); + }; + let id = match Uuid::parse_str(id) { + Ok(id) if !id.is_nil() => id, + _ => return Err(concealed(FailedCheck::Visibility)), + }; + let selected = selected_profile(raw).map_err(|_| concealed(FailedCheck::Visibility))?; + let (action, authority) = authorize_target( + service, + mutations, + id, + claims, + selected.as_deref(), + ProposalOperation::Message, + method, + correlation, + ) + .await?; + // A caller the Proposal's row boundaries or memberships hide learns + // nothing from how the request is shaped: visibility comes first. + if let Err(error) = mutations.proposal_visible(id, &authority).await { + return Err( + answers::visibility_refusal(mutations, &authority, method, correlation, error).await, + ); + } + Ok((id, action.clone(), authority)) +} + +/// The answer to a thread command: the caller's Proposal document when their +/// profile holds `get`, otherwise the review context with the thread when it +/// holds `get-review-context`. +async fn caller_view( + service: Arc, + action: &CompiledAction, + id: Uuid, + claims: &VerifiedRequestClaims, + authority: &ProposalAuthority, + correlation: &RequestCorrelation, +) -> Response { + let Some(mutations) = &service.mutations else { + return concealed(FailedCheck::Visibility); + }; + let profile = authority.common.access_profile().to_owned(); + let holds = |operation| { + authorize( + &service.registry, + action, + claims, + Some(&profile), + ProposalAuthorityOperation::Lifecycle(operation), + Some(id), + PartySelection::Exact(authority.party), + ) + }; + if let Some(get) = holds(ProposalOperation::Get) { + return match mutations + .proposal_document(id, &get, claims, correlation) + .await + { + Ok((value, etag)) => json_response(value, Some(&etag)), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), + Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), + Err(error) => proposal_target_problem(error), + }; + } + if holds(ProposalOperation::GetReviewContext).is_some() { + return review_read( + service.clone(), + id.to_string(), + claims.clone(), + Some(format!("accessProfile={profile}&include=messages")), + ProposalOperation::GetReviewContext, + ReviewAnswers::Omitted, + ReviewMessages::OnRequest, + correlation.clone(), + ) + .await; + } + StatusCode::NO_CONTENT.into_response() +} + +pub(in crate::api) async fn write( + State(service): State>, + Path(id): Path, + Extension(correlation): Extension, + Authenticated(claims): Authenticated, + RawQuery(raw_query): RawQuery, + headers: HeaderMap, + body: Body, +) -> Response { + let (id, action, authority) = match admit( + &service, + &id, + &claims, + raw_query.as_deref(), + HttpMethod::Post, + &correlation, + ) + .await + { + Ok(admitted) => admitted, + Err(response) => return response, + }; + let Some(mutations) = &service.mutations else { + return concealed(FailedCheck::Visibility); + }; + let refusal = async { + if !single_content_type(&headers, "application/json") { + return Err(unsupported_media_type()); + } + let key = single_header(&headers, "idempotency-key") + .filter(|key| valid_idempotency_key(key)) + .ok_or_else(missing_idempotency_key)?; + let etag = single_header(&headers, "if-match") + .filter(|etag| valid_if_match(etag)) + .ok_or_else(precondition_required)?; + let bytes = bounded_body_to(body, 16_384) + .await + .map_err(|_| invalid_request())?; + let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; + let text = match value.as_object() { + Some(object) if object.len() == 1 => object.get("text"), + _ => return Err(invalid_request()), + }; + let text = text + .and_then(Value::as_str) + .filter(|text| crate::proposal_messages::valid_text(text)) + .ok_or_else(|| { + invalid_request_at( + &crate::problem_location::RequestLocation::proposal_message_text(), + ) + })?; + Ok((key, etag, text.to_owned())) + } + .await; + let (key, etag, text) = match refusal { + Ok(values) => values, + Err(response) => { + return admitted_http_refusal( + mutations, + &authority, + HttpMethod::Post, + &correlation, + response, + ) + .await + } + }; + let outcome = mutations + .proposal_mutation(ProposalMutationInput { + action_id: &action.id, + proposal_id: Some(id), + operation: ProposalAuthorityOperation::Lifecycle(ProposalOperation::Message), + authority: &authority, + idempotency_key: key, + expected_etag: Some(etag), + input: None, + submission_version: None, + effect_digest: None, + reason: None, + executor_lease: None, + rebase_start_authority: None, + attachment: None, + form: None, + answer: None, + message: Some(text), + correlation: &correlation, + human_identity: claims.human_identity(), + claims: Some(&claims), + }) + .await; + match outcome { + Ok(outcome) => exact_mutation( + outcome.response(), + None, + "", + service.field_encryption.as_deref(), + ), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), + Err(error) => proposal_target_problem(error), + } +} + +pub(in crate::api) async fn list( + State(service): State>, + Path(id): Path, + Extension(correlation): Extension, + Authenticated(claims): Authenticated, + RawQuery(raw_query): RawQuery, +) -> Response { + // `after` and `limit` page the thread; every other parameter selects + // the access profile as on any Proposal read. + let mut after = None; + let mut limit = None; + let mut ordinary = Vec::new(); + for pair in raw_query.as_deref().unwrap_or("").split('&') { + if pair.is_empty() { + continue; + } + let Some((name, value)) = pair.split_once('=') else { + return concealed(FailedCheck::Visibility); + }; + match name { + "after" if after.is_none() => after = Some(value.to_owned()), + "limit" if limit.is_none() => limit = Some(value.to_owned()), + "after" | "limit" => return invalid_request(), + _ => ordinary.push(pair), + } + } + let ordinary = (!ordinary.is_empty()).then(|| ordinary.join("&")); + let (id, _, authority) = match admit( + &service, + &id, + &claims, + ordinary.as_deref(), + HttpMethod::Get, + &correlation, + ) + .await + { + Ok(admitted) => admitted, + Err(response) => return response, + }; + let Some(mutations) = &service.mutations else { + return concealed(FailedCheck::Visibility); + }; + let before = match after.as_deref().map(str::parse::) { + None => None, + Some(Ok(position)) if position > 0 => Some(position), + Some(_) => { + return admitted_http_refusal( + mutations, + &authority, + HttpMethod::Get, + &correlation, + fixed_problem(crate::problem::ProblemCode::QueryCursorInvalid), + ) + .await + } + }; + let limit = match limit.as_deref().map(str::parse::) { + None => crate::proposal_messages::DOCUMENT_ITEMS, + Some(Ok(limit)) if (1..=crate::proposal_messages::MAX_PAGE_ITEMS).contains(&limit) => limit, + Some(_) => { + return admitted_http_refusal( + mutations, + &authority, + HttpMethod::Get, + &correlation, + invalid_request(), + ) + .await + } + }; + match mutations + .proposal_messages_page(id, &authority, before, limit, &correlation) + .await + { + Ok(value) => json_response(value, None), + Err(MutationError::MembershipPreconditionFailed) => concealed(FailedCheck::Membership), + Err(MutationError::PreconditionFailed) => concealed(FailedCheck::Visibility), + Err(error) => proposal_target_problem(error), + } +} + +pub(in crate::api) async fn mark_read( + State(service): State>, + Path(id): Path, + Extension(correlation): Extension, + Authenticated(claims): Authenticated, + RawQuery(raw_query): RawQuery, + headers: HeaderMap, + body: Body, +) -> Response { + let (id, action, authority) = match admit( + &service, + &id, + &claims, + raw_query.as_deref(), + HttpMethod::Post, + &correlation, + ) + .await + { + Ok(admitted) => admitted, + Err(response) => return response, + }; + let Some(mutations) = &service.mutations else { + return concealed(FailedCheck::Visibility); + }; + let through = async { + if !single_content_type(&headers, "application/json") { + return Err(unsupported_media_type()); + } + let bytes = bounded_body_to(body, 1024) + .await + .map_err(|_| invalid_request())?; + let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; + match value.as_object() { + Some(object) if object.len() == 1 => object + .get("through") + .and_then(Value::as_str) + .and_then(|id| Uuid::parse_str(id).ok()) + .ok_or_else(|| { + invalid_request_at( + &crate::problem_location::RequestLocation::proposal_message_through(), + ) + }), + _ => Err(invalid_request()), + } + } + .await; + let through = match through { + Ok(through) => through, + Err(response) => { + return admitted_http_refusal( + mutations, + &authority, + HttpMethod::Post, + &correlation, + response, + ) + .await + } + }; + // A caller without Get is answered from the review context, or with the + // thread alone while none is readable. + let thread_view = authorize( + &service.registry, + &action, + &claims, + Some(authority.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Get), + Some(id), + PartySelection::Exact(authority.party), + ) + .is_none(); + match mutations + .proposal_mark_messages_read(id, &authority, through, thread_view, &correlation) + .await + { + Ok(Some(thread)) => return json_response(thread, None), + Ok(None) => {} + Err(MutationError::MembershipPreconditionFailed) => { + return concealed(FailedCheck::Membership) + } + Err(MutationError::PreconditionFailed) => return concealed(FailedCheck::Visibility), + Err(error) => return proposal_target_problem(error), + } + caller_view( + service.clone(), + &action, + id, + &claims, + &authority, + &correlation, + ) + .await +} diff --git a/crates/registry-breg/src/artifacts.rs b/crates/registry-breg/src/artifacts.rs index a83403ee3d..ecdbab4f59 100644 --- a/crates/registry-breg/src/artifacts.rs +++ b/crates/registry-breg/src/artifacts.rs @@ -15,11 +15,11 @@ use crate::diagnostics::Diagnostic; use crate::generated_ddl::DdlInventory; use crate::manifest_adapter::project_manifest_artifacts; use crate::model::{ - ActionRouteKind, CompiledAccessInventory, CompiledAction, CompiledActionInput, - CompiledActionInventory, CompiledActionRoute, CompiledEntity, CompiledEventDeliveryInventory, - CompiledManifestProjection, CompiledMetadataInventory, CompiledModuleIdentity, - CompiledPlanEffect, CompiledPlanMutation, CompiledPlanValue, CompiledQueryInventory, - CompiledQueryKind, CompiledQueryOperation, CompiledQueryTemporalBinding, + ActionRouteKind, CompiledAccessInventory, CompiledAction, CompiledActionExecution, + CompiledActionInput, CompiledActionInventory, CompiledActionRoute, CompiledEntity, + CompiledEventDeliveryInventory, CompiledManifestProjection, CompiledMetadataInventory, + CompiledModuleIdentity, CompiledPlanEffect, CompiledPlanMutation, CompiledPlanValue, + CompiledQueryInventory, CompiledQueryKind, CompiledQueryOperation, CompiledQueryTemporalBinding, CompiledQueryTemporalSemantics, CompiledQueryTemporalValueKind, CompiledRecipients, CompiledRevisionKind, CompiledRoute, CompiledRouteInventory, CompiledStatisticalDataset, DisclosureWithhold, HttpMethod, @@ -649,7 +649,7 @@ pub fn inspect_action(action: &CompiledAction) -> Value { value }) .collect::>(); - json!({ + let mut inspection = json!({ "id": action.id, "apiName": action.api_name, "revision": action.definition_revision, "display": action.display, "migrationReviewRevision": crate::immediate_actions::migration_review_revision(action), @@ -662,7 +662,49 @@ pub fn inspect_action(action: &CompiledAction) -> Value { "bounds": {"maximumTargets": action.maximum_targets, "maximumFieldMutations": action.maximum_field_mutations, "maximumSnapshotBytes": action.maximum_snapshot_bytes}, - }) + }); + if let CompiledActionExecution::Proposal { proposal } = &action.execution { + if !proposal.additional_forms.is_empty() { + let contracts: Map<_, _> = proposal + .additional_forms + .iter() + .map(|(id, form)| { + ( + id.clone(), + additional_form_contract(&action.id, id, &form.inputs), + ) + }) + .collect(); + inspection["additionalFormContracts"] = Value::Object(contracts); + } + } + inspection +} + +pub(crate) fn additional_form_contract( + action_id: &str, + form_id: &str, + inputs: &[CompiledActionInput], +) -> Value { + let mut inputs: Vec<_> = inputs.iter().collect(); + inputs.sort_by(|left, right| left.api_name.cmp(&right.api_name)); + let mut schema = action_input_properties_schema(inputs.iter().copied(), &[], false); + schema["minProperties"] = json!(1); + let fields = inputs + .iter() + .map(|input| { + json!({ + "id": input.id, + "apiName": input.api_name, + "fieldType": input.field_type, + "classification": input.classification, + }) + }) + .collect::>(); + let contract = json!({"actionId":action_id,"formId":form_id,"fields":fields,"schema":schema}); + let canonical = canonicalize_json(&contract).expect("compiled additional form canonicalizes"); + let digest = registry_review_protocol::ContentDigest::for_bytes(&canonical); + json!({"digest":digest,"schema":schema}) } fn inspect_scripted_plan(plan: &crate::model::CompiledPlanFunction) -> Value { @@ -1091,7 +1133,14 @@ pub(crate) fn openapi_action_response_schema( selected_result_effects: Option<&BTreeSet>, ) -> Value { if let crate::model::CompiledActionExecution::Proposal { proposal } = &action.execution { - return proposal_schema_with_additions(proposal.additions.is_some()); + let mut schema = proposal_schema_with_additions(proposal.additions.is_some()); + if !proposal.additional_forms.is_empty() { + append_proposal_forms_schema(&mut schema); + } + if proposal.messages.is_some() { + schema["properties"]["messages"] = proposal_artifacts::proposal_messages_schema(false); + } + return schema; } let result_shapes = action_response_result_shapes(action, selected_result_effects); let results_schema = match result_shapes.as_slice() { @@ -1511,6 +1560,32 @@ pub(crate) fn public_action_metadata_entry( .remove("invoke"); metadata["routes"]["start"] = start; } + if let (Some(profile), CompiledActionExecution::Proposal { proposal }) = + (selected_profile, &action.execution) + { + if let Some(thread) = proposal.messages.filter(|_| { + proposal.permissions.iter().any(|grant| { + grant.profile_id == profile + && grant + .operations + .contains(&crate::model::ProposalOperation::Message) + }) + }) { + metadata["messages"] = + json!({"maximumCount":thread.maximum_count,"maximumTextBytes":2000}); + } + let forms = proposal.additional_forms.iter().filter(|(id, _)| { + proposal.permissions.iter().any(|grant| { + grant.profile_id == profile + && (grant.readable_forms.contains(*id) || grant.writable_forms.contains(*id)) + }) + }).map(|(id, form)| { + (id.clone(), json!({"inputs":form.inputs.iter().map(|input|action_input_metadata(input,false)).collect::>()})) + }).collect::>(); + if !forms.is_empty() { + metadata["additionalForms"] = Value::Object(forms); + } + } metadata } @@ -1587,9 +1662,12 @@ pub(crate) fn proposal_asks_schema(review: bool) -> Value { let uuid = json!({"type":"string","format":"uuid"}); let instant = json!({"type":"string","format":"date-time"}); let text = json!({"type":"string","minLength":1,"maxLength":2000}); - let wants = json!({"type":"array","maxItems":8,"uniqueItems":true,"items":{ - "type":"object","additionalProperties":false,"required":["kind"], - "properties":{"kind":{"enum":["answer","document"]}}}}); + let wants = json!({"type":"array","maxItems":8,"uniqueItems":true,"items":{"oneOf":[ + {"type":"object","additionalProperties":false,"required":["kind"], + "properties":{"kind":{"enum":["answer","document"]}}}, + {"type":"object","additionalProperties":false,"required":["kind","form"], + "properties":{"kind":{"const":"form"},"form":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,63}$"}}} + ]}}); let mut answer = json!({"type":"object","additionalProperties":false, "required":["answeredAt"],"properties":{"text":text,"answeredAt":instant}}); let mut properties = json!({"id":uuid,"text":text,"wants":wants, @@ -1597,6 +1675,8 @@ pub(crate) fn proposal_asks_schema(review: bool) -> Value { let mut required = vec!["id", "text", "wants", "askedAt", "state"]; if review { answer["required"] = json!(["documents", "answeredAt"]); + answer["properties"]["formEntries"] = + json!({"type":"array","maxItems":32,"items":proposal_form_entry_schema(false)}); answer["properties"]["documents"] = json!({"type":"array","maxItems":32,"items":{ "type":"object","additionalProperties":false, "required":["id","sha256","contentType","byteSize","verificationStatus"], @@ -1607,6 +1687,8 @@ pub(crate) fn proposal_asks_schema(review: bool) -> Value { "properties":{"method":{"const":"GET"},"operation":{"const":"get-review-context"},"accessProfile":{"type":"string"},"path":{"type":"string"}}}}}}); } else { answer["required"] = json!(["additions", "answeredAt"]); + answer["properties"]["formEntries"] = + json!({"type":"array","maxItems":32,"uniqueItems":true,"items":uuid}); answer["properties"]["additions"] = json!({"type":"array","maxItems":32,"uniqueItems":true,"items":uuid}); required.push("links"); @@ -1618,6 +1700,45 @@ pub(crate) fn proposal_asks_schema(review: bool) -> Value { json!({"type":"array","maxItems":crate::contract::MAX_MIRRORED_REVIEW_ASKS,"items":{"type":"object","additionalProperties":false,"required":required,"properties":properties}}) } +fn proposal_form_entry_schema(applicant: bool) -> Value { + let mut schema = json!({ + "type":"object","additionalProperties":false,"required":["id","addedAt"], + "oneOf":[{"required":["input"],"not":{"required":["contractChanged"]}}, + {"required":["contractChanged"],"not":{"required":["input"]}}], + "properties":{ + "id":{"type":"string","format":"uuid"},"addedAt":{"type":"string","format":"date-time"}, + "input":{"type":"object","minProperties":1,"maxProperties":16}, + "contractChanged":{"const":true} + } + }); + if applicant { + schema["required"] + .as_array_mut() + .expect("required members") + .push(json!("submissionVersion")); + schema["properties"]["submissionVersion"] = + json!({"type":"integer","minimum":1,"maximum":u32::MAX}); + } + schema +} + +pub(crate) fn append_proposal_forms_schema(schema: &mut Value) { + schema["properties"]["formEntryId"] = json!({"type":"string","format":"uuid"}); + schema["properties"]["additionalForms"] = json!({"type":"object","maxProperties":8, + "additionalProperties":{"type":"object","additionalProperties":false,"required":["id","maximumCount"], + "anyOf":[{"required":["items"]},{"required":["links"]}], + "properties":{"id":{"type":"string"},"maximumCount":{"type":"integer","minimum":1,"maximum":32}, + "items":{"type":"array","maxItems":32,"items":proposal_form_entry_schema(true)}, + "links":{"type":"object","additionalProperties":false,"properties":{"add":{ + "type":"object","additionalProperties":false,"required":["method","path","accessProfile","operation","ifMatch","availability"], + "properties":{"method":{"const":"POST"},"operation":{"const":"add"},"path":{"type":"string"}, + "accessProfile":{"type":"string"},"ifMatch":{"type":"string"},"availability":availability_schema()} + }}} + } + } + }); +} + pub(crate) fn proposal_schema_with_additions(enabled: bool) -> Value { let mut schema = proposal_schema(); if enabled { diff --git a/crates/registry-breg/src/audit.rs b/crates/registry-breg/src/audit.rs index dc7c4d8b16..3af0ff5fd2 100644 --- a/crates/registry-breg/src/audit.rs +++ b/crates/registry-breg/src/audit.rs @@ -743,7 +743,7 @@ fn proposal_pre_io_record( let allowed = match event.method { HttpMethod::Get => matches!( operation, - "get" | "list" | "get-review-context" | "get-review-status" + "get" | "list" | "get-review-context" | "get-review-status" | "message" ), HttpMethod::Post => matches!( operation, @@ -758,6 +758,7 @@ fn proposal_pre_io_record( | "cancel" | "apply" | "get-task-grant-context" + | "message" ), HttpMethod::Patch | HttpMethod::Delete => operation == "edit", }; diff --git a/crates/registry-breg/src/authoring_integrity.rs b/crates/registry-breg/src/authoring_integrity.rs index 0ca260d7c9..bf270b0b3a 100644 --- a/crates/registry-breg/src/authoring_integrity.rs +++ b/crates/registry-breg/src/authoring_integrity.rs @@ -581,6 +581,27 @@ fn action_integrity( add_collisions(document, errors, "breg.action-effect.id-collision", &values); } if let ActionExecutionSource::Proposal { proposal } = &action.execution { + let forms = format!("{base}/execution/proposal/additionalForms"); + let form_ids: Vec<_> = proposal + .additional_forms + .keys() + .map(|id| (id.clone(), keyed_pointer(&forms, id))) + .collect(); + add_key_collisions( + document, + errors, + "breg.additional-form.id-collision", + &form_ids, + ); + for (id, form) in &proposal.additional_forms { + let inputs = format!("{}/inputs", keyed_pointer(&forms, id)); + add_collisions( + document, + errors, + "breg.additional-form-input.id-collision", + &indexed_ids(&inputs, &form.inputs, |input| &input.id), + ); + } for (code, values) in [ ( "breg.attachment.id-lookalike", diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index aa463217e3..84fc95bbb3 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -3437,7 +3437,15 @@ pub fn module_digest(module: &RegistryModule) -> String { } pub fn module_digest_with_assets(module: &RegistryModule, assets: &[ModuleAssetSource]) -> String { - let mut value = serde_json::to_value(module).expect("module serializes"); + let value = serde_json::to_value(module).expect("module serializes"); + module_source_digest(&module.id, value, assets) +} + +pub(crate) fn module_source_digest( + id: &str, + mut value: serde_json::Value, + assets: &[ModuleAssetSource], +) -> String { // Both module digest domains use the sealed Action Plan vocabulary. // Project and module authoring use the current names independently. let members = value @@ -3459,7 +3467,7 @@ pub fn module_digest_with_assets(module: &RegistryModule, assets: &[ModuleAssetS let bytes = canonicalize_json(&value).expect("module canonicalizes"); let mut module_assets = assets .iter() - .filter(|asset| asset.module.as_deref() == Some(module.id.as_str())) + .filter(|asset| asset.module.as_deref() == Some(id)) .collect::>(); if module_assets.is_empty() { let digest = Sha256::digest(bytes); diff --git a/crates/registry-breg/src/compiler/review_context.rs b/crates/registry-breg/src/compiler/review_context.rs index 384238cfaa..9bf4565db7 100644 --- a/crates/registry-breg/src/compiler/review_context.rs +++ b/crates/registry-breg/src/compiler/review_context.rs @@ -51,6 +51,27 @@ pub fn compile_schema_from_parts( let mut bindings = Map::new(); for (name, projection) in &context.fields { let (schema, classification, binding) = match projection { + ProposalContextValueSource::AdditionalForm { form } => { + let declared = proposal.additional_forms.get(form).ok_or_else(&invalid)?; + let contract = + crate::artifacts::additional_form_contract(&action.id, form, &declared.inputs); + let classification = declared + .inputs + .iter() + .map(|input| input.classification) + .max() + .ok_or_else(&invalid)?; + ( + json!({"type":"array","maxItems":32,"items":{ + "type":"object","additionalProperties":false, + "required":["id","addedAt","input"], + "properties":{"id":{"type":"string","format":"uuid"},"addedAt":{"type":"string","format":"date-time"}, + "input":contract["schema"]} + }}), + classification, + json!({"kind":"additional-form","form":form,"contractDigest":contract["digest"]}), + ) + } ProposalContextValueSource::Additions { slot } => { let declared = proposal .additions diff --git a/crates/registry-breg/src/contract.rs b/crates/registry-breg/src/contract.rs index 7624767d9f..85fcdb0425 100644 --- a/crates/registry-breg/src/contract.rs +++ b/crates/registry-breg/src/contract.rs @@ -633,11 +633,28 @@ pub struct ProposalPolicySource { pub attachments: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] pub additions: Option, + /// Typed information a reviewed Proposal can declare separately from its Action inputs. + #[serde( + default, + deserialize_with = "local_id_map", + skip_serializing_if = "BTreeMap::is_empty" + )] + #[cfg_attr( + feature = "schema", + schemars( + schema_with = "local_id_map_schema::", + extend("maxProperties" = MAXIMUM_ADDITIONAL_FORMS) + ) + )] + pub additional_forms: BTreeMap, #[serde(default)] pub review_context: Option, /// The person the Proposal is about, frozen at its first Submit. #[serde(default, skip_serializing_if = "Option::is_none")] pub subject: Option, + /// One message thread between the party and the office. Presence opens it. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub messages: Option, /// Post-commit observers of the fixed, value-free Proposal lifecycle event. #[serde( default, @@ -647,6 +664,56 @@ pub struct ProposalPolicySource { pub hooks: Vec, } +pub(crate) const MAXIMUM_ADDITIONAL_FORMS: usize = 8; +pub(crate) const MAXIMUM_ADDITIONAL_FORM_INPUTS: usize = 16; +#[cfg(feature = "schema")] +const UNSUPPORTED_ADDITIONAL_FORM_TYPES: [&str; 5] = [ + "reference", + "crs84-point", + "crs84-polygon", + "structured", + "vocabulary-code", +]; + +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct AdditionalFormSource { + #[serde(default = "default_additional_form_count")] + #[cfg_attr(feature = "schema", schemars(range(min = 1, max = 32)))] + pub maximum_count: u8, + #[cfg_attr( + feature = "schema", + schemars(schema_with = "additional_form_inputs_schema") + )] + pub inputs: Vec, +} + +fn default_additional_form_count() -> u8 { + 8 +} + +#[cfg(feature = "schema")] +fn additional_form_inputs_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { + schemars::json_schema!({ + "type": "array", + "minItems": 1, + "maxItems": MAXIMUM_ADDITIONAL_FORM_INPUTS, + "items": { + "unevaluatedProperties": false, + "allOf": [ + generator.subschema_for::(), + { + "type": "object", + "required": ["type"], + "properties": {"type": {"not": {"enum": UNSUPPORTED_ADDITIONAL_FORM_TYPES}}}, + "not": {"required": ["pattern"]} + } + ] + } + }) +} + #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "camelCase")] @@ -676,6 +743,7 @@ pub enum ProposalEventTransition { Asked, Answered, Added, + Messaged, Started, Edited, Submitted, @@ -694,6 +762,7 @@ impl ProposalEventTransition { Self::Asked => "asked", Self::Answered => "answered", Self::Added => "added", + Self::Messaged => "messaged", Self::Started => "started", Self::Edited => "edited", Self::Submitted => "submitted", @@ -804,6 +873,11 @@ pub struct ProposalReviewContextSource { )] #[cfg_attr(feature = "schema", schemars(!remote, tag = "type"))] pub enum ProposalContextValueSource { + AdditionalForm { + #[serde(deserialize_with = "local_id")] + #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] + form: String, + }, Additions { #[serde(deserialize_with = "local_id")] #[cfg_attr(feature = "schema", schemars(with = "LocalId"))] @@ -856,6 +930,7 @@ pub enum ProposalOperation { GetReviewContext, GetTaskGrantContext, GetApplicationActor, + Message, } impl ProposalOperation { pub const fn as_str(self) -> &'static str { @@ -875,6 +950,7 @@ impl ProposalOperation { Self::GetReviewContext => "get-review-context", Self::GetTaskGrantContext => "get-task-grant-context", Self::GetApplicationActor => "get-application-actor", + Self::Message => "message", } } } @@ -905,6 +981,25 @@ pub struct ProposalSubjectSource { #[serde(default, skip_serializing_if = "Option::is_none")] pub field: Option, } +/// The message thread on each Proposal of an Action. It needs no review. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ProposalMessagesSource { + /// The most messages each side, the party and the office, writes on one + /// Proposal's thread. + #[serde(default = "default_proposal_message_count")] + #[cfg_attr( + feature = "schema", + schemars(with = "BoundedU32<1, { MAX_PROPOSAL_MESSAGE_COUNT }>") + )] + pub maximum_count: u32, +} +/// The most messages an Action may allow each side on one Proposal. +pub const MAX_PROPOSAL_MESSAGE_COUNT: u32 = 1000; +fn default_proposal_message_count() -> u32 { + 200 +} #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "camelCase")] @@ -931,6 +1026,10 @@ pub struct ProposalPermissionSource { pub readable_attachments: UniqueSet, #[serde(default)] pub writable_attachments: UniqueSet, + #[serde(default, skip_serializing_if = "UniqueSet::is_empty")] + pub readable_forms: UniqueSet, + #[serde(default, skip_serializing_if = "UniqueSet::is_empty")] + pub writable_forms: UniqueSet, /// Action inputs this grant may set. Absent leaves every declared input writable. #[serde(default, skip_serializing_if = "Option::is_none")] pub writable_inputs: Option>, @@ -6825,20 +6924,22 @@ const SEALED_MODULE_FORMAT: FormatSpec<'static> = FormatSpec { /// column, and the action that fixes it (CFG-DIAG-1), and none repeats a /// value from the file. pub fn read_project_yaml(file: &str, bytes: &[u8]) -> Result, Report> { - read_project(file, bytes, false).map(|(decoded, _)| decoded) + read_project(file, bytes, false, None).map(|(decoded, _)| decoded) } fn read_project( file: &str, bytes: &[u8], sealed: bool, + predecessor_memberships: Option<&mut PredecessorMemberships>, ) -> Result<(Decoded, bool), Report> { let format = if sealed { &SEALED_PROJECT_FORMAT } else { &PROJECT_FORMAT }; - let (mut decoded, translated) = read_with_value_types(file, bytes, format, sealed)?; + let (mut decoded, translated) = + read_with_value_types(file, bytes, format, sealed, predecessor_memberships)?; let errors = crate::authoring_integrity::project_diagnostics(&mut decoded); if errors.is_empty() { Ok((decoded, translated)) @@ -6952,11 +7053,228 @@ fn rename_sealed_key( Ok(true) } +#[derive(Debug, Default)] +pub(crate) struct PredecessorMemberships { + // Keep the full historical tuples for rehearsal and for reconstructing + // module locks. Different grants could name different fields on one source. + pub historical: BTreeMap>, + pub current_site: Option, +} + +fn current_membership_site(value: &mut Value) -> Option { + let has_membership = |rows: Option<&Value>| { + rows.and_then(Value::as_array) + .is_some_and(|rows| rows.iter().any(|entry| entry.get("membership").is_some())) + }; + for (path, rows) in entries_mut(value, "rowBoundarySets", "") { + if has_membership(Some(rows)) { + return Some(path); + } + } + for (profile_path, profile) in entries_mut(value, "accessProfiles", "") { + let Some(permissions) = profile.get_mut("permissions") else { + continue; + }; + let permissions_path = format!("{profile_path}/permissions"); + for (path, grant) in entries_mut(permissions, "records", &permissions_path) { + if has_membership(grant.get("rowBoundaries")) { + return Some(format!("{path}/rowBoundaries")); + } + } + for surface in ["actions", "proposals"] { + for (grant_path, grant) in entries_mut(permissions, surface, &permissions_path) { + for (path, target) in entries_mut(grant, "targets", &grant_path) { + if has_membership(target.get("rowBoundaries")) { + return Some(format!("{path}/rowBoundaries")); + } + } + } + } + } + for collection in ["recordTypes", "extendRecordTypes"] { + for (path, record_type) in entries_mut(value, collection, "") { + if record_type.get("membership").is_some() { + return Some(format!("{path}/membership")); + } + for (path, grant) in entries_mut(record_type, "accessProfiles", &path) { + if has_membership(grant.get("rowBoundaries")) { + return Some(format!("{path}/rowBoundaries")); + } + } + } + } + None +} + +fn normalize_predecessor_memberships( + value: &mut Value, + document: &Document, + memberships: &mut PredecessorMemberships, +) -> Result<(), Report> { + memberships.current_site = current_membership_site(value); + for (profile_path, profile) in entries_mut(value, "accessProfiles", "") { + let Some(permissions) = profile.get_mut("permissions") else { + continue; + }; + for (path, grant) in entries_mut( + permissions, + "records", + &format!("{profile_path}/permissions"), + ) { + normalize_predecessor_membership_grant(grant, &path, document, memberships)?; + } + } + for collection in ["recordTypes", "extendRecordTypes"] { + for (path, record_type) in entries_mut(value, collection, "") { + for (path, grant) in entries_mut(record_type, "accessProfiles", &path) { + normalize_predecessor_membership_grant(grant, &path, document, memberships)?; + } + } + } + if let Some(site) = memberships + .current_site + .as_deref() + .filter(|_| !memberships.historical.is_empty()) + { + return Err(document.report_with([document.diagnostic_at_value( + Severity::Error, + "breg.membership.mixed-spelling", + site, + "The sealed source mixes historical and current membership declarations.", + "Use the original sources sealed by one release.", + )])); + } + Ok(()) +} + +fn normalize_predecessor_membership_grant( + grant: &mut Value, + path: &str, + document: &Document, + memberships: &mut PredecessorMemberships, +) -> Result<(), Report> { + let Some(grant) = grant.as_object_mut() else { + return Ok(()); + }; + if !grant.contains_key("membershipBoundaries") { + return Ok(()); + } + let site = format!("{path}/membershipBoundaries"); + let refuse = |code, site, message| { + document.report_with([document.diagnostic_at_value( + Severity::Error, + code, + site, + message, + "Use the original sources sealed by the previous release.", + )]) + }; + let boundaries: Vec = document.decode_at(&site)?; + if boundaries.len() > 8 { + return Err(refuse( + "breg.access.membership-limit", + &site, + "Declare at most eight membership boundaries.", + )); + } + for (index, boundary) in boundaries.iter().enumerate() { + let entry_site = format!("{site}/{index}"); + if boundaries[..index].contains(boundary) { + return Err(refuse( + "breg.access.membership-duplicate", + &entry_site, + "Each membership boundary must be unique.", + )); + } + for field in ["membershipKeyField", "principalField", "activeField"] { + document.decode_at::(&format!("{entry_site}/{field}"))?; + } + if boundary.field == crate::membership::CANONICAL_ID { + return Err(refuse( + "breg.access.membership-key-type", + &format!("{entry_site}/field"), + "A historical membership boundary requires a stored reference field.", + )); + } + } + if !boundaries.is_empty() { + let operations: UniqueSet = document.decode_at(&format!("{path}/operations"))?; + if operations.iter().any(|operation| { + !matches!( + operation, + Operation::Get + | Operation::Lookup + | Operation::List + | Operation::Revisions + | Operation::Snapshot + ) + }) || grant + .get("writableFields") + .and_then(Value::as_array) + .is_some_and(|fields| !fields.is_empty()) + { + return Err(refuse( + "breg.access.membership-read-only", + &site, + "Historical membership boundaries grant reads only.", + )); + } + if grant + .get("spatialQueries") + .is_some_and(|queries| !queries.is_null()) + { + return Err(refuse( + "breg.access.membership-spatial-unsupported", + &site, + "Historical membership boundaries do not grant spatial queries.", + )); + } + } + let row_site = format!("{path}/rowBoundaries"); + let Some(rows) = grant.get_mut("rowBoundaries") else { + return Err(refuse( + "config.missing-key", + path, + "The historical grant requires rowBoundaries.", + )); + }; + if rows.as_array().is_some_and(|entries| { + entries + .iter() + .any(|entry| entry.get("membership").is_some()) + }) { + return Err(refuse( + "breg.membership.mixed-spelling", + &site, + "The sealed grant declares both historical and current membership boundaries.", + )); + } + if !boundaries.is_empty() { + if rows.as_str() == Some("unrestricted") { + *rows = Value::Array(Vec::new()); + } else if rows.as_array().is_none_or(Vec::is_empty) { + return Err(refuse("config.invalid-value", &row_site, "Historical rowBoundaries must be unrestricted or a nonempty list of claim boundaries.")); + } + rows.as_array_mut() + .expect("historical row boundaries checked") + .extend(boundaries.iter().map(|boundary| { + serde_json::json!({ + "field": boundary.field, + "membership": boundary.membership_entity, + }) + })); + } + grant.remove("membershipBoundaries"); + memberships.historical.insert(site, boundaries); + Ok(()) +} + fn read_with_value_types( file: &str, bytes: &[u8], format: &FormatSpec<'_>, sealed: bool, + predecessor_memberships: Option<&mut PredecessorMemberships>, ) -> Result<(Decoded, bool), Report> { let ( Decoded { @@ -6983,7 +7301,7 @@ fn read_with_value_types( } Err(report) => return Err(report), }; - let translated = if sealed { + let mut translated = if sealed { let action_plans = normalize_sealed_action_plans(&mut value, &document)?; let proposal_parties = normalize_sealed_proposal_parties(&mut value, &document)?; action_plans || proposal_parties @@ -7036,6 +7354,18 @@ fn read_with_value_types( "Declare the set under rowBoundarySets in this file and reference it by its identifier, with no other member.", )]) })?; + let removed_error = if let Some(memberships) = predecessor_memberships { + normalize_predecessor_memberships(&mut value, &document, memberships)?; + translated |= !memberships.historical.is_empty(); + let diagnostics: Vec<_> = removed_error + .into_iter() + .flat_map(Report::into_diagnostics) + .filter(|diagnostic| !memberships.historical.contains_key(&diagnostic.path)) + .collect(); + (!diagnostics.is_empty()).then(|| document.report_with(diagnostics)) + } else { + removed_error + }; let mut requirement_errors = Vec::new(); for collection in ["recordTypes", "extendRecordTypes"] { for (pointer, entity) in entries_mut(&mut value, collection, "") { @@ -7230,6 +7560,21 @@ fn field_option_diagnostics( ); } } + if collection == "actions" { + if let Some(forms) = item + .pointer("/execution/proposal/additionalForms") + .and_then(Value::as_object) + { + for (id, form) in forms { + if let Some(inputs) = form.get("inputs").and_then(Value::as_array) { + let id = registry_platform_yaml::escape_pointer_segment(id); + for (index, input) in inputs.iter().enumerate() { + check(input, format!("/actions/{item_key}/execution/proposal/additionalForms/{id}/inputs/{index}")); + } + } + } + } + } } } if let Some(types) = value.get("valueTypes").and_then(Value::as_object) { @@ -7246,20 +7591,22 @@ fn field_option_diagnostics( /// Read an authored module through the shared reader, as /// [`read_project_yaml`] reads a project. pub fn read_module_yaml(file: &str, bytes: &[u8]) -> Result, Report> { - read_module(file, bytes, false).map(|(decoded, _)| decoded) + read_module(file, bytes, false, None).map(|(decoded, _)| decoded) } fn read_module( file: &str, bytes: &[u8], sealed: bool, + predecessor_memberships: Option<&mut PredecessorMemberships>, ) -> Result<(Decoded, bool), Report> { let format = if sealed { &SEALED_MODULE_FORMAT } else { &MODULE_FORMAT }; - let (mut decoded, translated) = read_with_value_types(file, bytes, format, sealed)?; + let (mut decoded, translated) = + read_with_value_types(file, bytes, format, sealed, predecessor_memberships)?; let errors = crate::authoring_integrity::module_diagnostics(&mut decoded); if errors.is_empty() { Ok((decoded, translated)) @@ -7295,7 +7642,7 @@ pub fn parse_module_yaml(bytes: &[u8]) -> Result pub(crate) fn parse_sealed_project_yaml( bytes: &[u8], ) -> Result<(RegistryProject, bool), CompileFailure> { - read_project(PROJECT_FILE, bytes, true) + read_project(PROJECT_FILE, bytes, true, None) .map(|(decoded, translated)| (decoded.value, translated)) .map_err(|report| compile_failure_from_report("project", &report)) } @@ -7304,11 +7651,31 @@ pub(crate) fn parse_sealed_project_yaml( pub(crate) fn parse_sealed_module_yaml( bytes: &[u8], ) -> Result<(RegistryModule, bool), CompileFailure> { - read_module(MODULE_FILE, bytes, true) + read_module(MODULE_FILE, bytes, true, None) .map(|(decoded, translated)| (decoded.value, translated)) .map_err(|report| compile_failure_from_report("module", &report)) } +#[cfg(feature = "runtime")] +pub(crate) fn parse_predecessor_project_yaml( + bytes: &[u8], +) -> Result<(RegistryProject, PredecessorMemberships), CompileFailure> { + let mut memberships = PredecessorMemberships::default(); + read_project(PROJECT_FILE, bytes, true, Some(&mut memberships)) + .map(|(decoded, _)| (decoded.value, memberships)) + .map_err(|report| compile_failure_from_report("project", &report)) +} + +#[cfg(feature = "runtime")] +pub(crate) fn parse_predecessor_module_yaml( + bytes: &[u8], +) -> Result<(RegistryModule, PredecessorMemberships), CompileFailure> { + let mut memberships = PredecessorMemberships::default(); + read_module(MODULE_FILE, bytes, true, Some(&mut memberships)) + .map(|(decoded, _)| (decoded.value, memberships)) + .map_err(|report| compile_failure_from_report("module", &report)) +} + fn parse_json_value(bytes: &[u8], root: &str) -> Result { parse_json_strict(bytes).map_err(|error| { CompileFailure::from_one(Diagnostic::error( @@ -7709,10 +8076,12 @@ mod tests { .iter() .map(|entry| entry.pointer) .filter(|pointer| { - !RETIRED_ACTION_PLAN_KEYS + let action_plan = RETIRED_ACTION_PLAN_KEYS .iter() - .any(|entry| entry.pointer == *pointer) - && !(legacy_ownership && *pointer == RETIRED_PROPOSAL_OWNERSHIP.pointer) + .any(|entry| entry.pointer == *pointer); + let proposal_ownership = + legacy_ownership && *pointer == RETIRED_PROPOSAL_OWNERSHIP.pointer; + !(action_plan || proposal_ownership) }) .collect::>(); let observed = sealed diff --git a/crates/registry-breg/src/fixtures.rs b/crates/registry-breg/src/fixtures.rs index 420073d2a8..4791310536 100644 --- a/crates/registry-breg/src/fixtures.rs +++ b/crates/registry-breg/src/fixtures.rs @@ -250,6 +250,11 @@ pub enum FixtureError { ResponseTooLarge, ResponseShapeRefused, ExpectationMismatch, + /// A Proposal Get step's `waitSeconds` ran out before its response + /// matched the step's expectation. + ProposalWaitTimedOut { + wait_seconds: u8, + }, ExecutionRefused, RuntimeSetup(SchemaTestRuntimeSetupError), CandidateBindingRefused, @@ -349,6 +354,12 @@ impl fmt::Display for FixtureError { "journeys[{journey_index}] `{journey_id}`: {message}" ); } + if let Self::ProposalWaitTimedOut { wait_seconds } = self { + return write!( + formatter, + "fixture.proposal.wait-timed-out: the Proposal step did not complete with a matching response within waitSeconds ({wait_seconds}). Check that the Action applies automatically and that the expected fields are the applied ones" + ); + } if let Self::ExpectedFieldNotReadable { step_id, field, @@ -403,6 +414,7 @@ impl fmt::Display for FixtureError { | Self::ReceiptDocument(_) | Self::JourneyRefused { .. } | Self::ExpectedFieldNotReadable { .. } + | Self::ProposalWaitTimedOut { .. } | Self::RequiredActionInputMissing { .. } => { unreachable!("handled above") } @@ -466,8 +478,11 @@ struct StepSource { #[cfg_attr(feature = "schema", schemars(with = "Option"))] capture: Option, /// Maps disclosed Action result aliases to distinct local capture aliases. - /// Capture aliases must be unique throughout the journey, including earlier - /// captures; the reader checks this semantic rule. + /// On a Proposal get or apply step, maps an effect ID to a record capture + /// taken from the application's result links; the effect must be the + /// Action's only effect on its Record type. Capture aliases must be unique + /// throughout the journey, including earlier captures; the reader checks + /// this semantic rule. #[serde(default, deserialize_with = "members::local_id_map")] #[cfg_attr( feature = "schema", @@ -509,6 +524,15 @@ enum ActionSource { input: Map, #[serde(default)] idempotency_key: Option, + /// The text a `message` step writes to the Proposal's thread. + #[serde(default)] + text: Option, + /// On a Get step, how long the schema test runs the built-in + /// application executor and reads the Proposal again until the + /// response matches the step's expectation. + #[serde(default)] + #[cfg_attr(feature = "schema", schemars(with = "Option>"))] + wait_seconds: Option, }, Import { #[serde(deserialize_with = "members::http_objects")] @@ -1122,6 +1146,9 @@ struct ValidatedStep { expect: ExpectationSource, problem_bindings: FixtureProblemBindings, capture: Option, + /// Result captures: for an Invoke, alias by effect ID; for a Proposal + /// step, alias by the effect's Record type, which validation proved names + /// that effect alone, since result links carry no effect ID. capture_results: BTreeMap, } @@ -3694,6 +3721,32 @@ async fn execute_schema_test_with_issuers( let mut runtime = SchemaTestRuntime::new(database, config, compiled, issuers, initial_facts.clone()).await?; + let result = run_schema_test_journeys(&mut runtime, suite, &credential_map).await; + if let Some(worker) = runtime.application_worker.take() { + worker + .shutdown(config.operational_timeouts().shutdown_grace) + .await; + } + result?; + + let final_facts = database_execution_facts(&runtime.pool).await?; + if final_facts != runtime.initial_facts || !runtime.readiness.is_ready().await { + return Err(FixtureError::CandidateBindingRefused); + } + let successful = SuccessfulFixtureJourneys { + registry_revision: suite.registry_revision.clone(), + file_sha256: suite.file_sha256.clone(), + journey_ids: sorted_journey_ids(suite), + candidate_binding_sha256: candidate_binding_sha256(&candidate), + }; + build_schema_test_receipt(&candidate, suite, &successful) +} + +async fn run_schema_test_journeys( + runtime: &mut SchemaTestRuntime, + suite: &ValidatedFixtureJourneys, + credential_map: &CredentialMap, +) -> Result<(), FixtureError> { let mut bearer_index = 0usize; let mut observations = BTreeMap::new(); for (journey_index, journey) in suite.journeys.iter().enumerate() { @@ -3706,44 +3759,62 @@ async fn execute_schema_test_with_issuers( let bearer = credential_map .get(&(journey.id.clone(), step.id.clone())) .ok_or_else(|| step_failure(FixtureError::RequestConstructionRefused))?; - runtime - .authenticate_exact(step, bearer.as_str()) - .await - .map_err(&step_failure)?; let bearer_token = bearer.as_str(); - let response = if matches!(step.action, ActionSource::Import { .. }) { - runtime - .execute_import(step, &observations, bearer_token) - .await - .map_err(&step_failure)? + let wait = proposals::wait_seconds(step).map(|wait_seconds| { + let deadline = tokio::time::Instant::now() + + std::time::Duration::from_secs(u64::from(wait_seconds)); + (deadline, wait_seconds) + }); + let execute = async { + runtime.authenticate_exact(step, bearer_token).await?; + let response = if matches!(step.action, ActionSource::Import { .. }) { + runtime + .execute_import(step, &observations, bearer_token) + .await? + } else if let Some((deadline, wait_seconds)) = wait { + runtime + .await_proposal( + &journey.id, + step, + &observations, + bearer_token, + deadline, + wait_seconds, + ) + .await? + } else { + let request = fixture_request(&journey.id, step, &observations, bearer_token)?; + runtime + .app + .call(request) + .await + .map_err(|error| match error {})? + }; + let actual = response.status().as_u16(); + if actual != step.expect.status { + let (problem_code, problem_detail) = response_problem(response).await; + return Err(FixtureError::ResponseStatusMismatch { + expected: step.expect.status, + actual, + problem_code, + problem_detail, + }); + } + accept_response( + step, + response, + &mut observations, + Some(&runtime.pool), + false, + ) + .await + }; + let result = if let Some((deadline, wait_seconds)) = wait { + run_proposal_wait_step(deadline, wait_seconds, execute).await } else { - let request = fixture_request(&journey.id, step, &observations, bearer_token) - .map_err(&step_failure)?; - runtime - .app - .call(request) - .await - .map_err(|error| match error {})? + execute.await }; - let actual = response.status().as_u16(); - if actual != step.expect.status { - let (problem_code, problem_detail) = response_problem(response).await; - return Err(step_failure(FixtureError::ResponseStatusMismatch { - expected: step.expect.status, - actual, - problem_code, - problem_detail, - })); - } - accept_response( - step, - response, - &mut observations, - Some(&runtime.pool), - false, - ) - .await - .map_err(step_failure)?; + result.map_err(step_failure)?; bearer_index += 1; } observations.clear(); @@ -3751,17 +3822,41 @@ async fn execute_schema_test_with_issuers( if bearer_index != credential_map.len() { return Err(FixtureError::ExecutionRefused); } - let final_facts = database_execution_facts(&runtime.pool).await?; - if final_facts != runtime.initial_facts || !runtime.readiness.is_ready().await { - return Err(FixtureError::CandidateBindingRefused); + Ok(()) +} + +async fn run_proposal_wait_step( + deadline: tokio::time::Instant, + wait_seconds: u8, + step: impl std::future::Future>, +) -> Result { + match tokio::time::timeout_at(deadline, step).await { + // A ready future can win even if it finished after the deadline. + Ok(result) if tokio::time::Instant::now() < deadline => result, + _ => Err(FixtureError::ProposalWaitTimedOut { wait_seconds }), } - let successful = SuccessfulFixtureJourneys { - registry_revision: suite.registry_revision.clone(), - file_sha256: suite.file_sha256.clone(), - journey_ids: sorted_journey_ids(suite), - candidate_binding_sha256: candidate_binding_sha256(&candidate), - }; - build_schema_test_receipt(&candidate, suite, &successful) +} + +async fn read_proposal_wait_response( + app: &mut Router, + request: Request, + expected_status: u16, + expected_fields: &Map, +) -> Result>, FixtureError> { + let response = app.call(request).await.map_err(|error| match error {})?; + if response.status().as_u16() != expected_status { + return Ok(Some(response)); + } + let (parts, body) = response.into_parts(); + let bytes = to_bytes(body, MAX_RESPONSE_BYTES) + .await + .map_err(|_| FixtureError::ResponseTooLarge)?; + let matched = serde_json::from_slice::(&bytes).is_ok_and(|document| { + expected_fields + .iter() + .all(|(key, value)| document.get(key) == Some(value)) + }); + Ok(matched.then(|| Response::from_parts(parts, Body::from(bytes)))) } /// The problem code and detail a status mismatch may name. A code is kept @@ -3824,6 +3919,10 @@ struct SchemaTestRuntime { package_revision: String, schema_fingerprint: String, import_authority: ImportAuthorityOperatorService, + /// The mutation service behind `app`, which a waiting Proposal step + /// drives through the built-in application executor. + mutations: Arc, + application_worker: Option, #[cfg(feature = "wasm")] _wasm_runtime: crate::wasm_runtime::ConfiguredWasmRuntime, } @@ -3966,7 +4065,7 @@ impl SchemaTestRuntime { cursor_codec, ) .with_postgres_revisions(revisions) - .with_postgres_mutations(mutations), + .with_postgres_mutations(Arc::clone(&mutations)), ); let app = crate::startup::with_request_timeout_for_test( crate::api::authenticated_router(service, Arc::clone(&authenticator)), @@ -3982,11 +4081,52 @@ impl SchemaTestRuntime { package_revision: expected.package_digest, schema_fingerprint: expected.schema_fingerprint, import_authority, + mutations, + application_worker: None, #[cfg(feature = "wasm")] _wasm_runtime: wasm_runtime, }) } + /// Read a Proposal until the response matches the step's expectation or + /// the step deadline expires. Before each read the built-in executor runs + /// the production automatic-application path until it has no due work or + /// the step's deadline expires. Steps without a wait never start an attempt. + async fn await_proposal( + &mut self, + journey_id: &str, + step: &ValidatedStep, + observations: &BTreeMap, + token: &str, + deadline: tokio::time::Instant, + wait_seconds: u8, + ) -> Result, FixtureError> { + while tokio::time::Instant::now() < deadline { + let worker = self.application_worker.get_or_insert_with(|| { + proposals::ApplicationWorker::spawn(Arc::clone(&self.mutations)) + }); + if worker.run_once(deadline).await? { + continue; + } + if tokio::time::Instant::now() >= deadline { + break; + } + let request = fixture_request(journey_id, step, observations, token)?; + if let Some(response) = read_proposal_wait_response( + &mut self.app, + request, + step.expect.status, + &step.expect.fields, + ) + .await? + { + return Ok(response); + } + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + } + Err(FixtureError::ProposalWaitTimedOut { wait_seconds }) + } + async fn authenticate_exact( &self, step: &ValidatedStep, @@ -4669,7 +4809,11 @@ async fn accept_response( } } if !step.capture_results.is_empty() { - capture_immediate_action_results(step, &document, observations)?; + if let ActionSource::Proposal { .. } = step.action { + proposals::capture_results(step, &document, observations)?; + } else { + capture_immediate_action_results(step, &document, observations)?; + } } if let Some(capture) = step.capture.as_ref() { let kind = capture_observation_kind(step, &headers, &document)?; @@ -6516,6 +6660,56 @@ mod tests { PackageLoadContext, PackageMigrationPlanInput, PackageModuleSource, PackageSourceFile, }; + #[tokio::test] + async fn proposal_wait_deadline_covers_delayed_get_and_body_independently() { + struct PendingBody; + impl futures_core::Stream for PendingBody { + type Item = Result; + + fn poll_next( + self: std::pin::Pin<&mut Self>, + _: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + std::task::Poll::Pending + } + } + + for (path, app) in [ + ( + "/get", + Router::new().route( + "/get", + axum::routing::get(std::future::pending::>), + ), + ), + ( + "/body", + Router::new().route( + "/body", + axum::routing::get(|| async { Body::from_stream(PendingBody) }), + ), + ), + ] { + let mut app = app; + let request = Request::get(path).body(Body::empty()).unwrap(); + let deadline = tokio::time::Instant::now() + std::time::Duration::from_millis(20); + let fields = Map::from_iter([("state".to_owned(), json!("applied"))]); + let result = run_proposal_wait_step( + deadline, + 1, + read_proposal_wait_response(&mut app, request, 200, &fields), + ) + .await; + assert!( + matches!( + result, + Err(FixtureError::ProposalWaitTimedOut { wait_seconds: 1 }) + ), + "{path} must report the step deadline" + ); + } + } + #[test] fn fixture_refusals_distinguish_missing_claim_from_refused_credential() { assert_eq!( diff --git a/crates/registry-breg/src/fixtures/proposals.rs b/crates/registry-breg/src/fixtures/proposals.rs index fb0894b127..c91792a78b 100644 --- a/crates/registry-breg/src/fixtures/proposals.rs +++ b/crates/registry-breg/src/fixtures/proposals.rs @@ -1,8 +1,90 @@ // SPDX-License-Identifier: Apache-2.0 //! Authored Proposal journeys exercise only the ordinary authenticated source API. +use std::time::Duration; + +use tokio::sync::{mpsc, oneshot, watch}; +use tokio::time::{timeout, Instant}; + use super::*; use crate::contract::ProposalOperation; use crate::model::{CompiledActionExecution, CompiledProposalPermission}; +use crate::startup::{BackgroundTask, OperationalEvent, SupervisedTask}; + +struct ApplicationAttempt { + step_deadline: Instant, + result: oneshot::Sender, +} + +/// The schema test owns this worker until cleanup. Each waiting step can ask +/// for one production application attempt at a time. +pub(super) struct ApplicationWorker { + attempts: mpsc::Sender, + shutdown: watch::Sender, + task: SupervisedTask, +} + +impl ApplicationWorker { + pub(super) fn spawn(mutations: Arc) -> Self { + let (attempts, mut requested) = mpsc::channel::(1); + let (shutdown, shutdown_rx) = watch::channel(false); + let task = SupervisedTask::spawn( + BackgroundTask::ReviewWorker, + async move { + while let Some(attempt) = requested.recv().await { + let worked = + if attempt.result.is_closed() || Instant::now() >= attempt.step_deadline { + false + } else { + match mutations.run_automatic_proposal_once().await { + Ok(worked) => worked, + Err(_) => { + OperationalEvent::ReviewWorkerIterationFailed.emit(); + false + } + } + }; + // The step may have timed out. The worker's transaction + // and lease govern the attempt even without a waiter. + let _ = attempt.result.send(worked); + } + }, + shutdown_rx, + None, + ); + Self { + attempts, + shutdown, + task, + } + } + + pub(super) async fn run_once(&self, step_deadline: Instant) -> Result { + let (result, completed) = oneshot::channel(); + self.attempts + .send(ApplicationAttempt { + step_deadline, + result, + }) + .await + .map_err(|_| FixtureError::ExecutionRefused)?; + completed.await.map_err(|_| FixtureError::ExecutionRefused) + } + + pub(super) async fn shutdown(self, grace: Duration) { + let Self { + attempts, + shutdown, + mut task, + } = self; + shutdown.send_replace(true); + drop(attempts); + if timeout(grace, task.join()).await.is_err() { + // Cancel and join like serve. An unfinished committed claim + // retains its token, attempt count and expiry for lease recovery. + task.abort_and_join().await; + } + } +} #[derive(Clone, Copy, Deserialize, PartialEq, Eq)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] @@ -19,6 +101,10 @@ pub(super) enum ProposalJourneyOperation { Apply, GetReviewContext, GetReviewStatus, + /// Write `text` to the Proposal's message thread. + Message, + /// Mark the thread read through the newest message the capture shows. + ReadMessages, } impl ProposalJourneyOperation { @@ -35,6 +121,7 @@ impl ProposalJourneyOperation { Self::Apply => ProposalOperation::Apply, Self::GetReviewContext => ProposalOperation::GetReviewContext, Self::GetReviewStatus => ProposalOperation::GetReviewStatus, + Self::Message | Self::ReadMessages => ProposalOperation::Message, }) } fn path(self) -> &'static str { @@ -50,6 +137,8 @@ impl ProposalJourneyOperation { Self::Apply => "apply", Self::GetReviewContext => "review-context", Self::GetReviewStatus => "review-status", + Self::Message => "messages", + Self::ReadMessages => "messages/read", } } fn reads(self) -> bool { @@ -102,11 +191,13 @@ pub(super) fn validate_step( submission_capture, input, idempotency_key, + text, + wait_seconds, } = &step.request else { return Err(FixtureError::JourneyShapeRefused); }; - if !step.entity.is_empty() || !step.capture_results.is_empty() { + if !step.entity.is_empty() { return Err(FixtureError::JourneyShapeRefused); } let action = registry @@ -155,6 +246,10 @@ pub(super) fn validate_step( || is_start && (etag_capture.is_some() || submission_capture.is_some()) || *operation != ProposalJourneyOperation::Apply && submission_capture.is_some() || operation.reads() && (etag_capture.is_some() || idempotency_key.is_some()) + // Only a message writes text; mark-read takes neither a condition nor a key. + || (*operation == ProposalJourneyOperation::Message) != text.is_some() + || *operation == ProposalJourneyOperation::ReadMessages + && (etag_capture.is_some() || idempotency_key.is_some()) { return Err(FixtureError::JourneyShapeRefused); } @@ -181,11 +276,26 @@ pub(super) fn validate_step( } else if !input.is_empty() { return Err(FixtureError::JourneyShapeRefused); } + // A wait repeats only a read, until fields of a success match. + if wait_seconds.is_some_and(|seconds| { + *operation != ProposalJourneyOperation::Get + || !(1..=MAXIMUM_WAIT_SECONDS).contains(&seconds) + || step.expect.outcome != ExpectedOutcome::Success + || step.expect.fields.is_empty() + }) { + return Err(FixtureError::JourneyShapeRefused); + } + let result_captures = validate_result_captures(&step, *operation, action, captures, ids)?; let mut expect = step.expect.clone(); if expect.fields.keys().any(|key| { !matches!( key.as_str(), - "state" | "submissionVersion" | "effectDigest" | "applicationStatus" + "state" + | "submissionVersion" + | "effectDigest" + | "applicationStatus" + | "status" + | "turn" ) }) { return Err(FixtureError::JourneyShapeRefused); @@ -260,10 +370,118 @@ pub(super) fn validate_step( expect: step.expect, problem_bindings, capture: step.capture, - capture_results: BTreeMap::new(), + capture_results: result_captures, }) } +/// The longest a Proposal Get step may wait. +const MAXIMUM_WAIT_SECONDS: u8 = 60; + +/// How long a Proposal step waits, when it is a waiting Get. +pub(super) fn wait_seconds(step: &ValidatedStep) -> Option { + match &step.action { + ActionSource::Proposal { wait_seconds, .. } => *wait_seconds, + _ => None, + } +} + +/// Validate `captureResults` on a Proposal step and register each alias as a +/// record capture. An application's result links name a Record type and a +/// record, not an effect, so an effect is captured only when it is the +/// Action's one effect on its Record type; the returned map is keyed by that +/// Record type. +fn validate_result_captures( + step: &StepSource, + operation: ProposalJourneyOperation, + action: &CompiledAction, + captures: &mut BTreeMap, + ids: &mut BTreeSet, +) -> Result, FixtureError> { + let mut by_record_type = BTreeMap::new(); + if step.capture_results.is_empty() { + return Ok(by_record_type); + } + if !matches!( + operation, + ProposalJourneyOperation::Get | ProposalJourneyOperation::Apply + ) || step.expect.outcome != ExpectedOutcome::Success + { + return Err(FixtureError::JourneyShapeRefused); + } + for (effect, alias) in &step.capture_results { + let record_type = &action + .effects + .iter() + .find(|compiled| compiled.id == *effect) + .ok_or(FixtureError::LogicalReferenceRefused)? + .target + .entity_id; + if action + .effects + .iter() + .filter(|compiled| compiled.target.entity_id == *record_type) + .count() + != 1 + { + return Err(FixtureError::LogicalReferenceRefused); + } + if !valid_stable_id(alias) { + return Err(FixtureError::LogicalReferenceRefused); + } + if !ids.insert(alias.clone()) { + return Err(FixtureError::DuplicateIdentifier); + } + captures.insert( + alias.clone(), + CaptureSource { + entity: Some(record_type.clone()), + has_etag: false, + condition_map: false, + proposal_action: None, + }, + ); + by_record_type.insert(record_type.clone(), alias.clone()); + } + Ok(by_record_type) +} + +/// Capture each record the step names from the application's result links. +pub(super) fn capture_results( + step: &ValidatedStep, + document: &Value, + observations: &mut BTreeMap, +) -> Result<(), FixtureError> { + let links = document + .pointer("/application/resultLinks") + .and_then(Value::as_array) + .ok_or(FixtureError::ResponseShapeRefused)?; + for (record_type, alias) in &step.capture_results { + let mut matching = links + .iter() + .filter(|link| link["recordType"].as_str() == Some(record_type)); + let (Some(link), None) = (matching.next(), matching.next()) else { + return Err(FixtureError::ResponseShapeRefused); + }; + let record_id = link["recordId"] + .as_str() + .filter(|value| uuid::Uuid::parse_str(value).is_ok_and(|id| id.to_string() == *value)) + .ok_or(FixtureError::ResponseShapeRefused)?; + let revision = link["revision"] + .as_u64() + .ok_or(FixtureError::ResponseShapeRefused)?; + observations.insert( + alias.clone(), + Observation { + kind: ObservationKind::Record { + record_id: record_id.to_owned(), + etag: format!("\"breg-action-result-{revision}\""), + }, + }, + ); + } + Ok(()) +} + fn observed<'a>( observations: &'a BTreeMap, reference: &str, @@ -291,6 +509,8 @@ pub(super) fn request( submission_capture, input, idempotency_key, + text, + .. } = &step.action else { return Err(FixtureError::RequestConstructionRefused); @@ -303,7 +523,7 @@ pub(super) fn request( .as_str() .ok_or(FixtureError::RequestConstructionRefused)?; path = path.replace("{proposal_id}", id); - if !operation.reads() { + if !operation.reads() && *operation != ProposalJourneyOperation::ReadMessages { if_match = Some( etag_capture .as_deref() @@ -332,6 +552,20 @@ pub(super) fn request( let (document, _) = observed(observations, reference)?; json!({"submissionVersion":document["submissionVersion"],"effectDigest":document["effectDigest"]}) } + ProposalJourneyOperation::Message => { + json!({"text":text.as_deref().ok_or(FixtureError::RequestConstructionRefused)?}) + } + // Read through the newest message the captured document shows. + ProposalJourneyOperation::ReadMessages => { + let reference = proposal_capture + .as_ref() + .ok_or(FixtureError::RequestConstructionRefused)?; + let (document, _) = observed(observations, reference)?; + let through = document["messages"]["items"][0]["id"] + .as_str() + .ok_or(FixtureError::RequestConstructionRefused)?; + json!({ "through": through }) + } _ => json!({}), }; let mut request = authenticated_json_request( @@ -347,7 +581,7 @@ pub(super) fn request( if operation.reads() { *request.body_mut() = Body::empty(); request.headers_mut().remove(CONTENT_TYPE); - } else { + } else if *operation != ProposalJourneyOperation::ReadMessages { let key = format!( "fixture-{journey}-{}-{}", step.action_id @@ -375,17 +609,23 @@ pub(super) fn assert_response(step: &ValidatedStep, document: &Value) -> Result< let ActionSource::Proposal { operation, .. } = &step.action else { return Err(FixtureError::ResponseShapeRefused); }; - if !matches!( + // A thread command answers a reviewer without Get with the review context. + let review_document = matches!( *operation, ProposalJourneyOperation::GetReviewContext | ProposalJourneyOperation::GetReviewStatus - ) && (document["actionId"].as_str() != step.action_id.as_deref() - || document["id"] - .as_str() - .is_none_or(|id| uuid::Uuid::parse_str(id).is_err()) - || !matches!( - document["state"].as_str(), - Some("draft" | "submitted" | "applied" | "cancelled" | "rejected") - )) + ) || matches!( + *operation, + ProposalJourneyOperation::Message | ProposalJourneyOperation::ReadMessages + ) && document.get("context").is_some(); + if !review_document + && (document["actionId"].as_str() != step.action_id.as_deref() + || document["id"] + .as_str() + .is_none_or(|id| uuid::Uuid::parse_str(id).is_err()) + || !matches!( + document["state"].as_str(), + Some("draft" | "submitted" | "applied" | "cancelled" | "rejected") + )) { return Err(FixtureError::ResponseShapeRefused); } @@ -543,6 +783,295 @@ mod tests { ); } + const AUTOMATIC_PROJECT: &[u8] = + include_bytes!("../../tests/fixtures/automatic-application/project.yaml"); + const AUTOMATIC_JOURNEYS: &[u8] = + include_bytes!("../../tests/fixtures/automatic-application/journeys.yaml"); + + fn automatic_registry() -> CompiledRegistry { + compile_project_with_assets( + &parse_project_yaml(AUTOMATIC_PROJECT).unwrap(), + &[], + &[], + CompileProfile::Authoring, + ) + .unwrap() + } + + fn step<'a>(suite: &'a ValidatedFixtureJourneys, id: &str) -> &'a ValidatedStep { + suite + .journeys + .iter() + .flat_map(|journey| &journey.steps) + .find(|step| step.id == id) + .unwrap() + } + + #[test] + fn a_get_step_may_wait_and_capture_the_record_its_effect_wrote() { + let suite = validate_fixture_journeys(AUTOMATIC_JOURNEYS, &automatic_registry()).unwrap(); + let wait = step(&suite, "await-application"); + assert_eq!(wait_seconds(wait), Some(10)); + // Result links carry no effect ID, so the capture is held by the + // effect's Record type, which names that effect alone. + assert_eq!( + wait.capture_results, + BTreeMap::from([("note".to_owned(), "filed-note".to_owned())]) + ); + assert_eq!(wait_seconds(step(&suite, "submit-note")), None); + } + + #[test] + #[allow( + clippy::disallowed_methods, + reason = "tests edit a checked-in synthetic authored journey to assert refusals" + )] + fn waits_and_result_captures_are_refused_where_they_cannot_hold() { + let registry = automatic_registry(); + let original: Value = serde_norway::from_slice(AUTOMATIC_JOURNEYS).unwrap(); + let refused = |step_id: &str, edit: &dyn Fn(&mut Value)| { + let mut changed = original.clone(); + let step = changed["journeys"][0]["steps"] + .as_array_mut() + .unwrap() + .iter_mut() + .find(|step| step["id"] == step_id) + .unwrap(); + edit(step); + validate_fixture_journeys(&serde_json::to_vec(&changed).unwrap(), ®istry).is_err() + }; + // Only a Get waits; a command is never repeated. + assert!(refused("submit-note", &|step| step["request"] + ["waitSeconds"] = + json!(5))); + // The wait is bounded at one minute and is never zero. + for bound in [0, 61] { + assert!(refused("await-application", &|step| step["request"] + ["waitSeconds"] = + json!(bound))); + } + // A wait needs fields to wait for, and a success to read them from. + assert!(refused("await-application", &|step| { + step["expect"].as_object_mut().unwrap().remove("fields"); + })); + assert!(refused("await-application", &|step| { + step["expect"] = + json!({"outcome": "refusal", "status": 404, "problemCode": "resource.not-found"}); + step.as_object_mut().unwrap().remove("captureResults"); + })); + // A result capture names one of the Action's effects, on a read or + // apply response that carries the application. + assert!(refused("await-application", &|step| step + ["captureResults"] = + json!({"unknown-effect": "filed-note"}))); + assert!(refused("submit-note", &|step| step["captureResults"] = + json!({"note": "filed-note"}))); + // A captured alias is unique in the journey. + assert!(refused("await-application", &|step| step + ["captureResults"] = + json!({"filed": "draft"}))); + } + + #[test] + #[allow( + clippy::disallowed_methods, + reason = "tests edit a checked-in synthetic authored project to assert refusals" + )] + fn two_effects_on_one_record_type_cannot_be_told_apart_in_the_result_links() { + let mut project: Value = serde_norway::from_slice(AUTOMATIC_PROJECT).unwrap(); + project["actions"]["file-note"]["plan"]["effects"] + .as_array_mut() + .unwrap() + .push(json!({"id": "copy", "target": {"recordType": "note"}, "operation": "create", "set": {"body": {"fromInput": "body"}}})); + let registry = compile_project_with_assets( + &crate::contract::parse_project_json(&serde_json::to_vec(&project).unwrap()).unwrap(), + &[], + &[], + CompileProfile::Authoring, + ) + .unwrap(); + assert!(validate_fixture_journeys(AUTOMATIC_JOURNEYS, ®istry).is_err()); + } + + #[test] + fn a_result_capture_takes_the_link_for_its_effects_record_type() { + let suite = validate_fixture_journeys(AUTOMATIC_JOURNEYS, &automatic_registry()).unwrap(); + let wait = step(&suite, "await-application"); + let record = uuid::Uuid::new_v4(); + let mut observations = BTreeMap::new(); + capture_results( + wait, + &json!({"application": {"resultLinks": [ + {"recordType": "note", "recordId": record, "revision": 1} + ]}}), + &mut observations, + ) + .unwrap(); + let ObservationKind::Record { record_id, .. } = &observations["filed-note"].kind else { + panic!("a result capture is a record observation"); + }; + assert_eq!(record_id, &record.to_string()); + for document in [ + json!({}), + json!({"application": {"resultLinks": []}}), + json!({"application": {"resultLinks": [ + {"recordType": "other", "recordId": record, "revision": 1} + ]}}), + json!({"application": {"resultLinks": [ + {"recordType": "note", "recordId": "not-a-uuid", "revision": 1} + ]}}), + ] { + assert!(capture_results(wait, &document, &mut BTreeMap::new()).is_err()); + } + } + + #[test] + fn the_starter_journeys_wait_for_their_automatic_registration() { + let registry = compile_project_with_assets( + &parse_project_yaml(include_bytes!( + "../../../../products/breg/examples/minimal/registry.yaml" + )) + .unwrap(), + &[], + &[], + CompileProfile::Authoring, + ) + .unwrap(); + let suite = validate_fixture_journeys( + include_bytes!("../../../../products/breg/examples/minimal/tests/journeys.yaml"), + ®istry, + ) + .unwrap(); + assert!(wait_seconds(step(&suite, "await-registration")).is_some()); + } + + const MESSAGE_PROJECT: &[u8] = + include_bytes!("../../tests/fixtures/message-journeys/project.yaml"); + + const MESSAGE_JOURNEY: &[u8] = + include_bytes!("../../tests/fixtures/message-journeys/journeys.yaml"); + + fn message_registry() -> CompiledRegistry { + crate::compiler::compile_project( + &parse_project_yaml(MESSAGE_PROJECT).unwrap(), + &[], + CompileProfile::Authoring, + ) + .unwrap() + } + + fn message_step<'a>(suite: &'a ValidatedFixtureJourneys, id: &str) -> &'a ValidatedStep { + suite.journeys[0] + .steps + .iter() + .find(|step| step.id == id) + .unwrap() + } + + #[tokio::test] + async fn message_journeys_write_through_the_thread_route_and_read_through_the_newest_message() { + let registry = message_registry(); + let suite = validate_fixture_journeys(MESSAGE_JOURNEY, ®istry).unwrap(); + let id = uuid::Uuid::new_v4(); + let newest = uuid::Uuid::new_v4(); + let observations = BTreeMap::from([ + ( + "office-view".to_owned(), + Observation { + kind: ObservationKind::Proposal { + document: json!({"id":id}), + etag: "\"office-condition\"".to_owned(), + }, + }, + ), + ( + "applicant-view".to_owned(), + Observation { + kind: ObservationKind::Proposal { + document: json!({"id":id,"messages":{"items":[{"id":newest},{"id":uuid::Uuid::new_v4()}]}}), + etag: "\"applicant-condition\"".to_owned(), + }, + }, + ), + ]); + + let write = fixture_request( + "thread", + message_step(&suite, "office-writes"), + &observations, + "synthetic-token", + ) + .unwrap(); + assert_eq!(write.method(), Method::POST); + assert_eq!(write.uri().path(), format!("/v1/proposals/{id}/messages")); + assert_eq!(write.uri().query(), Some("accessProfile=office")); + assert_eq!(write.headers()[IF_MATCH], "\"office-condition\""); + assert!(write.headers().contains_key("idempotency-key")); + let bytes = axum::body::to_bytes(write.into_body(), 4096).await.unwrap(); + let body: Value = serde_json::from_slice(&bytes).unwrap(); + assert_eq!(body, json!({"text":"Please add the full address."})); + + let read = fixture_request( + "thread", + message_step(&suite, "applicant-reads"), + &observations, + "synthetic-token", + ) + .unwrap(); + assert_eq!(read.method(), Method::POST); + assert_eq!( + read.uri().path(), + format!("/v1/proposals/{id}/messages/read") + ); + // Mark-read only moves the reader's side forward: no condition, no key. + assert!(!read.headers().contains_key(IF_MATCH)); + assert!(!read.headers().contains_key("idempotency-key")); + let bytes = axum::body::to_bytes(read.into_body(), 4096).await.unwrap(); + let body: Value = serde_json::from_slice(&bytes).unwrap(); + assert_eq!(body, json!({"through":newest})); + } + + #[test] + #[allow( + clippy::disallowed_methods, + reason = "tests edit an inline synthetic journey to assert refusals" + )] + fn message_steps_take_text_only_where_they_write_and_need_the_grant() { + let registry = message_registry(); + let original: Value = serde_norway::from_slice(MESSAGE_JOURNEY).unwrap(); + let edit = |id: &str, change: &dyn Fn(&mut Value)| { + let mut changed = original.clone(); + let step = changed["journeys"][0]["steps"] + .as_array_mut() + .unwrap() + .iter_mut() + .find(|step| step["id"] == id) + .unwrap(); + change(step); + validate_fixture_journeys(&serde_json::to_vec(&changed).unwrap(), ®istry) + }; + // A message without text, text on a step that writes none, and a + // mark-read that names a key are each refused. + assert!(edit("office-writes", &|step| { + step["request"].as_object_mut().unwrap().remove("text"); + }) + .is_err()); + assert!(edit("applicant-view", &|step| { + step["request"]["text"] = json!("Not a message"); + }) + .is_err()); + assert!(edit("applicant-reads", &|step| { + step["request"]["idempotencyKey"] = json!("read-once"); + }) + .is_err()); + // The applicant's grant holds message; a profile without it cannot + // be named for a message step. + assert!(edit("office-writes", &|step| { + step["accessProfile"] = json!("missing-profile"); + }) + .is_err()); + } + #[test] fn proposal_unknown_members_use_positioned_closed_union_diagnostics() { let bytes = b"apiVersion: id.registrystack.org/formats/breg/journeys/v1\nkind: BRegJourneys\njourneys:\n - id: example\n steps:\n - id: start\n action: deactivate-facility\n accessProfile: facility-correction-author\n claims: {principal: example}\n request:\n type: proposal\n transition: start\n approve: true\n expect: {outcome: success, status: 201}\n"; diff --git a/crates/registry-breg/src/hooks.rs b/crates/registry-breg/src/hooks.rs index 98ce539b4a..df7efae22c 100644 --- a/crates/registry-breg/src/hooks.rs +++ b/crates/registry-breg/src/hooks.rs @@ -474,7 +474,12 @@ impl BregDeliverySeams { let batch = match self.prune_terminal_batch().await { Ok(batch) => batch, Err(reason) => { + let code = match reason { + RetentionFailureReason::LockTimeout => "hook.retention.lock_timeout", + _ => "hook.retention.failed", + }; tracing::error!( + code, removed, reason = reason.as_str(), "hook metadata retention failed" diff --git a/crates/registry-breg/src/idempotency.rs b/crates/registry-breg/src/idempotency.rs index 6e152eb4e0..3c752ec7ef 100644 --- a/crates/registry-breg/src/idempotency.rs +++ b/crates/registry-breg/src/idempotency.rs @@ -14,6 +14,7 @@ use uuid::Uuid; use crate::history_reference::SnapshotReference; use crate::model::HttpMethod; use crate::postgres::{ActionClaimContext, ClaimContext, RowBoundaryContext}; +use crate::proposal_messages::Side; use crate::stored_bytes; // Every compiled effect mutates at least one field, so this also bounds the @@ -88,20 +89,31 @@ impl HeldResponse { body: &serde_json::Value, headers: BTreeMap>, ) -> Result { + Self::from_json_if_fits(status, body, headers)?.ok_or(IdempotencyError::InvalidInput) + } + + pub(crate) fn from_json_if_fits( + status: u16, + body: &serde_json::Value, + headers: BTreeMap>, + ) -> Result, IdempotencyError> { if !(200..=299).contains(&status) || headers.values().any(|value| !valid_header_value(value)) { return Err(IdempotencyError::InvalidInput); } let body = canonicalize_json(body).map_err(|_| IdempotencyError::InvalidInput)?; - if body.is_empty() || body.len() > MAX_HELD_BODY_BYTES { + if body.is_empty() { return Err(IdempotencyError::InvalidInput); } - Ok(Self { + if body.len() > MAX_HELD_BODY_BYTES { + return Ok(None); + } + Ok(Some(Self { status, body, headers, - }) + })) } #[must_use] @@ -304,6 +316,7 @@ pub(crate) enum StoredResultMetadata { record_revision: i64, submission_version: i64, result_count: u16, + thread_side: Option, }, ImmediateAction { result_count: u16, @@ -816,15 +829,20 @@ pub(crate) async fn lock_and_load( else { return Ok(None); }; - if row.get::<_, String>(0) != binding.binding_reference { + let result_kind = row.get::<_, String>(1); + let stored_binding = row.get::<_, String>(0); + let thread_side = if result_kind == "proposal" { + matched_proposal_thread_side(&binding.binding_reference, &stored_binding)? + } else if stored_binding == binding.binding_reference { + None + } else { return Err(IdempotencyError::Conflict); - } + }; if row.get::<_, Option>(9).is_some() { // Erasure is permanent. Keep the consumed key reserved and refuse // replay without presenting a transient outage to retrying clients. return Err(IdempotencyError::Conflict); } - let result_kind = row.get::<_, String>(1); if result_kind == "erased" { // Erasure is irreversible, so the consumed key answers with the same // terminal conflict the erased-at path answers with. A transient outage @@ -892,6 +910,7 @@ pub(crate) async fn lock_and_load( record_revision, submission_version, result_count, + thread_side, } } "immediate_action" => { @@ -981,6 +1000,7 @@ pub(crate) async fn insert_result( record_revision, submission_version, result_count, + .. } if !record_reference.is_empty() && *record_revision > 0 && *submission_version > 0 @@ -1019,6 +1039,13 @@ pub(crate) async fn insert_result( }; let caller = &binding.caller; let receipt_retention_days = i32::from(caller.receipt_retention_days); + let binding_reference = match metadata { + StoredResultMetadata::Proposal { + thread_side: Some(side), + .. + } => proposal_thread_binding_reference(&binding.binding_reference, *side), + _ => binding.binding_reference.clone(), + }; let changed = transaction .execute( "INSERT INTO registry_internal.registry_idempotency @@ -1030,7 +1057,7 @@ pub(crate) async fn insert_result( transaction_timestamp() + pg_catalog.make_interval(days => $15))", &[ &binding.key_reference, - &binding.binding_reference, + &binding_reference, &result_kind, &record_revision, &status, @@ -1054,6 +1081,29 @@ pub(crate) async fn insert_result( Ok(()) } +fn proposal_thread_binding_reference(binding: &str, side: Side) -> String { + sha256_reference( + "breg-idempotency-proposal-thread-v1", + &[binding, side.as_str()], + ) +} + +fn matched_proposal_thread_side( + binding: &str, + stored: &str, +) -> Result, IdempotencyError> { + // The spent-key identity is independent of the side. Older receipts + // can still match the request, but cannot prove which side they served. + if binding == stored { + return Ok(None); + } + [Side::Party, Side::Official] + .into_iter() + .find(|side| proposal_thread_binding_reference(binding, *side) == stored) + .map(Some) + .ok_or(IdempotencyError::Conflict) +} + /// Replace exact cached mutation responses that could replay erased historical /// bytes with a minimal tombstone row. The idempotency key and binding remain /// durable so an old retry cannot re-execute the mutation. @@ -1330,6 +1380,24 @@ impl std::fmt::Debug for HeldResponse { mod tests { use super::*; + #[test] + fn proposal_receipt_binding_preserves_the_request_and_recovers_the_original_side() { + let binding = "original-request"; + assert_eq!(matched_proposal_thread_side(binding, binding), Ok(None)); + for side in [Side::Party, Side::Official] { + let bound = proposal_thread_binding_reference(binding, side); + assert_ne!(bound, binding); + assert_eq!( + matched_proposal_thread_side(binding, &bound), + Ok(Some(side)) + ); + assert_eq!( + matched_proposal_thread_side("another-request", &bound), + Err(IdempotencyError::Conflict) + ); + } + } + #[test] fn a_policy_refuses_every_issuer_the_engine_reserves() { for reserved in [ diff --git a/crates/registry-breg/src/immediate_actions.rs b/crates/registry-breg/src/immediate_actions.rs index de1749e63d..2255a589d9 100644 --- a/crates/registry-breg/src/immediate_actions.rs +++ b/crates/registry-breg/src/immediate_actions.rs @@ -8,8 +8,10 @@ use serde_json::json; use sha2::{Digest, Sha256}; use crate::contract::{ - AccessProfileSource, ActionEffectSource, ActionSource, ActionValueSource, FieldTypeSource, - Operation, ProjectAccessProfileSource, RowBoundarySource, DECIMAL_BOUNDS_REQUIREMENTS, + AccessProfileSource, ActionEffectSource, ActionInputSource, ActionSource, ActionValueSource, + FieldTypeSource, Operation, ProjectAccessProfileSource, ProposalPolicySource, + ProposalReviewSource, RowBoundarySource, DECIMAL_BOUNDS_REQUIREMENTS, MAXIMUM_ADDITIONAL_FORMS, + MAXIMUM_ADDITIONAL_FORM_INPUTS, }; use crate::diagnostics::Diagnostic; use crate::logical_names::{default_api_name, reserved_logical_name, valid_api_name}; @@ -158,7 +160,7 @@ fn compile_action( "an Action must declare at least one typed input", )); } - let inputs = compile_inputs(action, entities, errors); + let inputs = compile_inputs(&action.inputs, "actions[].inputs[]", entities, errors); let input_map = inputs .iter() .map(|input| (input.id.as_str(), input)) @@ -1439,26 +1441,29 @@ fn validate_current_revision( } fn compile_inputs( - action: &ActionSource, + source: &[ActionInputSource], + path: &str, entities: &BTreeMap, errors: &mut Vec, ) -> Vec { let mut ids = BTreeSet::new(); let mut api_names = BTreeSet::new(); let mut inputs = Vec::new(); - for input in &action.inputs { - validate_id(&input.id, "actions[].inputs[].id", errors); + let id_path = format!("{path}.id"); + let api_name_path = format!("{path}.apiName"); + for input in source { + validate_id(&input.id, &id_path, errors); if reserved_logical_name(&input.id) { errors.push(Diagnostic::error( "breg.action.input-id-reserved", - "actions[].inputs[].id", + &id_path, "an action input identifier collides with a reserved Registry field", )); } if !ids.insert(input.id.as_str()) { errors.push(Diagnostic::error( "breg.action.input-id-duplicate", - "actions[].inputs[].id", + &id_path, "action input identifiers must be duplicate-free", )); } @@ -1469,18 +1474,18 @@ fn compile_inputs( if !valid_api_name(&api_name) || reserved_logical_name(&api_name) { errors.push(Diagnostic::error( "breg.action.input-api-name-invalid", - "actions[].inputs[].apiName", + &api_name_path, "an action input API name must be a non-reserved lower camelCase identifier", )); } if !api_names.insert(api_name.clone()) { errors.push(Diagnostic::error( "breg.action.input-api-name-duplicate", - "actions[].inputs[].apiName", + &api_name_path, "action input API names must be unique within the action", )); } - validate_field_type_bounds(&input.field_type, "actions[].inputs[]", errors); + validate_field_type_bounds(&input.field_type, path, errors); if let Some(pattern) = &input.pattern { if !matches!( input.field_type, @@ -1488,13 +1493,13 @@ fn compile_inputs( ) { errors.push(Diagnostic::error( "breg.action.input-pattern-type-unsupported", - "actions[].inputs[].pattern", + format!("{path}.pattern"), "pattern requires a string or text action input", )); } else if !crate::compiler::native_pattern_within_bounds(pattern) { errors.push(Diagnostic::error( "breg.action.input-pattern-bounds-invalid", - "actions[].inputs[].pattern", + format!("{path}.pattern"), "PostgreSQL pattern must be at most 4096 UTF-8 bytes and contain no NUL; syntax is validated by PostgreSQL", )); } @@ -1503,7 +1508,7 @@ fn compile_inputs( if !entities.contains_key(target) { errors.push(Diagnostic::error( "breg.action.input-reference-target-unknown", - "actions[].inputs[].target", + format!("{path}.target"), "an action reference input target does not resolve", )); } @@ -1521,6 +1526,84 @@ fn compile_inputs( inputs } +fn compile_additional_forms( + action_id: &str, + proposal: &ProposalPolicySource, + entities: &BTreeMap, + errors: &mut Vec, +) -> BTreeMap { + if proposal.additional_forms.is_empty() { + return BTreeMap::new(); + } + let path = format!("actions[id={action_id}].execution.proposal.additionalForms"); + if matches!(proposal.review, ProposalReviewSource::None {}) { + errors.push(Diagnostic::error( + "breg.additional-form.review-required", + &path, + "additional forms require review.type: required; configure required review or remove additionalForms", + )); + } + if proposal.additional_forms.len() > MAXIMUM_ADDITIONAL_FORMS { + errors.push(Diagnostic::error( + "breg.additional-form.count", + &path, + &format!("declare at most {MAXIMUM_ADDITIONAL_FORMS} additional forms"), + )); + } + let mut additional_forms = BTreeMap::new(); + for (id, form) in &proposal.additional_forms { + let inputs = format!("{path}.{id}.inputs"); + if !(1..=MAXIMUM_ADDITIONAL_FORM_INPUTS).contains(&form.inputs.len()) { + errors.push(Diagnostic::error( + "breg.additional-form.input-count", + &inputs, + &format!( + "declare from 1 to {MAXIMUM_ADDITIONAL_FORM_INPUTS} inputs per additional form" + ), + )); + } + for (index, input) in form.inputs.iter().enumerate() { + if matches!( + input.field_type, + FieldTypeSource::Reference { .. } + | FieldTypeSource::Crs84Point { .. } + | FieldTypeSource::Crs84Polygon { .. } + | FieldTypeSource::Structured { .. } + | FieldTypeSource::VocabularyCode { .. } + ) { + errors.push(Diagnostic::error( + "breg.additional-form.input-type", + format!("{inputs}[{index}].type"), + "choose boolean, string, text, int64, decimal, date, timestamp, or uuid", + )); + } + if input.pattern.is_some() { + errors.push(Diagnostic::error( + "breg.additional-form.input-pattern", + format!("{inputs}[{index}].pattern"), + "remove the PostgreSQL pattern from the additional-form input", + )); + } + } + let fields = compile_inputs(&form.inputs, &format!("{inputs}[]"), entities, errors); + if !(1..=32).contains(&form.maximum_count) { + errors.push(Diagnostic::error( + "breg.additional-form.maximum-count", + format!("{path}.{id}.maximumCount"), + "allow between 1 and 32 entries per submission", + )); + } + additional_forms.insert( + id.clone(), + crate::model::CompiledAdditionalForm { + maximum_count: form.maximum_count, + inputs: fields, + }, + ); + } + additional_forms +} + /// Binds each file an Action request carries to the record slot one create /// effect fills. Only an immediate fixed-plan Action without Evidence or a /// timer can carry files: every other immediate path has no request to take @@ -3105,12 +3188,13 @@ fn party_label(party: Option) -> &'static str { /// The operations a subject entry may hold. The subject follows work someone /// else filed: it reads, answers, adds files and withdraws, and never changes /// what was filed. -const SUBJECT_OPERATIONS: [crate::contract::ProposalOperation; 6] = [ +const SUBJECT_OPERATIONS: [crate::contract::ProposalOperation; 7] = [ crate::contract::ProposalOperation::Get, crate::contract::ProposalOperation::List, crate::contract::ProposalOperation::GetReviewStatus, crate::contract::ProposalOperation::Answer, crate::contract::ProposalOperation::Add, + crate::contract::ProposalOperation::Message, crate::contract::ProposalOperation::Cancel, ]; @@ -3235,7 +3319,7 @@ fn validate_party_grant( "breg.proposal.subject-operation-forbidden", format!("{path}.operations"), &format!( - "a `party: subject` entry cannot hold {}. The subject may hold only get, list, get-review-status, answer, add and cancel", + "a `party: subject` entry cannot hold {}. The subject may hold only get, list, get-review-status, answer, add, message and cancel", forbidden.join(", ") ), )); @@ -3278,6 +3362,7 @@ fn compile_execution( let ActionExecutionSource::Proposal { proposal } = &action.execution else { return CompiledActionExecution::Immediate; }; + let additional_forms = compile_additional_forms(&action.id, proposal, entities, errors); let attachment_field_names = action .inputs .iter() @@ -3368,6 +3453,21 @@ fn compile_execution( validate_proposal_subject(action, entities, subject, errors); subject.clone() }); + let messages = proposal.messages.as_ref().map(|messages| { + if !(1..=MAX_PROPOSAL_MESSAGE_COUNT).contains(&messages.maximum_count) { + errors.push(Diagnostic::error( + "breg.proposal.message-count-invalid", + format!( + "actions[id={}].execution.proposal.messages.maximumCount", + action.id + ), + &format!("a Proposal thread holds 1 through {MAX_PROPOSAL_MESSAGE_COUNT} messages"), + )); + } + CompiledProposalMessages { + maximum_count: messages.maximum_count, + } + }); let mut permissions = Vec::new(); for profile in profiles { for grant in profile @@ -3378,6 +3478,25 @@ fn compile_execution( { crate::consent::validate_proposal_permission(profile, grant, entities, errors); validate_party_grant(action, profile, grant, subject.is_some(), errors); + if grant.operations.contains(&ProposalOperation::Message) + && (messages.is_none() + || matches!( + profile.actor_kind, + Some(ActorKindSource::Agent | ActorKindSource::Service) + )) + { + errors.push(Diagnostic::error( + "breg.proposal.message-grant-invalid", + format!( + "accessProfiles[id={}].permissions.proposals[action={}].operations", + profile.id, action.id + ), + &format!( + "`message` reads and writes the thread between people: Action `{}` must declare `execution.proposal.messages`, and access profile `{}` must set `actorKind: human` or leave it unset", + action.id, profile.id + ), + )); + } if application.is_automatic() && grant.operations.iter().any(|operation| { matches!( @@ -3570,6 +3689,44 @@ fn compile_execution( "context grants must name fields in this Action's declared review context", )); } + // Form values reach only a person reading for themselves; a + // profile no such person reads through may not hold a form field. + let form_fields = proposal + .review_context + .as_ref() + .map(|context| { + context + .fields + .iter() + .filter(|(_, source)| { + matches!( + source, + crate::contract::ProposalContextValueSource::AdditionalForm { .. } + ) + }) + .map(|(name, _)| name.clone()) + .collect::>() + }) + .unwrap_or_default(); + if (profile.task_grant.is_some() + || matches!( + profile.actor_kind, + Some(ActorKindSource::Agent | ActorKindSource::Service) + )) + && !grant.readable_context_fields.is_disjoint(&form_fields) + { + errors.push(Diagnostic::error( + "breg.additional-form.context-reader-invalid", + format!( + "accessProfiles[id={}].permissions.proposals[action={}].readableContextFields", + profile.id, action.id + ), + &format!( + "a review-context field that shows an additional form is served only to a person reading for themselves: access profile `{}` is an agent, service or task-grant profile and may not read it", + profile.id + ), + )); + } if grant .operations .contains(&ProposalOperation::GetTaskGrantContext) @@ -3692,6 +3849,25 @@ fn compile_execution( "attachment grants must name declared slots and require Get for reads, Edit for attachment writes, or Add for additions", )); } + if grant + .readable_forms + .iter() + .any(|id| !additional_forms.contains_key(id)) + || grant + .writable_forms + .iter() + .any(|id| !additional_forms.contains_key(id)) + || (!grant.readable_forms.is_empty() + && !grant.operations.contains(&ProposalOperation::Get)) + || (!grant.writable_forms.is_empty() + && !grant.operations.contains(&ProposalOperation::Add)) + { + errors.push(Diagnostic::error( + "breg.additional-form.grant-invalid", + "accessProfiles[].permissions.proposals", + "form grants must name declared forms and require Get for reads or Add for writes", + )); + } permissions.push(CompiledProposalPermission { profile_id: profile.id.clone(), review_authority: grant.review_authority.clone(), @@ -3711,6 +3887,8 @@ fn compile_execution( readable_inputs: grant.readable_inputs.as_set().clone(), readable_attachments: grant.readable_attachments.as_set().clone(), writable_attachments: grant.writable_attachments.as_set().clone(), + readable_forms: grant.readable_forms.as_set().clone(), + writable_forms: grant.writable_forms.as_set().clone(), writable_inputs: grant .writable_inputs .as_ref() @@ -3742,6 +3920,16 @@ fn compile_execution( } use crate::contract::ProposalContextValueSource; let valid = match value { + ProposalContextValueSource::AdditionalForm { form } => { + if !additional_forms.contains_key(form) { + errors.push(Diagnostic::error( + "breg.additional-form.context-unknown", + "actions[].execution.proposal.reviewContext.fields", + "the review-context field must name a declared form", + )); + } + true + } ProposalContextValueSource::Document { slot } => attachments.contains_key(slot), ProposalContextValueSource::Additions { slot } => proposal .additions @@ -3802,9 +3990,11 @@ fn compile_execution( review_context: proposal.review_context.clone(), attachments, additions: proposal.additions.clone(), + additional_forms, promotions: Vec::new(), permissions, subject, + messages, }, } } @@ -3835,12 +4025,17 @@ pub fn migration_review_revision(action: &CompiledAction) -> String { guard.label = None; } if let crate::model::CompiledActionExecution::Proposal { proposal } = &mut action.execution { + // Form declarations may change without reinterpreting a frozen Action. + proposal.additional_forms.clear(); proposal .permissions .sort_by(|a, b| a.profile_id.cmp(&b.profile_id)); for hook in &mut proposal.hooks { hook.display = Default::default(); } + // The thread changes no frozen work: requests in flight get it at + // activation. + proposal.messages = None; if let Some(grant) = &mut proposal.system_apply_grant { grant.revision.clear(); grant.action_revision.clear(); diff --git a/crates/registry-breg/src/lib.rs b/crates/registry-breg/src/lib.rs index b8fe655feb..3a821a25f2 100644 --- a/crates/registry-breg/src/lib.rs +++ b/crates/registry-breg/src/lib.rs @@ -150,6 +150,8 @@ pub mod problem_location; pub mod proposal_events; pub mod proposal_hooks; #[cfg(feature = "runtime")] +mod proposal_messages; +#[cfg(feature = "runtime")] mod proposal_prepare; #[cfg(feature = "runtime")] pub mod proposal_retention; diff --git a/crates/registry-breg/src/lifecycle.rs b/crates/registry-breg/src/lifecycle.rs index d2c8b21ad2..ff86883f07 100644 --- a/crates/registry-breg/src/lifecycle.rs +++ b/crates/registry-breg/src/lifecycle.rs @@ -91,6 +91,8 @@ pub(crate) struct ProposalTurnContext { pub(crate) submission_blocked: bool, pub(crate) review: ProposalReviewProgress, pub(crate) ask_open: bool, + /// An office message on the thread the party has not read. + pub(crate) message_unread: bool, pub(crate) application: ProposalApplicationProgress, } @@ -297,6 +299,7 @@ impl ProposalTurn { #[derive(Clone, Copy)] enum TurnCondition { Always, + MessageUnread, SubmittedParty, SubmittedOfficial, SubmittedNobody, @@ -306,14 +309,17 @@ impl TurnCondition { const fn description(self) -> &'static str { match self { Self::Always => "Always while the Proposal is in this state.", + Self::MessageUnread => { + "An office message on the thread is unread by the party. This changes the turn only, never the status." + } Self::SubmittedParty => { "The submission package is blocked; Review is pending or retrying with an open ask; Review ended without a usable approval; or, after approval or when Review is not required, application is not manual and is blocked without recovery retry." } Self::SubmittedOfficial => { - "The submission package is not blocked, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry." + "The submission package is not blocked, no office message is unread by the party, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry." } Self::SubmittedNobody => { - "The submission package is not blocked, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status." + "The submission package is not blocked, no office message is unread by the party, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status." } } } @@ -322,6 +328,7 @@ impl TurnCondition { fn matches(self, context: ProposalTurnContext) -> bool { match self { Self::Always => true, + Self::MessageUnread => context.message_unread, Self::SubmittedParty => submitted_turn(context) == ProposalTurn::Party, Self::SubmittedOfficial => submitted_turn(context) == ProposalTurn::Official, Self::SubmittedNobody => submitted_turn(context) == ProposalTurn::Nobody, @@ -371,6 +378,12 @@ const DRAFT_TURN_RULES: &[TurnRule] = &[TurnRule { condition: TurnCondition::Always, }]; const SUBMITTED_TURN_RULES: &[TurnRule] = &[ + // An unread office message is something for the party to read. The + // status follows the rules after it, so no command opens or closes. + TurnRule { + turn: ProposalTurn::Party, + condition: TurnCondition::MessageUnread, + }, // Package blocking precedes Review and application progress in the runtime. TurnRule { turn: ProposalTurn::Party, @@ -428,9 +441,16 @@ pub(crate) fn proposal_status_and_turn( .find(|rule| rule.condition.matches(context)) .expect("every Proposal state and context has a turn") .turn; + // The status follows whose move it is, which an unread message is not. + let moving = proposal_turn_rules(state) + .iter() + .filter(|rule| !matches!(rule.condition, TurnCondition::MessageUnread)) + .find(|rule| rule.condition.matches(context)) + .expect("every Proposal state and context has a turn") + .turn; let status = proposal_status_rules(state) .iter() - .find(|(_, condition)| condition.matches(context, turn)) + .find(|(_, condition)| condition.matches(context, moving)) .expect("every Proposal state and context has a status") .0; (status, turn) @@ -750,9 +770,11 @@ mod tests { R::Answered, R::Ended, ] { - for ask_open in [false, true] { + for (ask_open, message_unread) in + [(false, false), (true, false), (false, true), (true, true)] + { for application in [A::Manual, A::BlockedRetry, A::BlockedOther, A::Other] { - let expected = match state { + let mut expected = match state { S::Draft => (0, "draft", "party"), S::Cancelled => (1, "cancelled", "nobody"), S::Applied => (2, "applied", "nobody"), @@ -783,10 +805,16 @@ mod tests { }, }, }; + // An unread office message is the party's turn + // on any open submission, and never a status. + if state == S::Submitted && message_unread { + expected.2 = "party"; + } let context = ProposalTurnContext { submission_blocked: blocked, review, ask_open, + message_unread, application, }; let (status, turn) = proposal_status_and_turn(state, context); @@ -800,6 +828,7 @@ mod tests { assert_eq!( turn.as_str() == "party", matches!(status.as_str(), "draft" | "awaiting-party") + || (state == S::Submitted && message_unread) ); for terminal in ["applied", "rejected", "cancelled"] { assert_eq!( @@ -810,10 +839,12 @@ mod tests { if status.as_str() == "approved" { assert_eq!(review, R::Approved); } - if status.as_str() == "in-review" { + if status.as_str() == "in-review" && !message_unread { assert_eq!(turn.as_str(), "official"); } - if matches!(status.as_str(), "approved" | "processing") { + if matches!(status.as_str(), "approved" | "processing") + && !message_unread + { assert!(matches!(turn.as_str(), "official" | "nobody")); } } @@ -875,6 +906,7 @@ mod tests { submission_blocked, review, ask_open: false, + message_unread: false, application, }, ) diff --git a/crates/registry-breg/src/membership.rs b/crates/registry-breg/src/membership.rs index 0d6968a7a0..78bd91f00f 100644 --- a/crates/registry-breg/src/membership.rs +++ b/crates/registry-breg/src/membership.rs @@ -914,7 +914,8 @@ pub(crate) fn is_proposal_write(operation: ProposalOperation) -> bool { | ProposalOperation::Cancel | ProposalOperation::Apply | ProposalOperation::Rebase - | ProposalOperation::Retry => true, + | ProposalOperation::Retry + | ProposalOperation::Message => true, ProposalOperation::Get | ProposalOperation::List | ProposalOperation::GetReviewStatus diff --git a/crates/registry-breg/src/model.rs b/crates/registry-breg/src/model.rs index a200501c41..17cdefc343 100644 --- a/crates/registry-breg/src/model.rs +++ b/crates/registry-breg/src/model.rs @@ -525,6 +525,13 @@ impl CompiledActionExecution { matches!(self, Self::Proposal { .. }) } } +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct CompiledAdditionalForm { + pub maximum_count: u8, + pub inputs: Vec, +} + #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CompiledProposalPolicy { @@ -537,6 +544,8 @@ pub struct CompiledProposalPolicy { pub attachments: BTreeMap, #[serde(default, skip_serializing_if = "Option::is_none")] pub additions: Option, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub additional_forms: BTreeMap, /// Proposal files that applied effects reference from record slots, in /// effect order. #[serde(default, skip_serializing_if = "Vec::is_empty")] @@ -545,10 +554,20 @@ pub struct CompiledProposalPolicy { /// Where the Proposal's subject comes from. Bound once, at the first Submit. #[serde(default, skip_serializing_if = "Option::is_none")] pub subject: Option, + /// The Proposal's message thread, when the Action declares one. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub messages: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub system_apply_grant: Option, } +/// The bounds of one Proposal's message thread. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct CompiledProposalMessages { + pub maximum_count: u32, +} + /// Static package-approved scope for the built-in executor. This definition /// alone is inert; application intersects it with a frozen submission scope. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -655,6 +674,10 @@ pub struct CompiledProposalPermission { pub readable_inputs: BTreeSet, pub readable_attachments: BTreeSet, pub writable_attachments: BTreeSet, + #[serde(default, skip_serializing_if = "BTreeSet::is_empty")] + pub readable_forms: BTreeSet, + #[serde(default, skip_serializing_if = "BTreeSet::is_empty")] + pub writable_forms: BTreeSet, #[serde(default, skip_serializing_if = "Option::is_none")] pub writable_inputs: Option>, } diff --git a/crates/registry-breg/src/mutation.rs b/crates/registry-breg/src/mutation.rs index 312251733c..a8da49bc37 100644 --- a/crates/registry-breg/src/mutation.rs +++ b/crates/registry-breg/src/mutation.rs @@ -12,8 +12,8 @@ pub(crate) use membership::probe_action_memberships; use membership::RecordMembership; mod proposal; pub(crate) use proposal::{ - link_readable, proposal_http_method, proposal_operation_name, CheckedProposalTaskAuthority, - ProposalApplyPreflight, ProposalReadDisclosure, + link_readable, proposal_http_method, proposal_operation_name, thread_of, + CheckedProposalTaskAuthority, ProposalApplyPreflight, ProposalReadDisclosure, }; pub(crate) use proposal::{PUBLIC_REASON_REFERENCE, REVIEW_PROGRESS_REFERENCE}; mod timer; @@ -2568,12 +2568,19 @@ pub enum MutationError { /// first Submit. #[error("the Proposal's subject changed since it was first submitted")] ProposalSubjectChanged, + /// The Proposal's thread holds as many messages as its Action allows. + #[error("the Proposal's message thread is full")] + ProposalMessageLimitReached, /// A record attachment slot already holds a file. Record slots are /// write-once, so a second write is refused whatever its bytes are. #[error("the record attachment slot already holds a file")] AttachmentSlotWriteOnce, #[error("the supporting document slot has reached its file limit")] AttachmentLimitReached, + #[error("the Action does not declare this additional form")] + FormUndeclared, + #[error("the submission has reached the entry limit for this form")] + FormLimitReached, #[error("the required attachment slot is empty")] AttachmentRequired { slot: String }, #[error("the attachment is awaiting verification")] @@ -2670,9 +2677,12 @@ impl MutationError { | Self::ProposalUniqueConflict | Self::ProposalRejected | Self::ProposalSubjectChanged + | Self::ProposalMessageLimitReached | Self::AttachmentSlotWriteOnce | Self::AttachmentTooLarge | Self::AttachmentLimitReached + | Self::FormUndeclared + | Self::FormLimitReached | Self::AttachmentRequired { .. } | Self::AttachmentVerificationPending { .. } | Self::AttachmentVerificationRejected { .. } diff --git a/crates/registry-breg/src/mutation/proposal.rs b/crates/registry-breg/src/mutation/proposal.rs index 6d2f1a0e36..103aa259ef 100644 --- a/crates/registry-breg/src/mutation/proposal.rs +++ b/crates/registry-breg/src/mutation/proposal.rs @@ -4,8 +4,10 @@ use super::*; mod additions; mod asks; +mod forms; pub(crate) use asks::ProposalReadDisclosure; mod context_projection; +mod messages; use crate::api::proposals::ProposalMutationInput; use crate::lifecycle::{ proposal_status_and_turn, ProposalApplicationProgress, ProposalAvailability, @@ -19,6 +21,7 @@ use crate::postgres::{ begin_proposal_transaction, ActionClaimContext, ProposalAuthority, ProposalAuthorityOperation, ProposalTargetPhase, }; +use crate::proposal_messages::Side; use crate::proposal_prepare::{self, ProposalTargetSnapshot}; use crate::proposal_store::{self, ProposalDocument}; use crate::proposal_workflow::{ @@ -26,6 +29,8 @@ use crate::proposal_workflow::{ ProposalDigest, ProposalState, RecordId, RecordRevision, TrustedActorRef, TrustedTimestamp, TrustedTransitionContext, }; +use messages::hold_proposal_response; +pub(crate) use messages::thread_of; // Both branches are short-lived admission results with bounded protocol data. #[allow(clippy::large_enum_variant)] @@ -362,6 +367,7 @@ pub(crate) fn proposal_operation_name(operation: ProposalAuthorityOperation) -> ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetApplicationActor) => { "get-application-actor" } + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Message) => "message", } } @@ -477,6 +483,7 @@ impl MutationTransaction { from_state: "submitted", state: workflow.state().as_storage(), transition, + message_from: None, effect_digest: workflow .current_proposal() .map(|proposal| proposal.effect_digest().as_str()), @@ -807,6 +814,12 @@ impl MutationTransaction { answer.ask_id ); } + if input.message.is_some() { + route = format!( + "/v1/proposals/{}/messages", + input.proposal_id.ok_or(MutationError::InvalidRequest)? + ); + } let method = if let Some(attachment) = &input.attachment { route = format!( "/v1/proposals/{}/{}/{}", @@ -845,6 +858,23 @@ impl MutationTransaction { if !permission.readable_inputs.is_empty() { contract["readableInputs"]=json!(permission.readable_inputs); } + if input.message.is_some() && permission.operations.contains(&ProposalOperation::GetReviewContext) + && !permission.operations.contains(&ProposalOperation::Get) + { + contract["readableContextFields"] = json!(permission.readable_context_fields); + } + for (key, forms) in [ + ("readableForms", &permission.readable_forms), + ("writableForms", &permission.writable_forms), + ] { + if !forms.is_empty() { + contract[key] = json!(forms.iter().filter_map(|id| { + policy.additional_forms.get(id).map(|form| { + (id, crate::artifacts::additional_form_contract(&action.id, id, &form.inputs)) + }) + }).collect::>()); + } + } contract }); let mut canonical_request = json!({ @@ -856,9 +886,20 @@ impl MutationTransaction { "contentType":attachment.content_type,"sha256":attachment.sha256(), "byteSize":attachment.bytes.as_ref().map(Vec::len)})), }); + if let Some(form) = &input.form { + route = format!( + "/v1/proposals/{}/additional-forms/{}", + input.proposal_id.ok_or(MutationError::InvalidRequest)?, + form.id + ); + canonical_request["form"] = json!({"id":form.id,"input":form.values}); + } if let Some(answer) = &input.answer { canonical_request["answer"] = json!(answer); } + if let Some(message) = &input.message { + canonical_request["message"] = json!(message); + } let digest = Sha256::digest( canonicalize_json(&canonical_request).map_err(|_| MutationError::InvalidRequest)?, ) @@ -1301,8 +1342,14 @@ impl MutationTransaction { .await .map_err(|_| MutationError::Unavailable)?; let tx = guarded.transaction(); - let document = - proposal_store::load_document(tx, id, proposal_store::DocumentLock::None).await?; + // Message receipt checks and erasure serialize on the Proposal state + // row. Take that lock before looking up a possible Apply receipt. + let lock = if thread_of(action).is_some() { + proposal_store::DocumentLock::Share + } else { + proposal_store::DocumentLock::None + }; + let document = proposal_store::load_document(tx, id, lock).await?; self.check_proposal_document( tx, registry, @@ -1315,9 +1362,9 @@ impl MutationTransaction { .proposal_document_binding(tx, registry, input, Some(&document)) .await?; if let Some(stored) = lock_and_load(tx, &binding).await? { - let StoredResultMetadata::Proposal { .. } = stored.metadata else { - return Err(MutationError::Unavailable); - }; + let disclosure = self + .replay_proposal_disclosure(tx, registry, action, &document, input, &stored) + .await?; let entry = self.proposal_terminal( input, &binding, @@ -1325,7 +1372,8 @@ impl MutationTransaction { TerminalAuditOutcome::Replayed, 0, &[], - replayed_public_reason(stored.response.body())?, + disclosure, + None, None, )?; check_current_proposal_grant(input.authority)?; @@ -1536,9 +1584,6 @@ impl MutationTransaction { .proposal_document_binding(tx, registry, &input, existing.as_ref()) .await?; if let Some(stored) = lock_and_load(tx, &binding).await? { - let StoredResultMetadata::Proposal { .. } = stored.metadata else { - return Err(MutationError::Unavailable); - }; let document = if let Some(document) = existing { document } else { @@ -1556,6 +1601,9 @@ impl MutationTransaction { .await?; document }; + let disclosure = self + .replay_proposal_disclosure(tx, registry, action, &document, &input, &stored) + .await?; let entry = self.proposal_terminal( &input, &binding, @@ -1563,7 +1611,8 @@ impl MutationTransaction { TerminalAuditOutcome::Replayed, 0, &[], - replayed_public_reason(stored.response.body())?, + disclosure, + None, None, )?; check_current_proposal_grant(input.authority)?; @@ -1584,8 +1633,10 @@ impl MutationTransaction { let actor = self.proposal_actor_of(&input.authority.common)?; let mut result_count = 0u16; let mut changed_inputs = Vec::new(); + let mut added_form_entry = None; let mut terminal_error = None; let mut bound_subject = None; + let mut message_id = None; let (id, from_state, transition) = match input.operation { ProposalAuthorityOperation::Start => { if existing.is_some() { @@ -1626,8 +1677,15 @@ impl MutationTransaction { ProposalAuthorityOperation::Lifecycle(operation) => { let document = existing.as_ref().ok_or(MutationError::InvalidRequest)?; let id = document.proposal_id; - if input.expected_etag - != Some(self.proposal_etag(document, input.authority)?.as_str()) + // Only the automatic worker's Apply goes without an ETag: its + // claimed lease is verified under lock before any effect. + let leased_apply = input.expected_etag.is_none() + && input.executor_lease.is_some() + && input.authority.is_system() + && operation == ProposalOperation::Apply; + if !leased_apply + && input.expected_etag + != Some(self.proposal_etag(document, input.authority)?.as_str()) { return Err(MutationError::PreconditionFailed); } @@ -1651,9 +1709,13 @@ impl MutationTransaction { { return Err(MutationError::PreconditionFailed); } + // A message does not depend on the Action revision, so a + // package block leaves the thread open. if !matches!( operation, - ProposalOperation::Cancel | ProposalOperation::Rebase + ProposalOperation::Cancel + | ProposalOperation::Rebase + | ProposalOperation::Message ) { let compatible = if matches!( operation, @@ -1713,6 +1775,44 @@ impl MutationTransaction { proposal_store::save(tx, &action.id, id, previous, &workflow).await?; (workflow, "answered") } + ProposalOperation::Add if input.form.is_some() => { + ensure_additions_open(tx, document, &workflow).await?; + let form = input.form.as_ref().ok_or(MutationError::InvalidRequest)?; + added_form_entry = Some( + forms::insert(tx, action, document, input.authority, form, &actor) + .await?, + ); + let workflow = workflow + .record_addition(context) + .map_err(workflow_error)? + .into_workflow(); + proposal_store::save(tx, &action.id, id, previous, &workflow).await?; + (workflow, "added") + } + ProposalOperation::Message => { + let message = input + .message + .as_deref() + .ok_or(MutationError::InvalidRequest)?; + message_id = Some( + self.commit_message( + tx, + action, + document, + &workflow, + input.authority, + &actor, + message, + ) + .await?, + ); + let workflow = workflow + .record_message(context) + .map_err(workflow_error)? + .into_workflow(); + proposal_store::save(tx, &action.id, id, previous, &workflow).await?; + (workflow, "messaged") + } ProposalOperation::Add => { ensure_additions_open(tx, document, &workflow).await?; check_addition_count(tx, action, document).await?; @@ -2416,6 +2516,7 @@ impl MutationTransaction { &[], ProposalReadDisclosure::default(), None, + None, )?; if tokio::time::Instant::now() >= deadline { return Err(MutationError::Unavailable); @@ -2455,6 +2556,8 @@ impl MutationTransaction { from_state: &from_state, state: workflow.state().as_storage(), transition, + message_from: message_id + .map(|_| crate::proposal_messages::Side::of(input.authority.party).as_str()), effect_digest: workflow .current_proposal() .map(|proposal| proposal.effect_digest().as_str()), @@ -2472,9 +2575,31 @@ impl MutationTransaction { }, ) .await?; - let value = self - .proposal_public_value(tx, registry, &document, input.claims, input.authority) - .await?; + let review_receipt = if input.message.is_some() { + self.message_review_receipt(tx, registry, action, &document, &input) + .await? + } else { + None + }; + let (mut value, thread_side) = match review_receipt { + Some(review) => (review, Some(Side::of(input.authority.party))), + None => { + self.proposal_public_projection( + tx, + registry, + &document, + input.claims, + input.authority, + ) + .await? + } + }; + if input.message.is_some() && thread_side.is_none() { + return Err(MutationError::Unavailable); + } + if let Some((entry, _)) = &added_form_entry { + value["formEntryId"] = json!(entry); + } let mut headers = BTreeMap::from([ ( PermittedResponseHeader::ContentType, @@ -2491,14 +2616,15 @@ impl MutationTransaction { format!("/v1/proposals/{id}").into_bytes(), ); } - let held = HeldResponse::from_json( + let (held, disclosure) = hold_proposal_response( if input.operation == ProposalAuthorityOperation::Start { 201 } else { 200 }, - &value, + value, headers, + thread_side, )?; insert_result( tx, @@ -2508,6 +2634,7 @@ impl MutationTransaction { record_revision: document.header.workflow_revision, submission_version: document.header.submission_version, result_count, + thread_side, }, &held, ) @@ -2528,9 +2655,25 @@ impl MutationTransaction { TerminalAuditOutcome::Committed, result_count, &changed_inputs, - ProposalReadDisclosure::for_value(&value), + disclosure, bound_subject.as_deref(), + added_form_entry, )?; + // A write records which message and which side, never its text. + let entry = match message_id { + Some(message_id) => { + let mut record = entry.record().clone(); + record["messageId"] = json!(message_id); + record["messageFrom"] = + json!(crate::proposal_messages::Side::of(input.authority.party).as_str()); + AuditEntry::response( + crate::audit::AUDIT_SCHEMA, + input.correlation.request_id().to_string(), + record, + ) + } + None => entry, + }; if tokio::time::Instant::now() >= deadline { return Err(MutationError::Unavailable); } @@ -2615,6 +2758,7 @@ impl MutationTransaction { changed_inputs: &[String], disclosure: ProposalReadDisclosure, bound_subject: Option<&str>, + added_form_entry: Option<(Uuid, Vec)>, ) -> Result { let terminal = TerminalAudit { context: input.authority.common.audit_context().cloned(), @@ -2660,6 +2804,11 @@ impl MutationTransaction { { record["changedInputs"] = json!(changed_inputs); } + if let (Some((entry, ids)), Some(form)) = (added_form_entry, &input.form) { + record["additionalFormId"] = json!(form.id); + record["formEntryId"] = json!(entry); + record["formInputIds"] = json!(ids); + } if let Some(answer) = &input.answer { record["reviewAskId"] = json!(answer.ask_id); record["citedAdditionIds"] = json!(answer.body.additions); @@ -4055,6 +4204,20 @@ impl MutationTransaction { ) .await?, ); + if authority.operation + == ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetReviewContext) + && authority.receives_form_values + { + if let CompiledActionExecution::Proposal { proposal } = &action.execution { + if !proposal.additional_forms.is_empty() { + value["context"]["additionalForms"] = json!(proposal + .additional_forms + .keys() + .map(|id| (id, id)) + .collect::>()); + } + } + } // Answers are served to human reviewers of the current // binding only; see `receives_review_answers`. if authority.operation @@ -4073,6 +4236,21 @@ impl MutationTransaction { .intrinsic_asks(tx, registry, document, authority, frozen, &schema) .await?; } + // The thread sits beside the asks: its text for a context + // read that asked for it, its counts for the inbox batch. + if let Some((thread, text)) = &authority.review_messages { + if link_readable( + self.check_proposal_document(tx, registry, document, thread, false) + .await, + )? { + if let Some(messages) = self + .proposal_messages_member(tx, action, document, thread, *text) + .await? + { + value["context"]["messages"] = messages; + } + } + } } _ => return Err(MutationError::PreconditionFailed), } @@ -4087,6 +4265,19 @@ impl MutationTransaction { claims: Option<&crate::api::VerifiedRequestClaims>, current: &ProposalAuthority, ) -> Result { + self.proposal_public_projection(tx, registry, document, claims, current) + .await + .map(|(value, _)| value) + } + + async fn proposal_public_projection( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + document: &ProposalDocument, + claims: Option<&crate::api::VerifiedRequestClaims>, + current: &ProposalAuthority, + ) -> Result<(Value, Option), MutationError> { let action = proposal_action(registry, &document.action_id)?; let mut value = json!({"id":document.proposal_id,"actionId":document.action_id, "actionRevision":document.action_revision,"submissionVersion":document.header.submission_version, @@ -4146,7 +4337,16 @@ impl MutationTransaction { ); } let Some(claims) = claims else { - return Ok(value); + return Ok((value, None)); + }; + let thread_side = if let Some((messages, side)) = self + .public_messages(tx, registry, action, document, claims, current) + .await? + { + value["messages"] = messages; + Some(side) + } else { + None }; // A command response discloses the decision, the hand-off refusal, // the inputs and the attachments to a caller whose selected access @@ -4389,7 +4589,9 @@ impl MutationTransaction { document.header.state != "draft" && !document.header.current_proposal_erased } ProposalOperation::GetApplicationActor => false, - ProposalOperation::Add | ProposalOperation::Answer => false, + ProposalOperation::Add | ProposalOperation::Answer | ProposalOperation::Message => { + false + } ProposalOperation::List => false, }; if !available @@ -4562,12 +4764,16 @@ impl MutationTransaction { if !slots.is_empty() { value["attachments"] = Value::Object(slots); } + self.append_forms( + tx, registry, action, document, current, claims, permission, read, &mut value, + ) + .await?; self.append_additions( tx, registry, action, document, current, claims, permission, read, &mut value, ) .await?; } - Ok(value) + Ok((value, thread_side)) } } @@ -5015,6 +5221,7 @@ async fn current_turn_context( let mut context = proposal_turn_context(document.blocked_reason.is_some(), review, &application); context.ask_open = document.ask_open; + context.message_unread = document.party_message_unread; Ok((state, context)) } @@ -5057,6 +5264,7 @@ fn proposal_turn_context( submission_blocked: blocked, review, ask_open: false, + message_unread: false, application, } } @@ -5081,13 +5289,6 @@ pub(crate) fn link_readable(outcome: Result<(), MutationError>) -> Result Result { - let response: Value = serde_json::from_slice(body).map_err(|_| MutationError::Unavailable)?; - Ok(ProposalReadDisclosure::for_value(&response)) -} - /// Why the review authority refused one submission's hand-off for good, as /// the allowlisted code recorded when it refused. A hand-off still pending, /// accepted, retrying or withdrawn names no refusal, and neither does a @@ -5613,6 +5814,7 @@ mod disclosure_tests { input_targets: Vec::new(), blocked_reason: None, ask_open: false, + party_message_unread: false, created_at: "2026-10-14T00:00:00Z".to_owned(), header: crate::proposal_store::ProposalWorkflowHeader { owner_reference: "owner".to_owned(), diff --git a/crates/registry-breg/src/mutation/proposal/asks.rs b/crates/registry-breg/src/mutation/proposal/asks.rs index 43e0ff1af7..d37222a3a6 100644 --- a/crates/registry-breg/src/mutation/proposal/asks.rs +++ b/crates/registry-breg/src/mutation/proposal/asks.rs @@ -42,10 +42,10 @@ impl MutationTransaction { let wants: Vec = serde_json::from_value(row.get(2)).map_err(|_| MutationError::Unavailable)?; answer.body.validate(&wants).map_err(|field| { - MutationError::InvalidRequestAt(if field == "text" { - RequestLocation::proposal_answer_text() - } else { - RequestLocation::proposal_answer_additions() + MutationError::InvalidRequestAt(match field { + "text" => RequestLocation::proposal_answer_text(), + "formEntries" => RequestLocation::proposal_answer_form_entries(), + _ => RequestLocation::proposal_answer_additions(), }) })?; let asked: DateTime = row @@ -76,6 +76,32 @@ impl MutationTransaction { RequestLocation::proposal_answer_additions(), )); } + let requested_forms = wants + .iter() + .filter_map(|want| match want { + registry_review_client::ReviewAskWant::Form { form } => Some(form.as_str()), + _ => None, + }) + .collect::>(); + let cited = tx.query( + "SELECT f.form_id + FROM registry_internal.registry_proposal_form_entries f + WHERE f.action_id=$1 AND f.proposal_id=$2 AND f.submission_version=$3 + AND f.entry_id=ANY($4) AND f.detail_erased_at IS NULL + AND NOT EXISTS (SELECT 1 FROM registry_internal.registry_proposal_review_ask_form_entries c + WHERE c.action_id=f.action_id AND c.proposal_id=f.proposal_id + AND c.submission_version=f.submission_version AND c.entry_id=f.entry_id)", + &[&document.action_id,&document.proposal_id,&document.header.submission_version,&answer.body.form_entries], + ).await.map_err(map_database_error)?; + let cited_forms = cited + .iter() + .map(|row| row.get::<_, &str>(0)) + .collect::>(); + if cited.len() != answer.body.form_entries.len() || cited_forms != requested_forms { + return Err(MutationError::InvalidRequestAt( + RequestLocation::proposal_answer_form_entries(), + )); + } let key_material = canonicalize_json( &json!({"authority":authority,"requestId":request,"askId":answer.ask_id}), ) @@ -88,6 +114,15 @@ impl MutationTransaction { for addition in &answer.body.additions { tx.execute("INSERT INTO registry_internal.registry_proposal_review_ask_files(authority,review_request_id,ask_id,action_id,proposal_id,submission_version,addition_id) VALUES($1,$2,$3,$4,$5,$6,$7)",&[&authority,&request,&answer.ask_id,&document.action_id,&document.proposal_id,&document.header.submission_version,addition]).await.map_err(map_database_error)?; } + for entry in &answer.body.form_entries { + tx.execute( + "INSERT INTO registry_internal.registry_proposal_review_ask_form_entries + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version,entry_id) + VALUES($1,$2,$3,$4,$5,$6,$7)", + &[&authority,&request,&answer.ask_id,&document.action_id,&document.proposal_id, + &document.header.submission_version,entry], + ).await.map_err(map_database_error)?; + } // The mirror keeps the provider's state. The local answer row makes // the applicant document answered and ends the party's turn immediately. Ok(()) @@ -95,6 +130,53 @@ impl MutationTransaction { } impl MutationTransaction { + pub(super) async fn check_message_receipt_ask_binding( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + document: &ProposalDocument, + held: &Value, + ) -> Result<(), MutationError> { + let Some(asks) = held + .get("asks") + .and_then(Value::as_array) + .filter(|asks| !asks.is_empty()) + else { + return Ok(()); + }; + let workflow = + proposal_store::load(tx, &document.action_id, document.proposal_id, false).await?; + let frozen = workflow + .current_proposal() + .ok_or(MutationError::IdempotencyConflict)?; + let CompiledProposalReview::Required { authority, .. } = frozen.review_requirement() else { + return Err(MutationError::IdempotencyConflict); + }; + let binding = crate::review_store::load_task_context_binding( + tx, + registry, + &document.action_id, + document.proposal_id, + frozen, + ) + .await + .map_err(|error| match error { + MutationError::PreconditionFailed => MutationError::IdempotencyConflict, + other => other, + })?; + let rows = ask_rows(tx, document, Some((authority, binding.request_id))).await?; + if asks.iter().all(|ask| { + ask.get("id") + .and_then(Value::as_str) + .and_then(|id| Uuid::parse_str(id).ok()) + .is_some_and(|id| rows.iter().any(|row| row.get::<_, Uuid>(0) == id)) + }) { + Ok(()) + } else { + Err(MutationError::IdempotencyConflict) + } + } + #[allow(clippy::too_many_arguments)] pub(super) async fn append_public_asks( &self, @@ -203,6 +285,7 @@ impl MutationTransaction { pub(crate) struct ProposalReadDisclosure { pub(crate) field_set_reference: Option<&'static str>, pub(crate) asks: bool, + pub(crate) message_text_count: usize, pub(crate) ask_download: Option<(Uuid, Uuid)>, } const ASK_REFERENCE: &str = "proposal-review-ask"; @@ -218,6 +301,17 @@ impl ProposalReadDisclosure { .or_else(|| value.pointer("/context/asks")) .and_then(Value::as_array) .is_some_and(|asks| !asks.is_empty()), + message_text_count: value + .pointer("/messages/items") + .or_else(|| value.pointer("/context/messages/items")) + .or_else(|| value.get("count").and_then(|_| value.get("items"))) + .and_then(Value::as_array) + .map_or(0, |items| { + items + .iter() + .filter(|item| item.get("text").is_some()) + .count() + }), ask_download: None, } } @@ -248,6 +342,10 @@ impl ProposalReadDisclosure { record["fieldSetReference"] = json!(ASK_REFERENCE); } } + if self.message_text_count != 0 { + record["messageFieldSetReference"] = json!("proposal-messages"); + record["messageTextCount"] = json!(self.message_text_count); + } if let Some((ask, file)) = self.ask_download { record["reviewAskId"] = json!(ask); record["additionId"] = json!(file); @@ -265,7 +363,10 @@ async fn ask_rows( document: &ProposalDocument, binding: Option<(&str, Uuid)>, ) -> Result, MutationError> { - tx.query("SELECT a.ask_id,a.text,a.wants,a.asked_at_wire,a.due_at_wire,a.state,x.ask_id IS NOT NULL,x.text,x.answered_at,ARRAY(SELECT c.addition_id FROM registry_internal.registry_proposal_review_ask_files c WHERE c.authority=a.authority AND c.review_request_id=a.review_request_id AND c.ask_id=a.ask_id ORDER BY c.addition_id) FROM registry_internal.registry_proposal_review_asks a LEFT JOIN registry_internal.registry_proposal_review_ask_answers x USING(authority,review_request_id,ask_id) WHERE a.action_id=$1 AND a.proposal_id=$2 AND a.submission_version=$3 AND a.text IS NOT NULL AND a.detail_erased_at IS NULL AND ($4::text IS NULL OR (a.authority=$4 AND a.review_request_id=$5 AND EXISTS (SELECT 1 FROM registry_internal.registry_proposal_review_submissions s WHERE s.action_id=a.action_id AND s.proposal_id=a.proposal_id AND s.submission_version=a.submission_version AND s.authority=a.authority AND s.accepted_binding->>'requestId'=a.review_request_id::text AND NOT s.withdrawn AND s.state='accepted'))) ORDER BY a.asked_at DESC,a.ask_id DESC LIMIT $6",&[&document.action_id,&document.proposal_id,&document.header.submission_version,&binding.map(|b|b.0),&binding.map(|b|b.1),&(crate::contract::MAX_MIRRORED_REVIEW_ASKS as i64)]).await.map_err(map_database_error) + tx.query("SELECT a.ask_id,a.text,a.wants,a.asked_at_wire,a.due_at_wire,a.state,x.ask_id IS NOT NULL,x.text,x.answered_at,ARRAY(SELECT c.addition_id FROM registry_internal.registry_proposal_review_ask_files c WHERE c.authority=a.authority AND c.review_request_id=a.review_request_id AND c.ask_id=a.ask_id ORDER BY c.addition_id), + ARRAY(SELECT c.entry_id FROM registry_internal.registry_proposal_review_ask_form_entries c + WHERE c.authority=a.authority AND c.review_request_id=a.review_request_id AND c.ask_id=a.ask_id + ORDER BY c.entry_id) FROM registry_internal.registry_proposal_review_asks a LEFT JOIN registry_internal.registry_proposal_review_ask_answers x USING(authority,review_request_id,ask_id) WHERE a.action_id=$1 AND a.proposal_id=$2 AND a.submission_version=$3 AND a.text IS NOT NULL AND a.detail_erased_at IS NULL AND ($4::text IS NULL OR (a.authority=$4 AND a.review_request_id=$5 AND EXISTS (SELECT 1 FROM registry_internal.registry_proposal_review_submissions s WHERE s.action_id=a.action_id AND s.proposal_id=a.proposal_id AND s.submission_version=a.submission_version AND s.authority=a.authority AND s.accepted_binding->>'requestId'=a.review_request_id::text AND NOT s.withdrawn AND s.state='accepted'))) ORDER BY a.asked_at DESC,a.ask_id DESC LIMIT $6",&[&document.action_id,&document.proposal_id,&document.header.submission_version,&binding.map(|b|b.0),&binding.map(|b|b.1),&(crate::contract::MAX_MIRRORED_REVIEW_ASKS as i64)]).await.map_err(map_database_error) } fn ask_value(row: &tokio_postgres::Row) -> Value { @@ -282,6 +383,10 @@ fn ask_value(row: &tokio_postgres::Row) -> Value { if let Some(text) = row.get::<_, Option>(7) { answer["text"] = json!(text); } + let entries: Vec = row.get(10); + if !entries.is_empty() { + answer["formEntries"] = json!(entries); + } value["answer"] = answer; } value @@ -362,6 +467,22 @@ impl MutationTransaction { documents.push(descriptor); } answer.insert("documents".into(), json!(documents)); + let entries: Vec = row.get(10); + if !entries.is_empty() { + let action = proposal_action(registry, &document.action_id)?; + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Err(MutationError::Unavailable); + }; + let entries = super::forms::items( + tx, + document, + None, + Some(&entries), + &proposal.additional_forms, + ) + .await?; + answer.insert("formEntries".into(), json!(entries)); + } } asks.push(ask); } diff --git a/crates/registry-breg/src/mutation/proposal/context_projection.rs b/crates/registry-breg/src/mutation/proposal/context_projection.rs index e59c367511..260982e53f 100644 --- a/crates/registry-breg/src/mutation/proposal/context_projection.rs +++ b/crates/registry-breg/src/mutation/proposal/context_projection.rs @@ -107,6 +107,22 @@ pub(super) async fn fields( .chain(fields.filter(|(_, source)| !record_source(source))) { let resolved = match source { + ProposalContextValueSource::AdditionalForm { form } => { + if authority.operation + != ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetReviewContext) + || !authority.receives_form_values + { + return Err(MutationError::PreconditionFailed); + } + Value::Array( + super::forms::items(tx, document, Some(form), None, &proposal.additional_forms) + .await? + .into_iter() + .filter(|item| item.get("input").is_some()) + .collect(), + ) + } + ProposalContextValueSource::Additions { slot } => { let schema = document_contract .as_ref() diff --git a/crates/registry-breg/src/mutation/proposal/forms.rs b/crates/registry-breg/src/mutation/proposal/forms.rs new file mode 100644 index 0000000000..0a45a78cbd --- /dev/null +++ b/crates/registry-breg/src/mutation/proposal/forms.rs @@ -0,0 +1,394 @@ +// SPDX-License-Identifier: Apache-2.0 +use super::*; +use crate::{ + api::proposals::FormMutation, + contract::{ProposalContextValueSource, ProposalReviewContextSource, MAX_MIRRORED_REVIEW_ASKS}, + data::{validate_field_value, FieldValue}, + model::CompiledAdditionalForm, + problem_location::RequestLocation, +}; +use registry_platform_authcommon::FailedCheck; + +// Reserve the largest supported lifecycle projection outside the submitted +// inputs and form items. One ask can include 2,000 bytes each of question and +// answer text (up to 2x and 6x in JSON), eight wants, citations and an answer +// link. Each inline message can include 2,000 bytes of text (up to 2x in +// JSON), sender metadata and an ID. The remaining reserve covers Proposal +// state and links, decisions, application results, attachment and addition +// descriptors, and the form descriptors and Add result ID. +const LIFECYCLE_METADATA_BYTES: usize = 128 * 1024 + + MAX_MIRRORED_REVIEW_ASKS * 20 * 1024 + + crate::proposal_messages::DOCUMENT_ITEMS as usize * 5 * 1024; +// Covers the entry's UUID, timestamp, submission version, member names and +// separator, including a contract-changed marker for a small retained input. +const FORM_ENTRY_FRAMING_BYTES: usize = 128; + +fn digest(action: &str, id: &str, form: &CompiledAdditionalForm) -> String { + crate::artifacts::additional_form_contract(action, id, &form.inputs)["digest"] + .as_str() + .expect("an additional form contract has a digest") + .to_owned() +} + +pub(super) async fn insert( + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, + authority: &ProposalAuthority, + entry: &FormMutation<'_>, + actor: &str, +) -> Result<(Uuid, Vec), MutationError> { + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Err(MutationError::InvalidRequest); + }; + let form = proposal + .additional_forms + .get(entry.id) + .ok_or(MutationError::FormUndeclared)?; + if !authority + .permission(proposal) + .is_some_and(|grant| grant.writable_forms.contains(entry.id)) + { + return Err(MutationError::AuthorizationRefused( + FailedCheck::AccessProfile, + )); + } + for key in entry.values.keys() { + if !form.inputs.iter().any(|input| &input.api_name == key) { + let path = if crate::logical_names::valid_api_name(key) { + RequestLocation::action_input(key) + } else { + return Err(MutationError::InvalidRequest); + }; + return Err(MutationError::InvalidRequestAt(path)); + } + } + for input in &form.inputs { + let valid = entry + .values + .get(&input.api_name) + .map_or(!input.required, |value| { + validate_field_value(FieldValue::Json(value), &input.field_type) + }); + if !valid { + return Err(MutationError::InvalidRequestAt( + RequestLocation::action_input(&input.api_name), + )); + } + } + if entry.values.is_empty() { + return Err(MutationError::InvalidRequest); + } + let input_ids = form + .inputs + .iter() + .filter(|input| entry.values.contains_key(&input.api_name)) + .map(|input| input.id.clone()) + .collect(); + let count = count(tx, document, entry.id).await?; + if count >= i64::from(form.maximum_count) { + return Err(MutationError::FormLimitReached); + } + let id = Uuid::new_v4(); + tx.execute( + "INSERT INTO registry_internal.registry_proposal_form_entries + (action_id,proposal_id,submission_version,form_id,entry_id,input,contract_digest,added_by) + VALUES ($1,$2,$3,$4,$5,$6,$7,$8)", + &[&document.action_id,&document.proposal_id,&document.header.submission_version, + &entry.id,&id,&json!(entry.values),&digest(&action.id,entry.id,form),&actor], + ).await.map_err(map_database_error)?; + // Measure the tentative entry as PostgreSQL will return it. The caller + // holds the Proposal state lock and rolls back the insert on refusal. + let rows = tx + .query( + "SELECT form_id,input FROM registry_internal.registry_proposal_form_entries + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 + AND detail_erased_at IS NULL + LIMIT $4", + &[ + &document.action_id, + &document.proposal_id, + &document.header.submission_version, + // This many entries already exceed the budget from framing alone. + &((form_budget(0) / FORM_ENTRY_FRAMING_BYTES + 1) as i64), + ], + ) + .await + .map_err(map_database_error)?; + check_aggregate_budget( + public_input_bytes(document.input.as_ref())?, + proposal.review_context.as_ref(), + rows.into_iter().map(|row| (row.get(0), row.get(1))), + )?; + Ok((id, input_ids)) +} + +async fn count( + tx: &Transaction<'_>, + document: &ProposalDocument, + form: &str, +) -> Result { + Ok(tx + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_form_entries + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND form_id=$4", + &[ + &document.action_id, + &document.proposal_id, + &document.header.submission_version, + &form, + ], + ) + .await + .map_err(map_database_error)? + .get(0)) +} + +pub(super) async fn items( + tx: &Transaction<'_>, + document: &ProposalDocument, + form_id: Option<&str>, + cited: Option<&[Uuid]>, + forms: &BTreeMap, +) -> Result, MutationError> { + let rows = tx + .query( + "SELECT entry_id,form_id,input,contract_digest,added_at + FROM registry_internal.registry_proposal_form_entries + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 + AND detail_erased_at IS NULL AND ($4::text IS NULL OR form_id=$4) + AND ($5::uuid[] IS NULL OR entry_id=ANY($5)) + ORDER BY added_at,entry_id", + &[ + &document.action_id, + &document.proposal_id, + &document.header.submission_version, + &form_id, + &cited, + ], + ) + .await + .map_err(map_database_error)?; + Ok(rows + .into_iter() + .map(|row| { + let id: Uuid = row.get(0); + let form_id: String = row.get(1); + let retained_digest: String = row.get(3); + let mut item = json!({"id":id,"addedAt":row.get::<_,chrono::DateTime>(4)}); + if forms + .get(&form_id) + .is_some_and(|form| digest(&document.action_id, &form_id, form) == retained_digest) + { + item["input"] = row.get(2); + } else { + item["contractChanged"] = json!(true); + } + item + }) + .collect()) +} + +impl MutationTransaction { + #[allow(clippy::too_many_arguments)] + pub(super) async fn append_forms( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + current: &ProposalAuthority, + claims: &crate::api::VerifiedRequestClaims, + permission: &crate::model::CompiledProposalPermission, + read: Option<&ProposalAuthority>, + value: &mut Value, + ) -> Result<(), MutationError> { + let CompiledActionExecution::Proposal { proposal } = &action.execution else { + return Ok(()); + }; + if proposal.additional_forms.is_empty() { + return Ok(()); + } + let write = crate::api::proposals::authorize( + registry, + action, + claims, + Some(current.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Add), + Some(document.proposal_id), + self.party_selection(document, current), + ); + let write = match write { + Some(authority) if !permission.writable_forms.is_empty() => link_readable( + self.check_proposal_document(tx, registry, document, &authority, false) + .await, + )? + .then_some(authority), + _ => None, + }; + let refusal = if write.is_none() { + None + } else if document.header.state == "applied" { + Some(LinkRefusal::AlreadyApplied) + } else if document.header.state == "rejected" { + Some(LinkRefusal::Rejected) + } else if document.header.state != "submitted" || document.header.current_proposal_erased { + Some(LinkRefusal::WrongState) + } else if document.blocked_reason.as_deref() == Some("application-refused") { + Some(LinkRefusal::ReviseInput) + } else if document.blocked_reason.as_deref() == Some("application-rebase") { + Some(LinkRefusal::TargetChanged) + } else if document.blocked_reason.is_some() + || document.action_revision != action.definition_revision + { + Some(LinkRefusal::PackageChanged) + } else { + let workflow = + proposal_store::load(tx, &action.id, document.proposal_id, false).await?; + match workflow.current_proposal() { + Some(frozen) => match review_progress(tx, document, frozen).await? { + ProposalReviewProgress::Pending | ProposalReviewProgress::Retrying => None, + ProposalReviewProgress::Rejected => Some(LinkRefusal::ReviewRejected), + ProposalReviewProgress::ChangesRequested => Some(LinkRefusal::ChangesRequested), + _ => Some(LinkRefusal::ReviewEnded), + }, + None => Some(LinkRefusal::WrongState), + } + }; + let mut visible = Map::new(); + for (id, form) in &proposal.additional_forms { + let mut description = json!({"id":id,"maximumCount":form.maximum_count}); + if read.is_some() && permission.readable_forms.contains(id) { + let mut entries = + items(tx, document, Some(id), None, &proposal.additional_forms).await?; + for entry in &mut entries { + entry["submissionVersion"] = json!(document.header.submission_version); + } + description["items"] = json!(entries); + } + if let Some(write) = write + .as_ref() + .filter(|_| permission.writable_forms.contains(id)) + { + let refusal = match refusal { + None if count(tx, document, id).await? >= i64::from(form.maximum_count) => { + Some(LinkRefusal::LimitReached) + } + other => other, + }; + description["links"] = json!({"add":{ + "method":"POST","path":format!("/v1/proposals/{}/additional-forms/{id}",document.proposal_id), + "accessProfile":write.common.access_profile(),"operation":"add", + "ifMatch":self.proposal_etag(document,write)?, + "availability":ProposalAvailability::new(document.header.workflow_revision as u64,refusal) + }}); + } + if description.get("items").is_some() || description.get("links").is_some() { + visible.insert(id.clone(), description); + } + } + if !visible.is_empty() { + value["additionalForms"] = Value::Object(visible); + } + Ok(()) + } +} + +fn public_input_bytes(input: Option<&Map>) -> Result { + let Some(input) = input else { + return Ok(0); + }; + // Every input could be disclosed. Reserve the full valid API name width + // for a successor package that projects the retained inputs under new names. + let api_name_growth: usize = input + .keys() + .map(|id| 64_usize.saturating_sub(id.len())) + .sum(); + Ok(canonicalize_json(&Value::Object(input.clone())) + .map_err(|_| MutationError::InvalidRequest)? + .len() + + api_name_growth) +} + +fn form_budget(input_bytes: usize) -> usize { + (MAX_HELD_BODY_BYTES - LIFECYCLE_METADATA_BYTES).saturating_sub(input_bytes) +} + +fn check_aggregate_budget( + input_bytes: usize, + context: Option<&ProposalReviewContextSource>, + entries: impl Iterator, +) -> Result<(), MutationError> { + let mut review_copies = BTreeMap::new(); + if let Some(context) = context { + for source in context.fields.values() { + if let ProposalContextValueSource::AdditionalForm { form } = source { + *review_copies.entry(form.as_str()).or_insert(0) += 1; + } + } + } + let mut public_remaining = form_budget(input_bytes); + let mut review_remaining = public_remaining; + for (form, input) in entries { + let bytes = canonicalize_json(&input) + .map_err(|_| MutationError::InvalidRequest)? + .len() + + FORM_ENTRY_FRAMING_BYTES; + public_remaining = public_remaining + .checked_sub(bytes) + .ok_or(MutationError::FormLimitReached)?; + review_remaining = review_remaining + .checked_sub(bytes * review_copies.get(form.as_str()).copied().unwrap_or(0)) + .ok_or(MutationError::FormLimitReached)?; + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn aggregate_form_budget_counts_every_form_and_reserves_lifecycle_response_space() { + // A maximum-sized synthetic entry includes escaped and multibyte text. + let input = json!({"note": "\"é".repeat(4000)}); + assert!(canonicalize_json(&input).unwrap().len() < 16 * 1024); + let entries = |count| { + ["first", "second", "third", "fourth", "fifth", "sixth"] + .into_iter() + .cycle() + .take(count) + .map(|form| (form.to_owned(), input.clone())) + }; + + let frozen_input_bytes = 160 * 1024; + assert_eq!( + check_aggregate_budget(frozen_input_bytes, None, entries(106)), + Ok(()) + ); + assert_eq!( + check_aggregate_budget(frozen_input_bytes, None, entries(107)), + Err(MutationError::FormLimitReached) + ); + } + + #[test] + fn aggregate_form_budget_charges_each_review_context_mapping() { + let context = serde_json::from_value(json!({"id":"review","fields":{ + "first":{"type":"additional-form","form":"note"}, + "duplicate":{"type":"additional-form","form":"note"} + }})) + .unwrap(); + let input = json!({"note": "x".repeat(15_000)}); + let entries = || (0..32).map(|_| ("note".to_owned(), input.clone())); + let frozen_input_bytes = 1024 * 1024; + assert_eq!( + check_aggregate_budget(frozen_input_bytes, None, entries()), + Ok(()) + ); + assert_eq!( + check_aggregate_budget(frozen_input_bytes, Some(&context), entries()), + Err(MutationError::FormLimitReached) + ); + } +} diff --git a/crates/registry-breg/src/mutation/proposal/messages.rs b/crates/registry-breg/src/mutation/proposal/messages.rs new file mode 100644 index 0000000000..a671419d08 --- /dev/null +++ b/crates/registry-breg/src/mutation/proposal/messages.rs @@ -0,0 +1,1023 @@ +// SPDX-License-Identifier: Apache-2.0 +//! The Proposal message thread: the write inside the Proposal transaction and +//! the `messages` member each caller's Message admission may read. +use super::*; +use crate::contract::ProposalContextValueSource; +use crate::idempotency::StoredMutationResult; +use crate::proposal_messages::{self, NewMessage, Side}; + +impl MutationTransaction { + pub(super) async fn replay_proposal_disclosure( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + input: &ProposalMutationInput<'_>, + stored: &StoredMutationResult, + ) -> Result { + let StoredResultMetadata::Proposal { thread_side, .. } = &stored.metadata else { + return Err(MutationError::Unavailable); + }; + let held: Value = serde_json::from_slice(stored.response.body()) + .map_err(|_| MutationError::Unavailable)?; + let disclosure = ProposalReadDisclosure::for_value(&held); + if input.message.is_some() { + check_receipt_side(*thread_side, Side::of(input.authority.party))?; + self.authorize_message_receipt(tx, registry, action, document, input, &held) + .await?; + } else if let Some(path) = receipt_thread_items_path(&held) { + let claims = input.claims.ok_or(MutationError::IdempotencyConflict)?; + let authority = self + .public_message_authority(tx, registry, action, document, claims, input.authority) + .await? + .ok_or(MutationError::IdempotencyConflict)?; + check_receipt_side(*thread_side, Side::of(authority.party))?; + self.check_message_receipt_items(tx, document, &authority, &held, path) + .await?; + } + Ok(disclosure) + } + + /// The no-Get reviewer receives an exact review response from the same + /// transaction as the write. Replay rechecks current disclosure before + /// returning the held bytes. + pub(super) async fn message_review_receipt( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + input: &ProposalMutationInput<'_>, + ) -> Result, MutationError> { + let claims = input.claims.ok_or(MutationError::InvalidRequest)?; + let admit = |operation| { + crate::api::proposals::authorize( + registry, + action, + claims, + Some(input.authority.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(operation), + Some(document.proposal_id), + self.party_selection(document, input.authority), + ) + }; + if admit(ProposalOperation::Get).is_some() { + return Ok(None); + } + let Some(mut review) = admit(ProposalOperation::GetReviewContext) else { + return Ok(None); + }; + // Between review rounds, or after the Action changed, no review + // context is readable: the reviewer is answered with the thread. + if !review_context_readable(tx, action, document).await? { + return self + .proposal_messages_member(tx, action, document, input.authority, true) + .await; + } + review.receives_review_answers = false; + review.review_messages = Some((Box::new(input.authority.clone()), true)); + self.authorize_proposal_review_read(tx, registry, document, &review) + .await?; + let records = crate::api::proposals::review_record_authorities( + registry, + action, + claims, + &review, + ProposalOperation::GetReviewContext, + None, + ) + .ok_or(MutationError::PreconditionFailed)?; + self.proposal_review_value(tx, registry, document, &review, &records, None, None) + .await + .map(Some) + } + + async fn authorize_message_receipt( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + input: &ProposalMutationInput<'_>, + held: &Value, + ) -> Result<(), MutationError> { + let shape = message_receipt_shape(held).ok_or(MutationError::IdempotencyConflict)?; + // The exact key binding has already matched the selected profile. + // Reuse its current read path for the shape of the held response. + let current = if shape == MessageReceiptShape::Thread { + // Message authority still covers the thread when a review resumes. + self.proposal_messages_member(tx, action, document, input.authority, true) + .await? + } else { + match self + .message_review_receipt(tx, registry, action, document, input) + .await? + { + Some(review_or_thread) => Some(review_or_thread), + None if shape == MessageReceiptShape::Proposal => Some( + self.proposal_public_value( + tx, + registry, + document, + input.claims, + input.authority, + ) + .await?, + ), + None => None, + } + }; + let current = current.ok_or(MutationError::IdempotencyConflict)?; + let context_fields = match &action.execution { + CompiledActionExecution::Proposal { proposal } => proposal + .review_context + .as_ref() + .map(|context| &context.fields), + CompiledActionExecution::Immediate => None, + }; + if !message_receipt_projection_allows(held, ¤t, context_fields) { + return Err(MutationError::IdempotencyConflict); + } + if shape == MessageReceiptShape::Proposal { + self.check_message_receipt_ask_binding(tx, registry, document, held) + .await?; + } + let path = receipt_thread_items_path(held).ok_or(MutationError::IdempotencyConflict)?; + if !current.pointer(path).is_some_and(Value::is_array) { + return Err(MutationError::IdempotencyConflict); + } + self.check_message_receipt_items(tx, document, input.authority, held, path) + .await + } + + async fn check_message_receipt_items( + &self, + tx: &Transaction<'_>, + document: &ProposalDocument, + authority: &ProposalAuthority, + held: &Value, + path: &str, + ) -> Result<(), MutationError> { + if !authority.receives_review_answers { + return Err(MutationError::IdempotencyConflict); + } + let held_items = held + .pointer(path) + .and_then(Value::as_array) + .filter(|items| items.len() <= proposal_messages::DOCUMENT_ITEMS as usize) + .ok_or(MutationError::IdempotencyConflict)?; + if held_items.is_empty() { + return Ok(()); + } + // A held page can outlive the newest-items window. Check its exact + // items against the live thread, including items whose detail was erased. + let reader = self.proposal_actor_of(&authority.common)?; + if proposal_messages::receipt_items_match( + tx, + &document.action_id, + document.proposal_id, + held_items, + &reader, + ) + .await? + { + Ok(()) + } else { + Err(MutationError::IdempotencyConflict) + } + } + + /// Append one message under the Proposal's state row lock. The thread + /// opens at the first Submit and closes when the Proposal ends; a package + /// block leaves it open. + #[allow(clippy::too_many_arguments)] + pub(super) async fn commit_message( + &self, + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, + workflow: &crate::proposal_workflow::ProposalWorkflow, + authority: &ProposalAuthority, + actor: &str, + text: &str, + ) -> Result { + let thread = thread_of(action).ok_or(MutationError::PreconditionFailed)?; + if !matches!( + workflow.state(), + ProposalState::Draft | ProposalState::Submitted + ) || !proposal_messages::opened(tx, &document.action_id, document.proposal_id).await? + { + return Err(MutationError::PreconditionFailed); + } + proposal_messages::append( + tx, + NewMessage { + action_id: &document.action_id, + proposal_id: document.proposal_id, + submission_version: document.header.submission_version, + side: Side::of(authority.party), + party_role: authority.party, + sent_by: actor, + text, + maximum_count: thread.maximum_count, + }, + ) + .await + } + + /// Move the caller's side of the thread forward through `through`, under + /// the Proposal's state row lock. A move advances an open Proposal's + /// revision, so the turn and every ETag follow; it emits no event. + pub(crate) async fn record_messages_read( + &self, + tx: &Transaction<'_>, + document: &ProposalDocument, + authority: &ProposalAuthority, + through: Uuid, + ) -> Result { + let moved = proposal_messages::mark_read( + tx, + &document.action_id, + document.proposal_id, + Side::of(authority.party), + through, + ) + .await?; + if moved && matches!(document.header.state.as_str(), "draft" | "submitted") { + let workflow = + proposal_store::load(tx, &document.action_id, document.proposal_id, false).await?; + let previous = i64::try_from(workflow.workflow_revision().get()) + .map_err(|_| MutationError::Unavailable)?; + let actor = self.proposal_actor_of(&authority.common)?; + let workflow = workflow + .record_message(transition_context(&actor)?) + .map_err(workflow_error)? + .into_workflow(); + proposal_store::save( + tx, + &document.action_id, + document.proposal_id, + previous, + &workflow, + ) + .await?; + } + Ok(moved) + } + + /// The `messages` member for a caller admitted to `message` on this + /// Proposal. With `items` it carries the newest messages and the thread's + /// links; without, only the counts a list or an inbox shows. Only a person + /// acting for themselves reads the thread. + pub(crate) async fn proposal_messages_member( + &self, + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, + authority: &ProposalAuthority, + items: bool, + ) -> Result, MutationError> { + if thread_of(action).is_none() { + return Ok(None); + } + if !authority.receives_review_answers { + return Ok(None); + } + let side = Side::of(authority.party); + let summary = + proposal_messages::summary(tx, &document.action_id, document.proposal_id, side).await?; + let mut member = summary.to_json(); + if !items { + return Ok(Some(member)); + } + let reader = self.proposal_actor_of(&authority.common)?; + member["items"] = Value::Array( + proposal_messages::page( + tx, + &document.action_id, + document.proposal_id, + None, + proposal_messages::DOCUMENT_ITEMS, + &reader, + ) + .await? + .into_iter() + .map(|(_, item)| item) + .collect(), + ); + member["links"] = self + .proposal_message_links(tx, action, document, authority) + .await?; + Ok(Some(member)) + } + + /// The thread alone, for a caller answered without a Proposal document + /// while no review context is readable; `None` when one is. + pub(crate) async fn proposal_thread_view( + &self, + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, + authority: &ProposalAuthority, + ) -> Result, MutationError> { + if review_context_readable(tx, action, document).await? { + return Ok(None); + } + self.proposal_messages_member(tx, action, document, authority, true) + .await + } + + /// The thread's message, mark-read and list links for this caller, with + /// the write's condition and availability. + pub(crate) async fn proposal_message_links( + &self, + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, + authority: &ProposalAuthority, + ) -> Result { + let thread = thread_of(action).ok_or(MutationError::PreconditionFailed)?; + let side = Side::of(authority.party); + let refusal = match document.header.state.as_str() { + "applied" => Some(LinkRefusal::AlreadyApplied), + "rejected" => Some(LinkRefusal::ReviewRejected), + "cancelled" => Some(LinkRefusal::WrongState), + _ if !proposal_messages::opened(tx, &document.action_id, document.proposal_id) + .await? => + { + Some(LinkRefusal::WrongState) + } + _ if proposal_messages::count(tx, &document.action_id, document.proposal_id, side) + .await? + >= i64::from(thread.maximum_count) => + { + Some(LinkRefusal::LimitReached) + } + _ => None, + }; + let revision = document.header.workflow_revision as u64; + let path = format!("/v1/proposals/{}/messages", document.proposal_id); + let profile = authority.common.access_profile(); + Ok(json!({ + "message":{"method":"POST","path":path,"accessProfile":profile,"operation":"message", + "ifMatch":self.proposal_etag(document, authority)?, + "availability":ProposalAvailability::new(revision, refusal)}, + "markRead":{"method":"POST","path":format!("{path}/read"),"accessProfile":profile,"operation":"message", + "availability":ProposalAvailability::new(revision, None)}, + "list":{"method":"GET","path":path,"accessProfile":profile,"operation":"message", + "availability":ProposalAvailability::new(revision, None)}, + })) + } + + /// The `messages` member of a Proposal document, when the caller's + /// profile holds `message` on it. + pub(super) async fn public_messages( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + claims: &crate::api::VerifiedRequestClaims, + current: &ProposalAuthority, + ) -> Result, MutationError> { + let Some(authority) = self + .public_message_authority(tx, registry, action, document, claims, current) + .await? + else { + return Ok(None); + }; + let items = + current.operation != ProposalAuthorityOperation::Lifecycle(ProposalOperation::List); + let value = self + .proposal_messages_member(tx, action, document, &authority, items) + .await?; + Ok(value.map(|value| (value, Side::of(authority.party)))) + } + + async fn public_message_authority( + &self, + tx: &Transaction<'_>, + registry: &CompiledRegistry, + action: &CompiledAction, + document: &ProposalDocument, + claims: &crate::api::VerifiedRequestClaims, + current: &ProposalAuthority, + ) -> Result, MutationError> { + if thread_of(action).is_none() { + return Ok(None); + } + let Some(authority) = crate::api::proposals::authorize( + registry, + action, + claims, + Some(current.common.access_profile()), + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Message), + Some(document.proposal_id), + self.party_selection(document, current), + ) else { + return Ok(None); + }; + if !link_readable( + self.check_proposal_document(tx, registry, document, &authority, false) + .await, + )? { + return Ok(None); + } + Ok(Some(authority)) + } +} + +fn check_receipt_side(original: Option, current: Side) -> Result<(), MutationError> { + if original == Some(current) { + Ok(()) + } else { + Err(MutationError::IdempotencyConflict) + } +} + +pub(super) fn hold_proposal_response( + status: u16, + mut value: Value, + headers: BTreeMap>, + thread_side: Option, +) -> Result<(HeldResponse, ProposalReadDisclosure), MutationError> { + if let Some(path) = receipt_thread_items_path(&value) { + if thread_side.is_none() || !value.pointer(path).is_some_and(Value::is_array) { + return Err(MutationError::Unavailable); + } + } else if thread_side.is_some() { + return Err(MutationError::Unavailable); + } + let receipt = if message_receipt_shape(&value) == Some(MessageReceiptShape::Review) { + if let Some(full) = HeldResponse::from_json_if_fits(status, &value, headers.clone())? { + full + } else { + // A reviewer can fetch the review context independently. The + // write's existing thread-only outcome fits the receipt limit. + value = value + .pointer_mut("/context/messages") + .filter(|thread| message_receipt_shape(thread) == Some(MessageReceiptShape::Thread)) + .ok_or(MutationError::Unavailable)? + .take(); + HeldResponse::from_json(status, &value, headers)? + } + } else { + HeldResponse::from_json(status, &value, headers)? + }; + Ok((receipt, ProposalReadDisclosure::for_value(&value))) +} + +/// The thread an Action declares, if any. +pub(crate) fn thread_of(action: &CompiledAction) -> Option { + match &action.execution { + CompiledActionExecution::Proposal { proposal } => proposal.messages, + CompiledActionExecution::Immediate => None, + } +} + +/// Whether a review context can be read for this Proposal now: it has a +/// frozen submission, and the Action has not changed since it was written. +pub(crate) async fn review_context_readable( + tx: &Transaction<'_>, + action: &CompiledAction, + document: &ProposalDocument, +) -> Result { + if action.definition_revision != document.action_revision { + return Ok(false); + } + let workflow = + proposal_store::load(tx, &document.action_id, document.proposal_id, false).await?; + Ok(workflow.current_proposal().is_some()) +} + +#[derive(Clone, Copy, Eq, PartialEq)] +enum MessageReceiptShape { + Proposal, + Review, + Thread, +} + +fn receipt_thread_items_path(value: &Value) -> Option<&'static str> { + if value.get("messages").is_some() { + Some("/messages/items") + } else if value.pointer("/context/messages").is_some() { + Some("/context/messages/items") + } else if message_receipt_shape(value) == Some(MessageReceiptShape::Thread) { + Some("/items") + } else { + None + } +} + +fn message_receipt_shape(value: &Value) -> Option { + if let Some(context) = value.get("context") { + context.is_object().then_some(MessageReceiptShape::Review) + } else if value.get("id").is_some() && value.get("state").is_some() { + Some(MessageReceiptShape::Proposal) + } else if value.get("count").and_then(Value::as_u64).is_some() + && value.get("items").is_some_and(Value::is_array) + { + Some(MessageReceiptShape::Thread) + } else { + None + } +} + +fn message_receipt_projection_allows( + held: &Value, + current: &Value, + context_fields: Option<&BTreeMap>, +) -> bool { + let Some(shape) = message_receipt_shape(held) else { + return false; + }; + if message_receipt_shape(current) != Some(shape) { + return false; + } + match shape { + MessageReceiptShape::Review => { + // The context contract includes each mapped form's compiled + // digest. The review envelope binds the frozen submission and + // the live fields have already checked current disclosure. + held.as_object().is_some_and(|held| { + held.iter().all(|(name, value)| match name.as_str() { + "revision" | "reviewable" => true, + "context" => value.as_object().is_some_and(|context| { + context.iter().all(|(name, value)| { + let live = ¤t["context"][name]; + match name.as_str() { + "messages" => live.is_object(), + "additionalForms" => projection_contains(value, live), + "fields" => context_fields.is_some_and(|sources| { + review_fields_visible(value, live, sources) + }), + _ => current["context"] + .get(name) + .is_some_and(|live| held_json_matches(value, live)), + } + }) + }), + _ => current + .get(name) + .is_some_and(|live| held_json_matches(value, live)), + }) + }) + } + MessageReceiptShape::Proposal => held.as_object().is_some_and(|held| { + held.iter().all(|(name, value)| match name.as_str() { + // Lifecycle observations and link conditions are part of + // the original response. Using any link requires fresh admission. + "actionRevision" | "submissionVersion" | "revision" | "state" | "effectDigest" + | "applicationStatus" | "blockedReason" | "status" | "turn" | "links" => true, + "messages" => current[name].is_object(), + "asks" => current.get(name).is_some_and(|live| { + public_asks_visible(value, live) + && held + .get("submissionVersion") + .zip(current.get("submissionVersion")) + .is_some_and(|(version, live)| held_json_matches(version, live)) + }), + "additionalForms" | "attachments" | "additions" => current + .get(name) + .is_some_and(|live| public_member_contains(name, value, live)), + _ => current + .get(name) + .is_some_and(|live| held_json_matches(value, live)), + }) + }), + // The current Message grant covers the whole thread. The caller + // checks the items independently of the current page and counters. + MessageReceiptShape::Thread => true, + } +} + +fn public_asks_visible(held: &Value, current: &Value) -> bool { + let (Some(held), Some(current)) = (held.as_array(), current.as_array()) else { + return false; + }; + held.iter().all(|ask| { + let Some(id) = ask.get("id").and_then(Value::as_str) else { + return false; + }; + let mut matches = current + .iter() + .filter(|live| live.get("id").and_then(Value::as_str) == Some(id)); + let Some(live) = matches.next() else { + return false; + }; + matches.next().is_none() + && ask.as_object().is_some_and(|fields| { + fields.iter().all(|(name, value)| { + matches!(name.as_str(), "state" | "links") + || live + .get(name) + .is_some_and(|live| held_json_matches(value, live)) + }) + }) + }) +} + +fn public_member_contains(name: &str, held: &Value, current: &Value) -> bool { + let mut held = held.clone(); + let mut current = current.clone(); + for member in [&mut held, &mut current] { + if let Some(descriptors) = member.as_object_mut() { + for descriptor in descriptors.values_mut() { + match name { + "attachments" => { + remove_file_observations(descriptor); + if let Some(value) = descriptor.get_mut("value") { + remove_file_observations(value); + } + } + "additions" => { + remove_file_observations(descriptor); + if let Some(items) = + descriptor.get_mut("items").and_then(Value::as_array_mut) + { + for item in items { + remove_file_observations(item); + } + } + } + _ => remove_link_conditions(descriptor), + } + } + } + } + projection_contains(&held, ¤t) +} + +fn remove_file_observations(descriptor: &mut Value) { + // Metadata must still be visible. A held verification observation or + // promoted link grants no access to the file when used later. + if let Some(descriptor) = descriptor.as_object_mut() { + descriptor.remove("verificationStatus"); + descriptor.remove("links"); + } +} + +fn remove_link_conditions(descriptor: &mut Value) { + // Visit only API link containers. Authored input can also use these keys. + if let Some(links) = descriptor.get_mut("links").and_then(Value::as_object_mut) { + for link in links.values_mut().filter_map(Value::as_object_mut) { + link.remove("ifMatch"); + link.remove("availability"); + } + } +} + +fn review_fields_visible( + held: &Value, + current: &Value, + sources: &BTreeMap, +) -> bool { + held.as_object().is_some_and(|fields| { + fields.iter().all(|(name, value)| { + let Some(live) = current.get(name) else { + return false; + }; + match sources.get(name) { + Some( + ProposalContextValueSource::AdditionalForm { .. } + | ProposalContextValueSource::Additions { .. }, + ) => projection_contains(value, live), + Some(_) => held_json_matches(value, live), + None => false, + } + }) + }) +} + +fn projection_contains(held: &Value, current: &Value) -> bool { + match (held, current) { + (Value::Object(held), Value::Object(current)) => held.iter().all(|(key, value)| { + current + .get(key) + .is_some_and(|live| projection_contains(value, live)) + }), + (Value::Array(held), Value::Array(current)) => { + // A response can contain rows to which the live projection has + // since appended. Every retained row must still appear in full. + let mut current = current.iter(); + held.iter() + .all(|entry| current.any(|live| held_json_matches(entry, live))) + } + _ => held_json_matches(held, current), + } +} + +fn held_json_matches(held: &Value, current: &Value) -> bool { + match (held, current) { + (Value::Object(held), Value::Object(current)) => { + held.len() == current.len() + && held.iter().all(|(name, value)| { + current + .get(name) + .is_some_and(|live| held_json_matches(value, live)) + }) + } + (Value::Array(held), Value::Array(current)) => { + held.len() == current.len() + && held + .iter() + .zip(current) + .all(|(value, live)| held_json_matches(value, live)) + } + (Value::Number(_), Value::Number(_)) => { + // HeldResponse stores canonical JSON. Compare numbers in the same + // representation as the parsed receipt, including integral floats. + canonicalize_json(current) + .ok() + .and_then(|bytes| serde_json::from_slice::(&bytes).ok()) + .is_some_and(|normalized| normalized == *held) + } + _ => held == current, + } +} + +#[cfg(test)] +mod receipt_tests { + use super::*; + + #[test] + fn message_receipt_requires_the_retained_review_projection() { + let sources = BTreeMap::from([ + ( + "record".to_owned(), + ProposalContextValueSource::Record { + input: "record".to_owned(), + field: "name".to_owned(), + }, + ), + ( + "form".to_owned(), + ProposalContextValueSource::AdditionalForm { + form: "example".to_owned(), + }, + ), + ]); + let held = json!({ + "id":"proposal", "actionId":"review", "actionRevision":"a1", + "submissionVersion":1, "effectDigest":"effect-1", "revision":4, + "reviewable":true, "subject":{"id":"proposal","version":"1"}, + "context":{ + "reference":"round-1", "contract":{"schemaDigest":"contract-1"}, + "fields":{"record":"visible", "form":[{"id":"entry", "input":{"value":7}}]}, + "messages":{"count":1,"unread":1,"items":[]} + } + }); + let mut current = held.clone(); + current["revision"] = json!(5); + current["reviewable"] = json!(false); + current["context"]["messages"]["unread"] = json!(0); + current["context"]["fields"]["form"] + .as_array_mut() + .unwrap() + .push(json!({"id":"next-entry","input":{"value":8}})); + assert!(message_receipt_projection_allows( + &held, + ¤t, + Some(&sources) + )); + + assert!(!message_receipt_projection_allows( + &held, + &json!({"count":1,"unread":0,"items":[]}), + Some(&sources), + )); + for path in [ + "/submissionVersion", + "/subject/version", + "/effectDigest", + "/context/fields/form", + "/context/fields/record", + "/context/messages", + ] { + let mut narrower = current.clone(); + *narrower.pointer_mut(path).unwrap() = Value::Null; + assert!( + !message_receipt_projection_allows(&held, &narrower, Some(&sources)), + "{path}" + ); + } + let mut successor = current.clone(); + successor["context"]["contract"]["schemaDigest"] = json!("contract-2"); + assert!(!message_receipt_projection_allows( + &held, + &successor, + Some(&sources) + )); + current["context"]["fields"]["form"] = json!([]); + assert!(!message_receipt_projection_allows( + &held, + ¤t, + Some(&sources) + )); + } + + #[test] + fn message_receipt_rechecks_the_proposal_disclosure_and_keeps_thread_observations() { + let held = json!({ + "id": "proposal", + "state": "submitted", + "revision": 4, + "input": {"value": 7}, + "messages": {"count": 1, "unread": 1, "items": []} + }); + let mut current = held.clone(); + current["revision"] = json!(5); + current["messages"]["unread"] = json!(0); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + current.as_object_mut().unwrap().remove("input"); + assert!(!message_receipt_projection_allows(&held, ¤t, None)); + assert!(message_receipt_projection_allows( + &held["messages"], + ¤t["messages"], + None, + )); + } + + #[test] + fn message_receipt_accepts_new_link_conditions_with_the_same_projection() { + let link = |condition, revision| { + json!({ + "method": "POST", "operation": "add", "path": "/forms/example", + "accessProfile": "owner", "ifMatch": condition, + "availability": ProposalAvailability::new(revision, None) + }) + }; + let held = json!({ + "id": "proposal", + "state": "submitted", + "additionalForms": { + "example": { + "items": [{"id": "entry", "input": {"links": {"ifMatch": "data"}}}], + "links": {"add": link("old", 4)}, + } + }, + "messages": {"items": []} + }); + let mut current = held.clone(); + current["additionalForms"]["example"]["links"]["add"] = link("current", 5); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + + let mut changed_path = current.clone(); + changed_path["additionalForms"]["example"]["links"]["add"]["path"] = json!("/forms/other"); + assert!(!message_receipt_projection_allows( + &held, + &changed_path, + None + )); + current["additionalForms"]["example"]["items"][0]["input"]["links"]["ifMatch"] = + json!("different data"); + assert!(!message_receipt_projection_allows(&held, ¤t, None)); + } + + #[test] + fn message_replay_requires_proof_of_the_original_thread_side() { + for side in [Side::Party, Side::Official] { + assert!(check_receipt_side(Some(side), side).is_ok()); + assert!(check_receipt_side(None, side).is_err()); + } + assert!(check_receipt_side(Some(Side::Official), Side::Party).is_err()); + assert!(check_receipt_side(Some(Side::Party), Side::Official).is_err()); + + let thread = json!({"count": 0, "unread": 0, "items": []}); + for value in [ + json!({"id": "proposal", "state": "draft", "messages": thread}), + json!({"context": {"messages": thread}}), + thread, + ] { + assert!(hold_proposal_response(200, value.clone(), BTreeMap::new(), None).is_err()); + assert!(hold_proposal_response(200, value, BTreeMap::new(), Some(Side::Party)).is_ok()); + } + } + + #[test] + fn message_receipt_matches_ask_identity_and_retained_values_through_answer_progress() { + let question = json!({ + "id": "ask-one", "text": "Explain the date", "wants": ["answer"], + "askedAt": "2026-01-05T00:00:00Z", "state": "open", "links": {} + }); + let mut held = json!({ + "id": "proposal", "state": "submitted", "submissionVersion": 1, + "asks": [question], "messages": {"items": []} + }); + let mut current = held.clone(); + let questions = current["asks"].as_array_mut().unwrap(); + questions[0]["state"] = json!("answered"); + questions[0]["answer"] = json!({"text": "Observed date", "additions": ["file-one"], + "formEntries": ["entry-one"], "answeredAt": "2026-01-05T00:01:00Z"}); + questions[0].as_object_mut().unwrap().remove("links"); + questions.insert(0, json!({"id": "ask-two", "text": "Confirm the address"})); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + + let mut next_submission = current.clone(); + next_submission["submissionVersion"] = json!(2); + assert!(!message_receipt_projection_allows( + &held, + &next_submission, + None + )); + + let mut duplicate = current.clone(); + duplicate["asks"] + .as_array_mut() + .unwrap() + .push(current["asks"][1].clone()); + assert!(!message_receipt_projection_allows(&held, &duplicate, None)); + + held["asks"][0]["answer"] = current["asks"][1]["answer"].clone(); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + for (path, replacement) in [ + ("/asks/1/id", json!("ask-three")), + ("/asks/1/text", json!("Explain the time")), + ("/asks/1/wants", json!(["document"])), + ("/asks/1/answer/text", json!("Different date")), + ("/asks/1/answer/additions", json!(["file-two"])), + ("/asks/1/answer/formEntries", json!(["entry-two"])), + ("/asks", json!([])), + ] { + let mut narrower = current.clone(); + *narrower.pointer_mut(path).unwrap() = replacement; + assert!( + !message_receipt_projection_allows(&held, &narrower, None), + "{path}" + ); + } + } + + #[test] + fn message_receipt_retains_file_observations_only_while_metadata_is_visible() { + let held = json!({ + "id": "proposal", "state": "submitted", + "attachments": {"proof": {"id": "proof", "value": { + "submissionVersion": 1, "sha256": "digest", "verificationStatus": "pending" + }, "links": {"upload": {"method": "PATCH"}}}}, + "additions": {"support": {"id": "support", "items": [{ + "id": "file-one", "submissionVersion": 1, "sha256": "another-digest", + "verificationStatus": "pending", "links": {} + }], "links": {}}}, + "messages": {"items": []} + }); + let mut current = held.clone(); + current["attachments"]["proof"]["value"]["verificationStatus"] = json!("verified"); + current["attachments"]["proof"]["links"] = json!({"download": {"method": "GET"}}); + current["additions"]["support"]["items"][0]["verificationStatus"] = json!("verified"); + current["additions"]["support"]["items"][0]["links"] = + json!({"download": {"method": "GET"}}); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + + let mut erased = current.clone(); + erased["attachments"]["proof"] + .as_object_mut() + .unwrap() + .remove("value"); + assert!(!message_receipt_projection_allows(&held, &erased, None)); + let mut replaced = current.clone(); + replaced["additions"]["support"]["items"][0]["sha256"] = json!("replacement-digest"); + assert!(!message_receipt_projection_allows(&held, &replaced, None)); + current["additions"]["support"]["items"] = json!([]); + assert!(!message_receipt_projection_allows(&held, ¤t, None)); + } + + #[test] + fn reviewer_message_receipt_bounds_the_complete_canonical_envelope() { + let thread = json!({"count": 1, "unread": 0, "items": [], "links": {}}); + let mut review = json!({"context": { + "fields": {"summary": "Résumé", "note": "\\n"}, + "messages": thread, + }}); + let framing = canonicalize_json(&review).unwrap().len(); + let remaining = crate::idempotency::MAX_HELD_BODY_BYTES - framing; + review["context"]["fields"]["note"] = json!(format!("\\n{}", "a".repeat(remaining))); + let (held, _) = + hold_proposal_response(200, review.clone(), BTreeMap::new(), Some(Side::Official)) + .unwrap(); + assert_eq!(held.body().len(), crate::idempotency::MAX_HELD_BODY_BYTES); + assert_eq!(held.body(), canonicalize_json(&review).unwrap()); + + review["context"]["fields"]["note"] = json!(format!("\\n{}", "a".repeat(remaining + 1))); + let (held, _) = + hold_proposal_response(200, review, BTreeMap::new(), Some(Side::Official)).unwrap(); + assert_eq!(held.body(), canonicalize_json(&thread).unwrap()); + } + + #[test] + fn message_receipt_compares_numbers_as_they_appear_in_held_json() { + let current = json!({ + "id": "proposal", "state": "submitted", + "input": {"value": 7.0}, "messages": {"items": []} + }); + let held = HeldResponse::from_json(200, ¤t, BTreeMap::new()).unwrap(); + let held: Value = serde_json::from_slice(held.body()).unwrap(); + assert!(held["input"]["value"].is_u64()); + assert!(message_receipt_projection_allows(&held, ¤t, None)); + + let mut changed = current; + changed["input"]["value"] = json!(7.5); + assert!(!message_receipt_projection_allows(&held, &changed, None)); + } +} diff --git a/crates/registry-breg/src/package.rs b/crates/registry-breg/src/package.rs index aee51a5e7e..232c9a9a16 100644 --- a/crates/registry-breg/src/package.rs +++ b/crates/registry-breg/src/package.rs @@ -29,10 +29,14 @@ use sha2::{Digest, Sha256}; use thiserror::Error; use crate::artifacts::REGISTRY_METADATA_ARTIFACT_PATH; +#[cfg(feature = "tooling")] +use crate::compiler::module_source_digest; use crate::compiler::{compile_project_with_assets, CompileProfile}; use crate::contract::{ - parse_module_yaml, parse_project_yaml, parse_sealed_module_yaml, parse_sealed_project_yaml, - FieldTypeSource, ModuleAssetSource, RegistryModule, RegistryProject, + parse_module_yaml, parse_predecessor_module_yaml, parse_predecessor_project_yaml, + parse_project_yaml, parse_sealed_module_yaml, parse_sealed_project_yaml, FieldTypeSource, + MembershipBoundarySource, ModuleAssetSource, PredecessorMemberships, RegistryModule, + RegistryProject, }; use crate::derived_sql::MAX_DERIVED_SQL_BYTES; use crate::generated_ddl::{ @@ -4350,11 +4354,10 @@ pub fn load_predecessor_package_with_verified_envelope( } /// Verify a predecessor package exactly as [`load_predecessor_package`] does, -/// then compile its packaged sources with the current compiler so a successor -/// can be rehearsed over the predecessor's schema. The historical generated -/// artifacts are still not compared: the rehearsal instead holds the installed -/// schema to the packaged predecessor fingerprint, and refuses when the -/// current compiler cannot reproduce it. +/// then prepare its schema for successor rehearsal. Historical membership +/// packages use the archived governed model and inventories. The rehearsal +/// compares the installed baseline fingerprint with the archived fingerprint +/// and requires the final catalog to match the candidate fingerprint. #[cfg(feature = "tooling")] pub fn load_predecessor_rehearsal_baseline( root: &Path, @@ -4371,8 +4374,8 @@ pub fn load_predecessor_rehearsal_baseline_with_verified_envelope( shared: &SharedVerifiedPackage, ) -> Result<(VerifiedPredecessorPackage, CompiledRegistry)> { let (package, loaded) = load_predecessor_closure(root, context, shared)?; - let (registry, _) = - compile_package_sources(&package.manifest, &loaded, PackageSourceMode::Predecessor)?; + let registry = + project_rehearsal_baseline(&package.manifest, &loaded, package.migration_baseline())?; Ok((package, registry)) } @@ -4385,7 +4388,7 @@ fn load_predecessor_closure( let (manifest, loaded) = load_verified_closure(root, shared, production)?; validate_engine_features(&manifest)?; validate_source_inventory(&manifest)?; - parse_package_sources(&manifest, &loaded, PackageSourceMode::Predecessor)?; + let sources = parse_package_sources(&manifest, &loaded, PackageSourceMode::Predecessor)?; let governed = package_predecessor_governed_model(&manifest, &loaded)?; validate_predecessor_registry_bindings(&manifest, &governed)?; let package_digest = shared.digest().to_owned(); @@ -4403,6 +4406,9 @@ fn load_predecessor_closure( generated_ddl_sha256, ); validate_migration_baseline(&migration_baseline)?; + if sources.has_historical_membership() { + validate_predecessor_membership_inventory(&sources, &migration_baseline)?; + } let history_schema_descriptor = governed.history_schema_descriptor(&package_digest)?; Ok(( @@ -4869,17 +4875,19 @@ fn load_closure( /// The refusal for stored sources that do not parse. A package closure holds /// sources an earlier release may have written, so the refusal carries the /// reader's diagnostics for the operator to act on. No release seals a file -/// that mixes Action Plan spellings or doubles an Action Plan or Proposal -/// grant key, so such a file is a modified package. +/// that mixes Action Plan or membership spellings on a grant or doubles an +/// Action Plan, Proposal grant or membership key. fn source_refusal(failure: &CompileFailure) -> PackageError { const SHOWN: usize = 3; let diagnostics = failure.diagnostics(); if diagnostics.iter().any(|diagnostic| { diagnostic.code == "breg.action-plan.mixed-spelling" + || diagnostic.code == "breg.membership.mixed-spelling" || (diagnostic.code == "yaml.duplicate-key" && (diagnostic.path.ends_with(".functions") || diagnostic.path.ends_with(".function") - || diagnostic.path.ends_with(".ownership"))) + || diagnostic.path.ends_with(".ownership") + || diagnostic.path.ends_with(".membershipBoundaries"))) }) { return PackageError::Integrity; } @@ -4909,20 +4917,51 @@ impl PackageSourceMode { } Ok(source) } + + fn project(self, bytes: &[u8]) -> Result<(RegistryProject, PredecessorMemberships)> { + match self { + Self::Strict => Ok(( + self.accept(parse_sealed_project_yaml(bytes))?, + PredecessorMemberships::default(), + )), + Self::Predecessor => { + parse_predecessor_project_yaml(bytes).map_err(|failure| source_refusal(&failure)) + } + } + } + + fn module(self, bytes: &[u8]) -> Result<(RegistryModule, PredecessorMemberships)> { + match self { + Self::Strict => Ok(( + self.accept(parse_sealed_module_yaml(bytes))?, + PredecessorMemberships::default(), + )), + Self::Predecessor => { + parse_predecessor_module_yaml(bytes).map_err(|failure| source_refusal(&failure)) + } + } + } +} + +struct ParsedPackageSources { + project: RegistryProject, + modules: Vec, + project_memberships: PredecessorMemberships, + module_memberships: Vec, } /// Parse verified source bytes. Only predecessor planning and rehearsal can -/// use translated historical Action Plan or Proposal grant keys. +/// use translated historical Action Plan, Proposal grant or membership keys. fn parse_package_sources( manifest: &PackageManifest, loaded: &BTreeMap>, mode: PackageSourceMode, -) -> Result<(RegistryProject, Vec)> { +) -> Result { let project_bytes = loaded .get(&manifest.sources.project) .ok_or(PackageError::Derivation)?; - let project = mode.accept(parse_sealed_project_yaml(project_bytes))?; - let modules = manifest + let (project, project_memberships) = mode.project(project_bytes)?; + let (modules, module_memberships) = manifest .sources .modules .iter() @@ -4930,19 +4969,416 @@ fn parse_package_sources( loaded .get(&source.path) .ok_or(PackageError::Derivation) - .and_then(|bytes| mode.accept(parse_sealed_module_yaml(bytes))) + .and_then(|bytes| mode.module(bytes)) }) - .collect::>>()?; - Ok((project, modules)) + .collect::>>()? + .into_iter() + .unzip(); + let sources = ParsedPackageSources { + project, + modules, + project_memberships, + module_memberships, + }; + if sources.has_historical_membership() + && sources + .memberships() + .any(|source| source.current_site.is_some()) + { + return Err(PackageError::Integrity); + } + Ok(sources) } -/// Compile the sources of one verified package closure. The caller -/// decides whether generated artifacts must also match byte for byte. -fn compile_package_sources( +impl ParsedPackageSources { + fn memberships(&self) -> impl Iterator { + std::iter::once(&self.project_memberships).chain(&self.module_memberships) + } + + fn has_historical_membership(&self) -> bool { + self.memberships() + .any(|source| !source.historical.is_empty()) + } +} + +#[cfg(feature = "tooling")] +fn project_rehearsal_baseline( + manifest: &PackageManifest, + loaded: &BTreeMap>, + baseline: &CompiledRegistryMigrationBaseline, +) -> Result { + let (sources, assets) = + capture_compiler_inputs(manifest, loaded, PackageSourceMode::Predecessor)?; + if !sources.has_historical_membership() { + return compile_captured_package_sources(manifest, &sources, &assets) + .map(|(registry, _)| registry); + } + + validate_predecessor_module_locks(&sources, &assets)?; + project_archived_registry(manifest, loaded, &sources.project, baseline) +} + +fn validate_predecessor_membership_inventory( + sources: &ParsedPackageSources, + baseline: &CompiledRegistryMigrationBaseline, +) -> Result<()> { + if sources.project.project.version != baseline.registry_version + || baseline + .entities + .values() + .any(|entity| entity.membership.is_some()) + || baseline.actions.actions.iter().any(|action| { + let target_membership = action + .permissions + .iter() + .flat_map(|grant| &grant.targets) + .any(|target| !target.membership_boundaries.is_empty()); + let proposal_targets = match &action.execution { + crate::model::CompiledActionExecution::Proposal { proposal } => { + proposal.permissions.as_slice() + } + crate::model::CompiledActionExecution::Immediate => &[], + }; + target_membership + || proposal_targets + .iter() + .flat_map(|grant| &grant.targets) + .any(|target| !target.membership_boundaries.is_empty()) + }) + { + return Err(PackageError::Derivation); + } + + // Historical read paths never inherited the direct target's membership. + // Unused declarations on other Records cannot disclose a protected row. + let granted_read_path_targets = baseline + .entities + .values() + .flat_map(|entity| { + entity + .access_profiles + .values() + .flat_map(|profile| &profile.read_paths) + .filter_map(|grant| entity.read_paths.get(&grant.path)) + }) + .flat_map(|path| [path.through.as_str(), path.to.as_str()]) + .collect::>(); + + let project = serde_json::to_value(&sources.project).map_err(|_| PackageError::Derivation)?; + let mut seen = BTreeSet::new(); + let mut compare_grants = |source: &Value, memberships: &PredecessorMemberships| { + for (site, boundaries) in &memberships.historical { + if boundaries.is_empty() { + continue; + } + let grant = source + .pointer( + site.strip_suffix("/membershipBoundaries") + .ok_or(PackageError::Derivation)?, + ) + .ok_or(PackageError::Derivation)?; + let parts = site.split('/').collect::>(); + let (id, profile_id) = match parts.as_slice() { + ["", "accessProfiles", profile, "permissions", "records", _, _] => { + (required_str(grant, "recordType")?, *profile) + } + ["", "recordTypes" | "extendRecordTypes", id, "accessProfiles", profile, _] => { + (*id, *profile) + } + _ => return Err(PackageError::Derivation), + }; + let entity = baseline.entities.get(id).ok_or(PackageError::Derivation)?; + let profile = entity + .access_profiles + .get(profile_id) + .ok_or(PackageError::Derivation)?; + let physical = entity + .membership_boundaries + .get(profile_id) + .ok_or(PackageError::Derivation)?; + let rows = grant + .get("rowBoundaries") + .and_then(Value::as_array) + .ok_or(PackageError::Derivation)?; + let claim_count = rows + .len() + .checked_sub(boundaries.len()) + .ok_or(PackageError::Derivation)?; + let claims = &rows[..claim_count]; + let archived_claims = serde_json::to_value(&profile.row_boundaries) + .map_err(|_| PackageError::Derivation)?; + let archived_operations = + serde_json::to_value(&profile.operations).map_err(|_| PackageError::Derivation)?; + let expected_memberships = boundaries + .iter() + .cloned() + .map(MembershipBoundarySource::Expanded); + if entity.id != id + || profile.id != profile_id + || granted_read_path_targets.contains(id) + || !seen.insert((id.to_owned(), profile_id.to_owned())) + || !profile.writable_fields.is_empty() + || profile.spatial_queries.is_some() + || grant.get("operations") != Some(&archived_operations) + || archived_claims.as_array().map(Vec::as_slice) != Some(claims) + || !profile + .membership_boundaries + .iter() + .cloned() + .eq(expected_memberships) + || physical.len() != boundaries.len() + { + return Err(PackageError::Derivation); + } + for (logical, physical) in boundaries.iter().zip(physical) { + verify_predecessor_membership_columns( + baseline, entity, profile, logical, physical, + )?; + } + } + Ok(()) + }; + compare_grants(&project, &sources.project_memberships)?; + for (module, memberships) in sources.modules.iter().zip(&sources.module_memberships) { + let module = serde_json::to_value(module).map_err(|_| PackageError::Derivation)?; + compare_grants(&module, memberships)?; + } + let logical_count = baseline + .entities + .values() + .flat_map(|entity| entity.access_profiles.values()) + .filter(|profile| !profile.membership_boundaries.is_empty()) + .count(); + let physical_count: usize = baseline + .entities + .values() + .map(|entity| entity.membership_boundaries.len()) + .sum(); + // Each matched grant already has equal, ordered logical and physical + // tuples. Both inventories must contain exactly those matched grants. + if seen.len() != logical_count || seen.len() != physical_count { + return Err(PackageError::Derivation); + } + Ok(()) +} + +fn verify_predecessor_membership_columns( + baseline: &CompiledRegistryMigrationBaseline, + protected: &CompiledEntity, + profile: &crate::contract::AccessProfileSource, + logical: &crate::contract::ExpandedMembershipBoundarySource, + physical: &crate::model::CompiledMembershipBoundary, +) -> Result<()> { + let source = baseline + .entities + .get(&logical.membership_entity) + .ok_or(PackageError::Derivation)?; + let names = baseline + .physical_names + .entities + .get(&source.id) + .ok_or(PackageError::Derivation)?; + let field = |id: &str| { + source + .fields + .get(id) + .filter(|field| field.id == id) + .ok_or(PackageError::Derivation) + }; + let root = protected + .fields + .get(&logical.field) + .ok_or(PackageError::Derivation)?; + let protected_names = baseline + .physical_names + .entities + .get(&protected.id) + .ok_or(PackageError::Derivation)?; + let key = field(&logical.membership_key_field)?; + let principal = field(&logical.principal_field)?; + let active = field(&logical.active_field)?; + if physical.field != logical.field + || root.id != logical.field + || protected_names.fields.get(&root.id) != Some(&root.physical_name) + || source.id != logical.membership_entity + || physical.membership_entity != source.id + || physical.membership_table != names.table + || physical.membership_table != source.physical_table + || !source.membership_boundaries.is_empty() + || source.id == protected.id + || baseline.entities.values().any(|entity| { + entity + .read_paths + .values() + .any(|path| path.through == source.id || path.to == source.id) + }) + || !matches!((&root.field_type, &key.field_type), + (FieldTypeSource::Reference { target: root, .. }, FieldTypeSource::Reference { target: key, .. }) if root == key) + || !matches!( + principal.field_type, + FieldTypeSource::String { .. } | FieldTypeSource::Text { .. } + ) + || principal.encryption.is_some() + || active.field_type != FieldTypeSource::Boolean + { + return Err(PackageError::Derivation); + } + if let Some(requirements) = &source.access_requirements { + let mut errors = Vec::new(); + crate::access::check_profile_authority( + requirements, + &profile.required_scopes, + &profile.required_purposes, + "baselinePackage", + &mut errors, + ); + if !requirements.row_boundaries.is_empty() || !errors.is_empty() { + return Err(PackageError::Derivation); + } + } + for (field, column) in [ + (key, &physical.membership_key_column), + (principal, &physical.principal_column), + (active, &physical.active_column), + ] { + if &field.physical_name != column || names.fields.get(&field.id) != Some(column) { + return Err(PackageError::Derivation); + } + } + Ok(()) +} + +/// Rebuild the rehearsal view over the same retained inventories that +/// successor planning uses. As in the migration baseline schema projection, +/// generate DDL from the historical entities, names and Actions. +#[cfg(feature = "tooling")] +fn project_archived_registry( + manifest: &PackageManifest, + loaded: &BTreeMap>, + project: &RegistryProject, + baseline: &CompiledRegistryMigrationBaseline, +) -> Result { + fn member Deserialize<'de>>(model: &mut Value, key: &str) -> Result { + let value = model.get_mut(key).map_or(Value::Null, Value::take); + serde_json::from_value(value).map_err(|error| generated_member_refusal(&error)) + } + + let mut model = packaged_manifest_value(manifest, loaded, PackageFileRole::GovernedModel)?; + let module_closure: Vec = + member(&mut model, "moduleClosure")?; + let archived_locks = module_closure + .iter() + .map(|module| (module.id.as_str(), (&module.version, &module.digest))) + .collect::>(); + if module_closure.len() != project.modules.len() + || archived_locks.len() != module_closure.len() + || project.modules.iter().any(|lock| { + archived_locks.get(lock.id.as_str()) != Some(&(&lock.version, &lock.digest)) + }) + { + return Err(PackageError::Derivation); + } + let ddl = generate_ddl_with_actions( + &baseline.entities, + &baseline.physical_names, + &baseline.actions, + ); + Ok(CompiledRegistry::new( + baseline.registry_id.clone(), + baseline.registry_version.clone(), + member(&mut model, "defaultLanguage")?, + member::>(&mut model, "display")?.unwrap_or_default(), + member(&mut model, "timezone")?, + member::>(&mut model, "reviewAuthorities")?.unwrap_or_default(), + member(&mut model, "datasets")?, + member(&mut model, "accessProfiles")?, + project.package.clone(), + member(&mut model, "manifestProjection")?, + member(&mut model, "moduleOrder")?, + module_closure, + baseline.entities.clone(), + baseline.statistical_datasets.clone(), + baseline.external_views.clone(), + baseline.physical_names.clone(), + baseline.actions.clone(), + baseline.routes.clone(), + baseline.access.clone(), + member(&mut model, "metadataInventory")?, + baseline.queries.clone(), + member(&mut model, "eventDeliveryInventory")?, + baseline.recipients.clone(), + ddl, + // Rehearsal installs the projected schema without publishing artifacts. + serde_json::from_value(Value::Object(Default::default())) + .map_err(|_| PackageError::Derivation)?, + Vec::new(), + baseline.registry_revision.clone(), + )) +} + +/// Reconstruct the historical normalized module value for its exact lock. +/// The legacy grant appended its membership entries after any claim entries. +#[cfg(feature = "tooling")] +fn predecessor_module_digest( + module: &RegistryModule, + memberships: &PredecessorMemberships, + assets: &[ModuleAssetSource], +) -> Result { + let mut value = serde_json::to_value(module).map_err(|_| PackageError::Derivation)?; + for (site, boundaries) in &memberships.historical { + if boundaries.is_empty() { + continue; + } + let (path, _) = site.rsplit_once('/').ok_or(PackageError::Derivation)?; + let grant = value + .pointer_mut(path) + .and_then(Value::as_object_mut) + .ok_or(PackageError::Derivation)?; + let rows = grant + .get_mut("rowBoundaries") + .ok_or(PackageError::Derivation)?; + let entries = rows.as_array_mut().ok_or(PackageError::Derivation)?; + let claim_count = entries + .len() + .checked_sub(boundaries.len()) + .ok_or(PackageError::Derivation)?; + entries.truncate(claim_count); + if entries.is_empty() { + *rows = Value::String("unrestricted".to_owned()); + } + grant.insert( + "membershipBoundaries".to_owned(), + serde_json::to_value(boundaries).map_err(|_| PackageError::Derivation)?, + ); + } + Ok(module_source_digest(&module.id, value, assets)) +} + +#[cfg(feature = "tooling")] +fn validate_predecessor_module_locks( + sources: &ParsedPackageSources, + assets: &[ModuleAssetSource], +) -> Result<()> { + for (module, memberships) in sources.modules.iter().zip(&sources.module_memberships) { + let lock = sources + .project + .modules + .iter() + .find(|lock| lock.id == module.id) + .ok_or(PackageError::Derivation)?; + let original_digest = predecessor_module_digest(module, memberships, assets)?; + if lock.version != module.version || lock.digest.as_ref() != Some(&original_digest) { + return Err(PackageError::Derivation); + } + } + Ok(()) +} + +fn capture_compiler_inputs( manifest: &PackageManifest, loaded: &BTreeMap>, mode: PackageSourceMode, -) -> Result<(CompiledRegistry, bool)> { +) -> Result<(ParsedPackageSources, Vec)> { validate_source_inventory(manifest)?; let fixture_journeys = loaded .get(&manifest.sources.fixture_journeys) @@ -4951,7 +5387,7 @@ fn compile_package_sources( { return Err(PackageError::Derivation); } - let (project, modules) = parse_package_sources(manifest, loaded, mode)?; + let sources = parse_package_sources(manifest, loaded, mode)?; let module_assets = captured_compiler_assets(manifest, loaded)?; let project_assets = module_assets .iter() @@ -4979,12 +5415,39 @@ fn compile_package_sources( .collect(), }) .collect::>(); - validate_declared_package_assets(&project, &modules, &project_assets, &module_sources)?; - validate_captured_bindings(manifest, &project, &modules)?; + validate_declared_package_assets( + &sources.project, + &sources.modules, + &project_assets, + &module_sources, + )?; + validate_captured_bindings(manifest, &sources.project, &sources.modules)?; + Ok((sources, module_assets)) +} + +/// Compile the sources of one verified package closure. The caller +/// decides whether generated artifacts must also match byte for byte. +fn compile_package_sources( + manifest: &PackageManifest, + loaded: &BTreeMap>, + mode: PackageSourceMode, +) -> Result<(CompiledRegistry, bool)> { + let (sources, assets) = capture_compiler_inputs(manifest, loaded, mode)?; + compile_captured_package_sources(manifest, &sources, &assets) +} + +fn compile_captured_package_sources( + manifest: &PackageManifest, + sources: &ParsedPackageSources, + assets: &[ModuleAssetSource], +) -> Result<(CompiledRegistry, bool)> { + if sources.has_historical_membership() { + return Err(PackageError::Derivation); + } let compiled = compile_project_with_assets( - &project, - &modules, - &module_assets, + &sources.project, + &sources.modules, + assets, CompileProfile::Production, ) .map_err(|_| PackageError::Derivation)?; @@ -4993,7 +5456,7 @@ fn compile_package_sources( } Ok(( compiled, - crate::compiler::has_placeholder_identity(&project), + crate::compiler::has_placeholder_identity(&sources.project), )) } diff --git a/crates/registry-breg/src/package/tests/predecessor_sources.rs b/crates/registry-breg/src/package/tests/predecessor_sources.rs index 910b6c94b6..fe7d2f890e 100644 --- a/crates/registry-breg/src/package/tests/predecessor_sources.rs +++ b/crates/registry-breg/src/package/tests/predecessor_sources.rs @@ -5,9 +5,777 @@ #![cfg(feature = "tooling")] use super::*; +use serde_json::json; use std::fs; use std::path::Path; +const MEMBER_GRANT: &str = "/accessProfiles/member/permissions/records/0"; + +fn membership_source() -> Value { + serde_json::from_slice(include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../products/breg/fixtures/organization-membership-access/registry.yaml" + ))) + .expect("the maintained membership fixture parses") +} + +fn historical_member_grant(source: &mut Value) { + source["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("membership"); + let grant = source.pointer_mut(MEMBER_GRANT).unwrap(); + grant["rowBoundaries"] = json!([{"field":"label","claim":"label","operator":"equals"}]); + grant["membershipBoundaries"] = json!([{ + "field": "organization", + "membershipRecordType": "membership", + "membershipKeyField": "organization", + "principalField": "principal", + "activeField": "active" + }]); +} + +#[test] +fn predecessor_sources_refuse_current_membership_elsewhere_in_a_historical_file() { + let mut previous = membership_source(); + historical_member_grant(&mut previous); + let mut different_declaration = + membership_source()["recordTypes"]["membership"]["membership"].clone(); + different_declaration["principal"] = json!("private-note"); + for (pointer, key, value) in [ + ( + "/recordTypes/membership", + "membership", + membership_source()["recordTypes"]["membership"]["membership"].clone(), + ), + ( + "/recordTypes/membership", + "membership", + different_declaration, + ), + ( + "/accessProfiles/steward/permissions/records/2", + "rowBoundaries", + json!([{"field":"organization","membership":"membership"}]), + ), + ( + "/accessProfiles/steward/permissions", + "actions", + json!([{"action":"review","operations":["invoke"],"targets":[{ + "recordType":"facility", + "rowBoundaries":[{"field":"organization","membership":"membership"}] + }]}]), + ), + ( + "/accessProfiles/steward/permissions", + "proposals", + json!([{"action":"review","operations":["apply"],"targets":[{ + "recordType":"facility", + "rowBoundaries":[{"field":"organization","membership":"membership"}] + }]}]), + ), + ( + "", + "rowBoundarySets", + json!({"unused":[{"field":"organization","membership":"membership"}]}), + ), + ] { + let mut mixed = previous.clone(); + mixed.pointer_mut(pointer).unwrap()[key] = value; + let bytes = serde_json::to_vec(&mixed).unwrap(); + let error = parse_predecessor_project_yaml(&bytes).unwrap_err(); + assert_eq!( + error.diagnostics()[0].code, + "breg.membership.mixed-spelling" + ); + assert_eq!( + PackageSourceMode::Predecessor.project(&bytes).err(), + Some(PackageError::Integrity) + ); + assert!(PackageSourceMode::Strict.project(&bytes).is_err()); + } + + previous["rowBoundarySets"] = json!({ + "same-organization":[{"field":"organization","membership":"membership"}] + }); + previous["accessProfiles"]["steward"]["permissions"]["records"][2]["rowBoundaries"] = + json!({"rowBoundarySet":"same-organization"}); + let error = + parse_predecessor_project_yaml(&serde_json::to_vec(&previous).unwrap()).unwrap_err(); + assert_eq!( + error.diagnostics()[0].code, + "breg.membership.mixed-spelling" + ); +} + +#[test] +fn predecessor_sources_refuse_mixed_membership_across_project_and_module() { + let mut project = membership_source(); + historical_member_grant(&mut project); + let historical_grant = project.pointer(MEMBER_GRANT).unwrap()["membershipBoundaries"].clone(); + let mut module = json!({ + "apiVersion": crate::contract::MODULE_API_VERSION, + "kind": crate::contract::MODULE_KIND, + "id": "member-grants", + "version": "1", + "extendRecordTypes": {"facility":{"accessProfiles":{"observer":{ + "principalClaim":"principal", "requiredScopes":["membership:use"], + "operations":["get"], "readableFields":["label"], + "rowBoundaries":"unrestricted" + }}}} + }); + let prepared = prepare_membership_candidate(&membership_source()); + let mut manifest = prepared.manifest; + let mut files = prepared.files; + let module_path = "source/modules/member-grants/module.yaml".to_owned(); + manifest.sources.modules.push(CapturedModule { + id: "member-grants".to_owned(), + path: module_path.clone(), + assets: Vec::new(), + }); + files.insert( + manifest.sources.project.clone(), + serde_json::to_vec(&project).unwrap(), + ); + for (key, declaration) in [ + ( + "recordTypes", + json!({"membership": membership_source()["recordTypes"]["membership"].clone()}), + ), + ( + "rowBoundarySets", + json!({"unused":[{"field":"organization","membership":"membership"}]}), + ), + ] { + module[key] = declaration; + files.insert(module_path.clone(), serde_json::to_vec(&module).unwrap()); + assert_eq!( + parse_package_sources(&manifest, &files, PackageSourceMode::Predecessor).err(), + Some(PackageError::Integrity), + "{key}" + ); + module.as_object_mut().unwrap().remove(key); + } + + module["extendRecordTypes"]["facility"]["accessProfiles"]["observer"]["membershipBoundaries"] = + historical_grant; + files.insert( + manifest.sources.project.clone(), + serde_json::to_vec(&membership_source()).unwrap(), + ); + files.insert(module_path, serde_json::to_vec(&module).unwrap()); + assert_eq!( + parse_package_sources(&manifest, &files, PackageSourceMode::Predecessor).err(), + Some(PackageError::Integrity) + ); +} + +#[test] +fn predecessor_sources_rehearse_a_historically_maintained_membership_source() { + let mut current = membership_source(); + current.pointer_mut(MEMBER_GRANT).unwrap()["rowBoundaries"] + .as_array_mut() + .unwrap() + .insert( + 0, + json!({"field":"label","claim":"label","operator":"equals"}), + ); + let mut prepared = prepare_membership_candidate(¤t); + let source_path = prepared.manifest.sources.project.clone(); + let mut historical: Value = serde_json::from_slice(&prepared.files[&source_path]).unwrap(); + let writer_path = "/accessProfiles/steward/permissions/records/1"; + let maintenance_boundary = + json!([{"field":"principal","claim":"principal","operator":"equals"}]); + current.pointer_mut(writer_path).unwrap()["rowBoundaries"] = maintenance_boundary.clone(); + let edited = parse_project_yaml(&serde_json::to_vec(¤t).unwrap()).unwrap(); + for profile in [CompileProfile::Authoring, CompileProfile::Production] { + let error = compile_project_with_assets(&edited, &[], &[], profile).unwrap_err(); + assert!(error + .diagnostics() + .iter() + .any(|diagnostic| { diagnostic.code == "breg.access.membership-source-key-write" })); + } + + historical_member_grant(&mut historical); + historical.pointer_mut(writer_path).unwrap()["rowBoundaries"] = maintenance_boundary.clone(); + let entry = unique_manifest_file(&prepared.manifest, PackageFileRole::GovernedModel).unwrap(); + let mut model: Value = serde_json::from_slice(&prepared.files[&entry.path]).unwrap(); + let source = &mut model["recordTypes"]["membership"]; + source.as_object_mut().unwrap().remove("membership"); + source["accessProfiles"]["steward"]["rowBoundaries"] = maintenance_boundary; + prepared + .files + .insert(entry.path.clone(), canonicalize_json(&model).unwrap()); + let bytes = serde_json::to_vec(&historical).unwrap(); + assert_eq!( + parse_project_yaml(&bytes).unwrap_err().diagnostics()[0].code, + "config.removed-key" + ); + prepared.files.insert(source_path, bytes); + assert!(matches!( + rederive(&prepared.manifest, &prepared.files), + Err(PackageError::PreviousReleaseSources(_)) + )); + + let governed = package_predecessor_governed_model(&prepared.manifest, &prepared.files).unwrap(); + let baseline = governed.migration_baseline( + "sha256:1111111111111111111111111111111111111111111111111111111111111111", + current_engine_features(), + None, + ); + let registry = project_rehearsal_baseline(&prepared.manifest, &prepared.files, &baseline) + .expect("the historical baseline preserves the archived read and maintenance grants"); + assert_eq!(registry.entities(), &baseline.entities); + assert_eq!(registry.physical_names(), &baseline.physical_names); + assert_eq!(registry.access(), &baseline.access); + assert_eq!( + registry.ddl(), + prepared + .registry + .with_migration_baseline_schema(&baseline) + .ddl() + ); + let previous_writer = edited + .access_profiles + .iter() + .find(|profile| profile.id == "steward") + .unwrap() + .permissions + .entities + .iter() + .find(|grant| grant.entity == "membership") + .unwrap(); + assert_eq!( + registry.entities()["membership"].access_profiles["steward"].row_boundaries, + previous_writer.row_boundaries + ); + assert!(registry.ddl().functions.iter().any(|function| { + function.name == crate::membership::function_name("facility", "member", 0) + })); + assert!(!registry + .ddl() + .statements + .iter() + .any(|statement| { statement.id == "entity.membership.membership.key-index" })); + let maintenance = current.pointer_mut(writer_path).unwrap(); + maintenance["operations"] = json!(["get", "patch"]); + maintenance["writableFields"] = json!(["private-note"]); + let successor = prepare_membership_candidate(¤t); + assert!(successor + .registry + .ddl() + .statements + .iter() + .any(|statement| { statement.id == "entity.membership.membership.key-index" })); + let changes = compiled_registry_change_set_from_baseline( + &baseline, + &successor.registry, + &baseline.package_digest, + ); + assert_eq!(changes.from_package_digest, baseline.package_digest); + assert!(changes.changes.iter().any(|change| { + change.code == CompiledRegistryChangeCode::AccessProfileChanged + && change.target.record_type_id.as_deref() == Some("membership") + })); +} + +fn prepare_membership_candidate(source: &Value) -> PreparedPackage { + let mut source = source.clone(); + source["package"] = json!({ + "sourceRevision":"0123456789abcdef0123456789abcdef01234567" + }); + prepare_package(PackageBuildRequest { + from_package_digest: None, + compiler_source_revision: "0123456789abcdef0123456789abcdef01234567".to_owned(), + schema_fingerprint: + "sha256:1111111111111111111111111111111111111111111111111111111111111111".to_owned(), + project: PackageSourceFile { + path: "source/project.yaml".to_owned(), + bytes: serde_json::to_vec(&source).unwrap(), + }, + modules: Vec::new(), + fixture_journeys: PackageSourceFile { + path: FIXTURE_JOURNEYS_PATH.to_owned(), + bytes: b"journeys: []".to_vec(), + }, + migration_plan: PackageMigrationPlanInput::InitialCompiledDdl, + }) + .expect("the maintained membership source compiles for a candidate") +} + +#[test] +fn predecessor_sources_preserve_a_historical_membership_and_claim_conjunction() { + let mut previous = membership_source(); + historical_member_grant(&mut previous); + let mut current = membership_source(); + current.pointer_mut(MEMBER_GRANT).unwrap()["rowBoundaries"] + .as_array_mut() + .unwrap() + .insert( + 0, + previous.pointer(MEMBER_GRANT).unwrap()["rowBoundaries"][0].clone(), + ); + + let bytes = serde_json::to_vec(&previous).unwrap(); + assert_eq!( + parse_project_yaml(&bytes).unwrap_err().diagnostics()[0].code, + "config.removed-key" + ); + assert!(PackageSourceMode::Strict.project(&bytes).is_err()); + let (project, legacy) = PackageSourceMode::Predecessor.project(&bytes).unwrap(); + assert_eq!(legacy.historical.len(), 1); + let prepared = prepare_membership_candidate(¤t); + let archive_profile = &prepared.registry.entities()["facility"].access_profiles["member"]; + let historical_permission = &project + .access_profiles + .iter() + .find(|profile| profile.id == "member") + .unwrap() + .permissions + .entities[0]; + assert_eq!( + historical_permission.row_boundaries, + archive_profile.row_boundaries + ); + assert_eq!( + archive_profile.membership_boundaries, + vec![MembershipBoundarySource::Expanded( + legacy.historical.values().next().unwrap()[0].clone() + )] + ); +} + +#[test] +fn predecessor_sources_refuse_malformed_or_mixed_historical_membership() { + let mut previous = membership_source(); + historical_member_grant(&mut previous); + let cases: [(&str, Value, &str); 8] = [ + ("membershipBoundaries", Value::Null, "config.null-value"), + ( + "membershipBoundaries/0/principalField", + json!(false), + "config.expected-string", + ), + ( + "membershipBoundaries/0/unknownField", + json!("extra"), + "config.unknown-key", + ), + ( + "membershipBoundaries/0/field", + json!("id"), + "breg.access.membership-key-type", + ), + ("membershipBoundaries/1", json!(null), "config.null-value"), + ( + "rowBoundaries/0", + json!({"field":"organization","membership":"membership"}), + "breg.membership.mixed-spelling", + ), + ( + "operations", + json!(["patch"]), + "breg.access.membership-read-only", + ), + ( + "writableFields", + json!(["label"]), + "breg.access.membership-read-only", + ), + ]; + for (path, value, code) in cases { + let mut source = previous.clone(); + let grant = source.pointer_mut(MEMBER_GRANT).unwrap(); + if path == "membershipBoundaries/1" { + grant["membershipBoundaries"] + .as_array_mut() + .unwrap() + .push(value); + } else { + let pointer = format!("/{path}"); + if let Some(target) = grant.pointer_mut(&pointer) { + *target = value; + } else if let Some((parent, key)) = pointer.rsplit_once('/') { + grant.pointer_mut(parent).unwrap()[key] = value; + } + } + let bytes = serde_json::to_vec(&source).unwrap(); + let error = parse_predecessor_project_yaml(&bytes).unwrap_err(); + assert_eq!(error.diagnostics()[0].code, code, "{path}: {error:?}"); + assert!(PackageSourceMode::Strict.project(&bytes).is_err()); + } + + let bytes = serde_json::to_string(&previous).unwrap().replace( + "\"membershipBoundaries\":", + "\"membershipBoundaries\":[],\"membershipBoundaries\":", + ); + for mode in [PackageSourceMode::Strict, PackageSourceMode::Predecessor] { + assert_eq!( + mode.project(bytes.as_bytes()).err(), + Some(PackageError::Integrity) + ); + } + + let grant = previous.pointer_mut(MEMBER_GRANT).unwrap(); + let duplicate = grant["membershipBoundaries"][0].clone(); + grant["membershipBoundaries"] + .as_array_mut() + .unwrap() + .push(duplicate); + let error = + parse_predecessor_project_yaml(&serde_json::to_vec(&previous).unwrap()).unwrap_err(); + assert_eq!( + error.diagnostics()[0].code, + "breg.access.membership-duplicate" + ); +} + +#[test] +fn predecessor_sources_still_refuse_an_unrelated_retired_key() { + let mut previous = membership_source(); + historical_member_grant(&mut previous); + previous["recordTypes"]["facility"]["changeControl"] = json!({}); + let error = + parse_predecessor_project_yaml(&serde_json::to_vec(&previous).unwrap()).unwrap_err(); + assert_eq!(error.diagnostics()[0].code, "config.removed-key"); + assert!(error.diagnostics()[0].path.ends_with(".changeControl")); +} + +#[test] +fn predecessor_sources_keep_the_module_lock_bound_to_the_exact_membership_fields() { + let mut previous = membership_source(); + historical_member_grant(&mut previous); + let boundaries = previous.pointer(MEMBER_GRANT).unwrap()["membershipBoundaries"].clone(); + previous["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("member"); + let mut module = json!({ + "apiVersion": crate::contract::MODULE_API_VERSION, + "kind": crate::contract::MODULE_KIND, + "id": "member-grants", + "version": "1", + "extendRecordTypes": { + "facility": {"accessProfiles": { + "member": { + "principalClaim": "principal", + "requiredScopes": ["records:read", "membership:use"], + "operations": ["get"], + "readableFields": ["label"], + "rowBoundaries": "unrestricted", + "membershipBoundaries": boundaries + } + }} + } + }); + let bytes = serde_json::to_vec(&module).unwrap(); + assert!(parse_module_yaml(&bytes).is_err()); + assert!(PackageSourceMode::Strict.module(&bytes).is_err()); + let (original, original_memberships) = PackageSourceMode::Predecessor.module(&bytes).unwrap(); + let assets = [ModuleAssetSource { + module: Some("member-grants".to_owned()), + path: "plans/check.rhai".to_owned(), + bytes: b"fn plan(ctx) { #{effects: []} }".to_vec(), + }]; + let original_digest = + predecessor_module_digest(&original, &original_memberships, &assets).unwrap(); + assert_ne!( + original_digest, + crate::compiler::module_digest_with_assets(&original, &assets) + ); + + let other = parse_module_yaml( + &serde_json::to_vec(&json!({ + "apiVersion": crate::contract::MODULE_API_VERSION, + "kind": crate::contract::MODULE_KIND, + "id": "other", + "version": "2" + })) + .unwrap(), + ) + .unwrap(); + let other_digest = crate::compiler::module_digest_with_assets(&other, &assets); + + previous["modules"] = json!({ + "member-grants": {"version":"1", "digest": original_digest}, + "other": {"version":"2", "digest":other_digest} + }); + let project = parse_project_yaml(&serde_json::to_vec(&previous).unwrap()).unwrap(); + module["extendRecordTypes"]["facility"]["accessProfiles"]["member"]["membershipBoundaries"] + [0]["principalField"] = json!("private-note"); + let (changed, changed_memberships) = PackageSourceMode::Predecessor + .module(&serde_json::to_vec(&module).unwrap()) + .unwrap(); + assert_eq!(changed, original); + let changed_sources = ParsedPackageSources { + project: project.clone(), + modules: vec![other.clone(), changed], + project_memberships: PredecessorMemberships::default(), + module_memberships: vec![PredecessorMemberships::default(), changed_memberships], + }; + assert_eq!( + validate_predecessor_module_locks(&changed_sources, &assets), + Err(PackageError::Derivation) + ); + + let original_sources = ParsedPackageSources { + project, + modules: vec![other, original], + project_memberships: PredecessorMemberships::default(), + module_memberships: vec![PredecessorMemberships::default(), original_memberships], + }; + validate_predecessor_module_locks(&original_sources, &assets).unwrap(); + assert_eq!( + validate_predecessor_module_locks(&original_sources, &[]), + Err(PackageError::Derivation) + ); + assert_eq!( + original_sources.project.modules[0].digest.as_deref(), + Some(original_digest.as_str()) + ); +} + +fn historical_membership_package() -> PreparedPackage { + let mut current = membership_source(); + current.pointer_mut(MEMBER_GRANT).unwrap()["rowBoundaries"] + .as_array_mut() + .unwrap() + .insert( + 0, + json!({"field":"label","claim":"label","operator":"equals"}), + ); + let mut package = prepare_membership_candidate(¤t); + let path = package.manifest.sources.project.clone(); + let mut source: Value = serde_json::from_slice(&package.files[&path]).unwrap(); + historical_member_grant(&mut source); + package + .files + .insert(path, serde_json::to_vec(&source).unwrap()); + edit_governed_model(&mut package, |model| { + model["recordTypes"]["membership"] + .as_object_mut() + .unwrap() + .remove("membership"); + }); + package +} + +fn edit_governed_model(package: &mut PreparedPackage, edit: impl FnOnce(&mut Value)) { + let entry = unique_manifest_file(&package.manifest, PackageFileRole::GovernedModel).unwrap(); + let mut model = serde_json::from_slice(&package.files[&entry.path]).unwrap(); + edit(&mut model); + package + .files + .insert(entry.path.clone(), canonicalize_json(&model).unwrap()); +} + +fn historical_membership_baseline(package: &PreparedPackage) -> CompiledRegistryMigrationBaseline { + let governed = package_predecessor_governed_model(&package.manifest, &package.files).unwrap(); + governed.migration_baseline( + "sha256:1111111111111111111111111111111111111111111111111111111111111111", + current_engine_features(), + None, + ) +} + +#[test] +fn predecessor_sources_rehearse_distinct_membership_tuples_on_one_source() { + let mut package = historical_membership_package(); + let path = package.manifest.sources.project.clone(); + let mut source: Value = serde_json::from_slice(&package.files[&path]).unwrap(); + let stored_bounds = source.pointer_mut(MEMBER_GRANT).unwrap()["membershipBoundaries"] + .as_array_mut() + .unwrap(); + let mut alternate = stored_bounds[0].clone(); + alternate["principalField"] = json!("private-note"); + stored_bounds.push(alternate.clone()); + package + .files + .insert(path, serde_json::to_vec(&source).unwrap()); + + let alternate_column = package.registry.entities()["membership"].fields["private-note"] + .physical_name + .clone(); + edit_governed_model(&mut package, |model| { + let entity = &mut model["recordTypes"]["facility"]; + entity["accessProfiles"]["member"]["membershipBoundaries"] + .as_array_mut() + .unwrap() + .push(alternate); + let compiled = entity["membershipBoundaries"]["member"] + .as_array_mut() + .unwrap(); + let mut alternate = compiled[0].clone(); + alternate["principalColumn"] = json!(alternate_column); + compiled.push(alternate); + }); + let baseline = historical_membership_baseline(&package); + let sources = parse_package_sources( + &package.manifest, + &package.files, + PackageSourceMode::Predecessor, + ) + .unwrap(); + validate_predecessor_membership_inventory(&sources, &baseline).unwrap(); + let registry = project_rehearsal_baseline(&package.manifest, &package.files, &baseline) + .expect("rehearsal preserves each archived tuple"); + let boundaries = ®istry.entities()["facility"].membership_boundaries["member"]; + assert_eq!(boundaries.len(), 2); + assert_ne!( + boundaries[0].principal_column, + boundaries[1].principal_column + ); + for (ordinal, boundary) in boundaries.iter().enumerate() { + let probe = crate::membership::function_name("facility", "member", ordinal); + let statement = registry + .ddl() + .statements + .iter() + .find(|statement| statement.id == format!("registry_context.{probe}")) + .expect("one read probe per historical tuple"); + assert!(statement + .sql + .contains(&format!("membership.\"{}\"", boundary.principal_column))); + } +} + +#[test] +fn predecessor_membership_inventory_refuses_unmatched_members() { + let package = historical_membership_package(); + let sources = parse_package_sources( + &package.manifest, + &package.files, + PackageSourceMode::Predecessor, + ) + .unwrap(); + let baseline = historical_membership_baseline(&package); + validate_predecessor_membership_inventory(&sources, &baseline).unwrap(); + let mut logical_only = baseline.clone(); + let facility = logical_only.entities.get_mut("facility").unwrap(); + facility + .access_profiles + .get_mut("steward") + .unwrap() + .membership_boundaries = baseline.entities["facility"].access_profiles["member"] + .membership_boundaries + .clone(); + assert_eq!( + validate_predecessor_membership_inventory(&sources, &logical_only), + Err(PackageError::Derivation) + ); + + let mut mismatched = baseline.clone(); + mismatched + .entities + .get_mut("facility") + .unwrap() + .membership_boundaries + .get_mut("member") + .unwrap()[0] + .principal_column = baseline.entities["membership"].fields["private-note"] + .physical_name + .clone(); + assert_eq!( + validate_predecessor_membership_inventory(&sources, &mismatched), + Err(PackageError::Derivation) + ); +} + +#[test] +fn predecessor_membership_inventory_refuses_granted_read_paths_to_protected_records() { + let package = historical_membership_package(); + let sources = parse_package_sources( + &package.manifest, + &package.files, + PackageSourceMode::Predecessor, + ) + .unwrap(); + let baseline = historical_membership_baseline(&package); + for (through, to) in [("facility", "organization"), ("organization", "facility")] { + let mut archive = baseline.clone(); + let entity = archive.entities.get_mut("organization").unwrap(); + let path = crate::model::CompiledReadPath { + id: "related".to_owned(), + route: "related".to_owned(), + through: through.to_owned(), + to: to.to_owned(), + source_ref: "organization".to_owned(), + target_ref: "organization".to_owned(), + }; + entity.read_paths.insert(path.id.clone(), path); + validate_predecessor_membership_inventory(&sources, &archive).unwrap(); + + archive + .entities + .get_mut("organization") + .unwrap() + .access_profiles + .get_mut("steward") + .unwrap() + .read_paths + .push(serde_json::from_value(json!({"path":"related"})).unwrap()); + assert_eq!( + validate_predecessor_membership_inventory(&sources, &archive), + Err(PackageError::Derivation) + ); + } +} + +#[test] +fn predecessor_membership_inventory_refuses_current_action_and_proposal_targets() { + let package = historical_membership_package(); + let sources = parse_package_sources( + &package.manifest, + &package.files, + PackageSourceMode::Predecessor, + ) + .unwrap(); + let mut baseline = historical_membership_baseline(&package); + baseline.actions = serde_json::from_slice(include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../products/breg/generated/facility/compiled/actions.json" + ))) + .unwrap(); + validate_predecessor_membership_inventory(&sources, &baseline).unwrap(); + let boundary = &baseline.entities["facility"].membership_boundaries["member"][0]; + let mut immediate = baseline.clone(); + let action = immediate + .actions + .actions + .iter_mut() + .find(|action| !action.execution.is_proposal()) + .unwrap(); + action.permissions[0].targets[0] + .membership_boundaries + .push(boundary.clone()); + assert_eq!( + validate_predecessor_membership_inventory(&sources, &immediate), + Err(PackageError::Derivation) + ); + + let mut proposal = baseline.clone(); + let policy = proposal + .actions + .actions + .iter_mut() + .find_map(|action| match &mut action.execution { + crate::model::CompiledActionExecution::Proposal { proposal } => Some(proposal), + crate::model::CompiledActionExecution::Immediate => None, + }) + .unwrap(); + let target = policy + .permissions + .iter_mut() + .flat_map(|grant| &mut grant.targets) + .next() + .unwrap(); + target.membership_boundaries.push(boundary.clone()); + assert_eq!( + validate_predecessor_membership_inventory(&sources, &proposal), + Err(PackageError::Derivation) + ); +} + /// An exact historical package built before access profiles were keyed by id, /// so its stored sources list them. fn list_form_package() -> PathBuf { diff --git a/crates/registry-breg/src/postgres/catalog.rs b/crates/registry-breg/src/postgres/catalog.rs index 232c70d0d5..6147b08510 100644 --- a/crates/registry-breg/src/postgres/catalog.rs +++ b/crates/registry-breg/src/postgres/catalog.rs @@ -143,6 +143,7 @@ const MANAGED_INTERNAL_INDEXES: &[&str] = &[ "registry_internal.registry_ingestion_run_chunk_records_erased_record", "registry_internal.registry_migrations_one_open_activation_per_digest", "registry_internal.registry_proposal_evidence_uses_expiry", + "registry_internal.registry_proposal_form_entries_form", "registry_internal.registry_proposal_idempotency_by_request", "registry_internal.registry_proposal_pending_targets", "registry_internal.registry_proposal_queue", diff --git a/crates/registry-breg/src/postgres/mutation.rs b/crates/registry-breg/src/postgres/mutation.rs index 71806ab3c7..8b23538705 100644 --- a/crates/registry-breg/src/postgres/mutation.rs +++ b/crates/registry-breg/src/postgres/mutation.rs @@ -72,6 +72,8 @@ pub struct PostgresRecordMutationService { proposal_read_barrier_for_test: Option, #[cfg(feature = "postgres-test")] task_context_barrier_for_test: Option, + #[cfg(feature = "postgres-test")] + automatic_apply_barrier_for_test: Option, evidence_timeout: Duration, evidence_evaluator: Option>, review_result_source: Option>, @@ -758,6 +760,8 @@ impl PostgresRecordMutationService { proposal_read_barrier_for_test: None, #[cfg(feature = "postgres-test")] task_context_barrier_for_test: None, + #[cfg(feature = "postgres-test")] + automatic_apply_barrier_for_test: None, evidence_timeout: REQUEST_ACTION_TIMEOUT, evidence_evaluator: None, review_result_source: None, @@ -804,6 +808,20 @@ impl PostgresRecordMutationService { self } + /// Pause the automatic worker after it has read the Proposal and before + /// it applies it, so a test can land another write in between. + #[cfg(feature = "postgres-test")] + #[must_use] + #[doc(hidden)] + pub fn with_automatic_apply_barrier_for_test( + mut self, + loaded: Arc, + resume: Arc, + ) -> Self { + self.automatic_apply_barrier_for_test = Some(ProposalReadBarrier { loaded, resume }); + self + } + #[cfg(feature = "postgres-test")] #[must_use] #[doc(hidden)] @@ -2173,6 +2191,7 @@ impl PostgresRecordMutationService { | MutationError::ProposalRejected | MutationError::ProposalSubjectNotCaller | MutationError::ProposalSubjectChanged + | MutationError::ProposalMessageLimitReached | MutationError::AuthorizationRefused(_) // Ingestion consumes the batch mutation outcome through // its run protocol. Its item refusal remains the generic @@ -2202,6 +2221,8 @@ impl PostgresRecordMutationService { | MutationError::AttachmentSlotWriteOnce | MutationError::AttachmentTooLarge | MutationError::AttachmentLimitReached + | MutationError::FormUndeclared + | MutationError::FormLimitReached | MutationError::AttachmentRequired { .. } | MutationError::AttachmentVerificationPending { .. } | MutationError::AttachmentVerificationRejected { .. } diff --git a/crates/registry-breg/src/postgres/proposal.rs b/crates/registry-breg/src/postgres/proposal.rs index ed4cb34bf6..86d8156c22 100644 --- a/crates/registry-breg/src/postgres/proposal.rs +++ b/crates/registry-breg/src/postgres/proposal.rs @@ -12,6 +12,9 @@ use crate::postgres::{begin_proposal_transaction, ProposalAuthority, ProposalAut use crate::proposal_store; use std::collections::{BTreeMap, BTreeSet}; +#[path = "proposal_messages.rs"] +mod messages; + const REVIEW_PROGRESS_LOOKUP_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(1); const REVIEW_PROGRESS_FINAL_READ_RESERVE: std::time::Duration = std::time::Duration::from_millis(250); @@ -248,7 +251,7 @@ impl PostgresRecordMutationService { return Ok(false); }; let result = async { - let (authority, etag) = { + let authority = { let mut client = tokio::time::timeout_at(deadline, self.pool.get()) .await .map_err(|_| MutationError::Unavailable)? @@ -277,19 +280,17 @@ impl PostgresRecordMutationService { ) .await .map_err(|_| MutationError::PreconditionFailed)?; - let document = proposal_store::load_document( - guarded.transaction(), - id, - proposal_store::DocumentLock::None, - ) - .await?; - let etag = self.coordinator.proposal_etag(&document, &authority)?; guarded .commit() .await .map_err(|_| MutationError::Unavailable)?; - (authority, etag) + authority }; + #[cfg(feature = "postgres-test")] + if let Some(barrier) = &self.automatic_apply_barrier_for_test { + barrier.loaded.notify_one(); + barrier.resume.notified().await; + } let correlation = crate::correlation::RequestCorrelation::breg_created(); let key = format!("breg-proposal-automatic-{job_id}"); self.proposal_mutation_with_deadline( @@ -299,7 +300,12 @@ impl PostgresRecordMutationService { operation: ProposalAuthorityOperation::Lifecycle(ProposalOperation::Apply), authority: &authority, idempotency_key: &key, - expected_etag: Some(&etag), + // The claimed lease, the submission version and the + // frozen effect digest fence this Apply inside its own + // transaction. A Proposal ETag read earlier would also + // fence on thread activity, which never changes what is + // applied. + expected_etag: None, input: None, submission_version: Some(frozen.version().get()), effect_digest: Some(frozen.effect_digest().as_str()), @@ -310,7 +316,9 @@ impl PostgresRecordMutationService { }), rebase_start_authority: None, attachment: None, + form: None, answer: None, + message: None, correlation: &correlation, human_identity: None, claims: None, diff --git a/crates/registry-breg/src/postgres/proposal_context.rs b/crates/registry-breg/src/postgres/proposal_context.rs index 03dc8bc592..7a1d9dc66b 100644 --- a/crates/registry-breg/src/postgres/proposal_context.rs +++ b/crates/registry-breg/src/postgres/proposal_context.rs @@ -44,6 +44,10 @@ pub(crate) struct ProposalAuthority { /// else and under no task grant. Only such a caller is matched as a /// subject. Review reads clear the answers flag, never this one. pub(crate) person: bool, + pub(crate) receives_form_values: bool, + /// The same caller's `message` admission, set by a review-context read + /// that may serve the thread: `true` serves its text, `false` its counts. + pub(crate) review_messages: Option<(Box, bool)>, system: Option, } @@ -165,6 +169,8 @@ impl ProposalAuthority { proposal_scope: None, receives_review_answers: false, person: false, + receives_form_values: false, + review_messages: None, system: None, }) } @@ -293,6 +299,8 @@ impl ProposalAuthority { proposal_scope: Some(BTreeSet::from([proposal_id])), receives_review_answers: false, person: false, + receives_form_values: false, + review_messages: None, system: Some(SystemApplyAuthority { grant: grant.clone(), proposal_id, @@ -536,6 +544,7 @@ impl ProposalAuthority { ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetReviewContext) => "get-review-context", ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetTaskGrantContext) => "get-task-grant-context", ProposalAuthorityOperation::Lifecycle(ProposalOperation::GetApplicationActor) => "get-application-actor", + ProposalAuthorityOperation::Lifecycle(ProposalOperation::Message) => "message", }, "phase": match phase {ProposalTargetPhase::Preparation=>"preparation",ProposalTargetPhase::Application=>"application",ProposalTargetPhase::Inspection=>"inspection"}, "targetEntityId": target_entity_id, "targetRecordId": target_record_id, diff --git a/crates/registry-breg/src/postgres/proposal_messages.rs b/crates/registry-breg/src/postgres/proposal_messages.rs new file mode 100644 index 0000000000..68365d898e --- /dev/null +++ b/crates/registry-breg/src/postgres/proposal_messages.rs @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Reading a Proposal's message thread page by page, and one side marking +//! it read. A write is an ordinary Proposal command. +use super::*; +use crate::model::CompiledAction; +use crate::proposal_messages; +use crate::proposal_store::ProposalDocument; + +impl PostgresRecordMutationService { + /// One page of the thread, newest first. `before` is the cursor the + /// previous page returned. + pub(crate) async fn proposal_messages_page( + &self, + id: Uuid, + authority: &ProposalAuthority, + before: Option, + limit: i64, + correlation: &crate::correlation::RequestCorrelation, + ) -> Result { + let method = crate::model::HttpMethod::Get; + let _attempt = self + .coordinator + .begin_proposal_read_audit(authority, method, correlation) + .await?; + let deadline = tokio::time::Instant::now() + self.action_timeout; + let client = self + .admitted_proposal_read_client(authority, method, correlation, deadline) + .await?; + let mut guard = QueryCancellationGuard::new(self.pool.clone(), client); + let result = tokio::time::timeout_at(deadline, async { + let guarded = begin_proposal_transaction( + guard.client(), + self.lock_key, + self.lock_timeout, + &self.expected, + authority, + ) + .await + .map_err(|_| MutationError::Unavailable)?; + guarded + .set_statement_budget( + deadline.saturating_duration_since(tokio::time::Instant::now()), + ) + .await + .map_err(|_| MutationError::Unavailable)?; + let tx = guarded.transaction(); + let document = + proposal_store::load_document(tx, id, proposal_store::DocumentLock::Share).await?; + self.coordinator + .authorize_proposal_document(tx, &self.registry, &document, authority) + .await?; + let reader = self.coordinator.proposal_actor_of(&authority.common)?; + let mut page = + proposal_messages::page(tx, &document.action_id, id, before, limit + 1, &reader) + .await?; + let more = page.len() as i64 > limit; + page.truncate(limit as usize); + let mut value = + json!({"items":page.iter().map(|(_, item)| item.clone()).collect::>()}); + // The page carries the thread's links, so a reader with no + // document to start from still has the write's condition. + value["links"] = self + .coordinator + .proposal_message_links(tx, self.thread_action(&document)?, &document, authority) + .await?; + if more { + if let Some((position, _)) = page.last() { + value["nextCursor"] = json!(position.to_string()); + } + } + guarded + .commit() + .await + .map_err(|_| MutationError::Unavailable)?; + self.coordinator + .finish_proposal_read_audit( + authority, + method, + Some(&document), + page.len(), + Some(MESSAGES_REFERENCE), + correlation, + ) + .await?; + Ok(value) + }) + .await; + self.finish_message_request(guard, result, authority, method, correlation) + .await + } + + /// Move the caller's side of the thread forward through `through`. A + /// move advances the Proposal revision and emits no event; repeating it + /// changes nothing. With `thread_view`, a caller answered without a + /// Proposal document receives the thread when no review context is + /// readable. + pub(crate) async fn proposal_mark_messages_read( + &self, + id: Uuid, + authority: &ProposalAuthority, + through: Uuid, + thread_view: bool, + correlation: &crate::correlation::RequestCorrelation, + ) -> Result, MutationError> { + let method = crate::model::HttpMethod::Post; + let _attempt = self + .coordinator + .begin_proposal_read_audit(authority, method, correlation) + .await?; + let deadline = tokio::time::Instant::now() + self.action_timeout; + let client = self + .admitted_proposal_read_client(authority, method, correlation, deadline) + .await?; + let mut guard = QueryCancellationGuard::new(self.pool.clone(), client); + let result = tokio::time::timeout_at(deadline, async { + let guarded = begin_proposal_transaction( + guard.client(), + self.lock_key, + self.lock_timeout, + &self.expected, + authority, + ) + .await + .map_err(|_| MutationError::Unavailable)?; + guarded + .set_statement_budget( + deadline.saturating_duration_since(tokio::time::Instant::now()), + ) + .await + .map_err(|_| MutationError::Unavailable)?; + let tx = guarded.transaction(); + let document = + proposal_store::load_document(tx, id, proposal_store::DocumentLock::Update).await?; + self.coordinator + .authorize_proposal_document(tx, &self.registry, &document, authority) + .await?; + let moved = self + .coordinator + .record_messages_read(tx, &document, authority, through) + .await?; + let view = if thread_view { + let document = + proposal_store::load_document(tx, id, proposal_store::DocumentLock::None) + .await?; + self.coordinator + .proposal_thread_view(tx, self.thread_action(&document)?, &document, authority) + .await? + } else { + None + }; + guarded + .commit() + .await + .map_err(|_| MutationError::Unavailable)?; + self.coordinator + .finish_proposal_read_audit( + authority, + method, + Some(&document), + usize::from(moved), + view.as_ref().map(|_| MESSAGES_REFERENCE), + correlation, + ) + .await?; + Ok(view) + }) + .await; + self.finish_message_request(guard, result, authority, method, correlation) + .await + } + + fn thread_action(&self, document: &ProposalDocument) -> Result<&CompiledAction, MutationError> { + self.registry + .actions() + .actions + .iter() + .find(|action| action.id == document.action_id) + .ok_or(MutationError::PreconditionFailed) + } + + async fn finish_message_request( + &self, + mut guard: QueryCancellationGuard, + result: Result, tokio::time::error::Elapsed>, + authority: &ProposalAuthority, + method: crate::model::HttpMethod, + correlation: &crate::correlation::RequestCorrelation, + ) -> Result { + let result = match result { + Ok(result) => { + guard.disarm(); + result + } + Err(_) => { + guard.cancel_and_discard().await; + Err(MutationError::Unavailable) + } + }; + if result.is_err() { + self.coordinator + .record_proposal_refusal(authority, method, correlation) + .await?; + } + result + } +} + +/// The audit marker of a read that served message text. +const MESSAGES_REFERENCE: &str = "proposal-messages"; diff --git a/crates/registry-breg/src/problem.rs b/crates/registry-breg/src/problem.rs index 1f2fd495d6..66bbe87cf4 100644 --- a/crates/registry-breg/src/problem.rs +++ b/crates/registry-breg/src/problem.rs @@ -30,6 +30,8 @@ pub enum ProblemCode { AttachmentContentType, AttachmentDigestMismatch, AttachmentLimitReached, + ProposalFormUndeclared, + ProposalFormLimitReached, AttachmentRequired, AttachmentSlotWriteOnce, AttachmentTooLarge, @@ -50,6 +52,7 @@ pub enum ProblemCode { PreconditionFailed, PreconditionRequired, ProfileNotAuthorized, + ProposalMessageLimitReached, ProposalRejected, ProposalReviewResultMismatch, ProposalSubjectChanged, @@ -105,6 +108,9 @@ impl ProblemCode { Self::PreconditionFailed, Self::PreconditionRequired, Self::ProfileNotAuthorized, + Self::ProposalFormLimitReached, + Self::ProposalFormUndeclared, + Self::ProposalMessageLimitReached, Self::ProposalRejected, Self::ProposalReviewResultMismatch, Self::ProposalSubjectChanged, @@ -163,6 +169,9 @@ impl ProblemCode { Self::PreconditionFailed, Self::PreconditionRequired, Self::ProfileNotAuthorized, + Self::ProposalFormLimitReached, + Self::ProposalFormUndeclared, + Self::ProposalMessageLimitReached, Self::ProposalRejected, Self::ProposalReviewResultMismatch, Self::ProposalSubjectChanged, @@ -197,6 +206,8 @@ impl ProblemCode { Self::AttachmentContentType => "attachment.content-type", Self::AttachmentDigestMismatch => "attachment.digest-mismatch", Self::AttachmentLimitReached => "attachment.limit-reached", + Self::ProposalFormUndeclared => "proposal.form-undeclared", + Self::ProposalFormLimitReached => "proposal.form-limit-reached", Self::AttachmentRequired => "attachment.required", Self::AttachmentVerificationPending => "attachment.verification-pending", Self::AttachmentVerificationRejected => "attachment.verification-rejected", @@ -217,6 +228,7 @@ impl ProblemCode { Self::PreconditionFailed => "precondition.failed", Self::PreconditionRequired => "precondition.required", Self::ProfileNotAuthorized => "profile.not-authorized", + Self::ProposalMessageLimitReached => "proposal.message-limit-reached", Self::ProposalRejected => "proposal.rejected", Self::ProposalReviewResultMismatch => "proposal.review-result-mismatch", Self::ProposalSubjectChanged => "proposal.subject-changed", @@ -257,15 +269,17 @@ impl ProblemCode { | Self::ProfileNotAuthorized | Self::ProposalSubjectNotCaller | Self::WriteOutsideBoundary => 403, - Self::LookupUnresolved | Self::ResourceNotFound => 404, + Self::LookupUnresolved | Self::ResourceNotFound | Self::ProposalFormUndeclared => 404, Self::AttachmentSlotWriteOnce | Self::AttachmentLimitReached + | Self::ProposalFormLimitReached | Self::AttachmentVerificationPending | Self::IdempotencyConflict | Self::IngestionChunkMismatch | Self::IngestionRunBlocked | Self::IngestionRunNotOpen | Self::MutationConflict + | Self::ProposalMessageLimitReached | Self::ProposalRejected | Self::ProposalSubjectChanged | Self::StatisticalDatasetVersionConflict => 409, @@ -345,6 +359,8 @@ impl ProblemCode { } Self::AttachmentTooLarge => "The file is larger than the attachment slot accepts.", Self::AttachmentLimitReached => "The supporting document slot has reached its file limit.", + Self::ProposalFormUndeclared => "The Action does not declare this additional form.", + Self::ProposalFormLimitReached => "The submission has reached the entry limit for this form.", Self::AttachmentRequired => "The required attachment slot is empty.", Self::AttachmentVerificationPending => "The attachment is awaiting verification. Refresh the Proposal before submitting.", Self::AttachmentVerificationRejected => "The attachment was rejected by verification. Replace or remove the file before submitting.", @@ -370,6 +386,7 @@ impl ProblemCode { } Self::PreconditionFailed => "The mutation precondition failed.", Self::ProposalReviewResultMismatch => "The current review result does not match the retained approval.", + Self::ProposalMessageLimitReached => "This Proposal's message thread is full.", Self::ProposalSubjectChanged => "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.", Self::ProposalSubjectNotCaller => "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.", Self::PreconditionRequired => "The mutation precondition is required.", diff --git a/crates/registry-breg/src/problem_location.rs b/crates/registry-breg/src/problem_location.rs index bb063e5667..a79f751c94 100644 --- a/crates/registry-breg/src/problem_location.rs +++ b/crates/registry-breg/src/problem_location.rs @@ -118,6 +118,20 @@ impl RequestLocation { scope: Scope::Input, } } + /// The text of a Proposal message. No submitted value is echoed. + pub fn proposal_message_text() -> Self { + Self { + pointer: "/text".into(), + scope: Scope::Input, + } + } + /// The message a mark-read names. No submitted value is echoed. + pub fn proposal_message_through() -> Self { + Self { + pointer: "/through".into(), + scope: Scope::Input, + } + } pub fn proposal_answer_additions() -> Self { Self { pointer: "/additions".into(), @@ -125,6 +139,13 @@ impl RequestLocation { } } + pub fn proposal_answer_form_entries() -> Self { + Self { + pointer: "/formEntries".into(), + scope: Scope::Input, + } + } + /// The `data` member of a create body. #[must_use] pub fn data() -> Self { diff --git a/crates/registry-breg/src/proposal_artifacts.rs b/crates/registry-breg/src/proposal_artifacts.rs index 7aa4232485..a1c2768069 100644 --- a/crates/registry-breg/src/proposal_artifacts.rs +++ b/crates/registry-breg/src/proposal_artifacts.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 //! First-class Proposal operations derived from the compiled Action policies. use super::*; +use crate::contract::MAX_PROPOSAL_MESSAGE_COUNT; use crate::model::{CompiledActionExecution, ProposalOperation}; use crate::problem::ProblemCode; @@ -14,6 +15,12 @@ pub(crate) fn append_proposal_openapi( matches!(&action.execution, CompiledActionExecution::Proposal { proposal } if proposal.additions.is_some()) }); + let forms_enabled = actions.actions.iter().any(|action| { + matches!(&action.execution, CompiledActionExecution::Proposal { proposal } if !proposal.additional_forms.is_empty()) + }); + let mut form_profiles = BTreeSet::new(); + let mut form_inputs = Vec::new(); + let mut message_profiles = BTreeSet::new(); let mut permissions: BTreeMap, Vec)> = BTreeMap::new(); // A manual application writes as the applier, so the apply operation may @@ -44,6 +51,7 @@ pub(crate) fn append_proposal_openapi( ProposalOperation::GetApplicationActor | ProposalOperation::Add | ProposalOperation::Answer + | ProposalOperation::Message ) { continue; } @@ -231,6 +239,20 @@ pub(crate) fn append_proposal_openapi( merge_operation(paths, path.clone(), method, operation)?; } } + if permitted(ProposalOperation::Message) { + message_profiles.insert(grant.profile_id.clone()); + } + if permitted(ProposalOperation::Add) { + for id in &grant.writable_forms { + let form = &proposal.additional_forms[id]; + let schema = + additional_form_contract(&action.id, id, &form.inputs)["schema"].clone(); + if !form_inputs.contains(&schema) { + form_inputs.push(schema); + } + form_profiles.insert(grant.profile_id.clone()); + } + } if permitted(ProposalOperation::Answer) { let mut document = operation_document( "proposals.answer", @@ -243,9 +265,10 @@ pub(crate) fn append_proposal_openapi( "name":"ask_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}})); document["requestBody"] = json!({"required":true,"content":{"application/json":{"schema":{ "type":"object","additionalProperties":false, - "anyOf":[{"required":["text"]},{"required":["additions"],"properties":{"additions":{"minItems":1}}}], + "anyOf":[{"required":["text"]},{"required":["additions"],"properties":{"additions":{"minItems":1}}},{"required":["formEntries"],"properties":{"formEntries":{"minItems":1}}}], "properties":{ "text":{"type":"string","minLength":1,"maxLength":2000}, + "formEntries":{"type":"array","maxItems":32,"uniqueItems":true,"items":{"type":"string","format":"uuid"}}, "additions":{"type":"array","maxItems":32,"uniqueItems":true,"items":{"type":"string","format":"uuid"}}}}}}}); merge_operation( paths, @@ -478,9 +501,219 @@ pub(crate) fn append_proposal_openapi( } merge_operation(paths, path, method, document)?; } + if !form_profiles.is_empty() { + let mut add = operation_document( + "proposals.add-form", + "post", + &form_profiles, + false, + additions_enabled, + ); + add["parameters"].as_array_mut().expect("operation parameters").push(json!({ + "name":"form_id","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,63}$"} + })); + add["requestBody"] = json!({"required":true,"content":{"application/json":{"schema":{ + "type":"object","additionalProperties":false,"required":["input"],"properties":{"input":{"anyOf":form_inputs}} + }}}}); + merge_operation( + paths, + "/v1/proposals/{proposal_id}/additional-forms/{form_id}".to_owned(), + "post", + add, + )?; + } + if !message_profiles.is_empty() { + append_message_openapi(paths, &message_profiles, additions_enabled, forms_enabled)?; + } + if forms_enabled { + for (path, operations) in paths + .iter_mut() + .filter(|(path, _)| path.starts_with("/v1/proposals")) + { + for operation in operations + .as_object_mut() + .expect("path operations") + .values_mut() + { + let Some(schema) = + operation.pointer_mut("/responses/200/content/application~1json/schema") + else { + continue; + }; + if path == "/v1/proposals" { + if let Some(item) = schema.pointer_mut("/properties/items/items") { + append_proposal_forms_schema(item); + } + } else if schema.pointer("/properties/actionRevision").is_some() + && schema.pointer("/properties/links").is_some() + { + append_proposal_forms_schema(schema); + } else if path.ends_with("/review-context") { + if let Some(properties) = schema.pointer_mut("/properties/context/properties") { + properties["additionalForms"] = json!({"type":"object","maxProperties":8,"additionalProperties":{"type":"string"}}); + } + } + } + } + } Ok(()) } +fn append_message_openapi( + paths: &mut Map, + profiles: &BTreeSet, + additions: bool, + forms: bool, +) -> Result<(), Diagnostic> { + let path = "/v1/proposals/{proposal_id}/messages"; + let mut list = operation_document("proposals.list-messages", "get", profiles, false, additions); + list["parameters"].as_array_mut().expect("query parameters").extend([ + json!({"name":"after","in":"query","schema":{"type":"string","pattern":"^[1-9][0-9]*$"}}), + json!({"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}), + ]); + list["responses"]["200"]["content"]["application/json"]["schema"] = json!({ + "type":"object","additionalProperties":false,"required":["items","links"], + "properties":{"items":{"type":"array","maxItems":50,"items":proposal_message_schema()}, + "nextCursor":{"type":"string","pattern":"^[1-9][0-9]*$"}, + "links":proposal_messages_schema(false)["properties"]["links"].clone()} + }); + merge_operation(paths, path.to_owned(), "get", list)?; + let mut proposal = proposal_schema_with_additions(additions); + if forms { + append_proposal_forms_schema(&mut proposal); + } + proposal["properties"]["messages"] = proposal_messages_schema(false); + let mut review = review_document_schema(true); + review["properties"]["context"]["properties"]["messages"] = proposal_messages_schema(false); + if forms { + review["properties"]["context"]["properties"]["additionalForms"] = + json!({"type":"object","maxProperties":8,"additionalProperties":{"type":"string"}}); + } + for (id, suffix, member, member_schema) in [ + ( + "proposals.message", + "", + "text", + json!({"type":"string","minLength":1,"maxLength":2000,"x-maximum-utf8-bytes":2000}), + ), + ( + "proposals.mark-messages-read", + "/read", + "through", + json!({"type":"string","format":"uuid"}), + ), + ] { + let mut operation = operation_document(id, "post", profiles, false, additions); + if !suffix.is_empty() { + operation["parameters"] + .as_array_mut() + .expect("command parameters") + .retain(|parameter| parameter["in"] != "header"); + let responses = operation["responses"].as_object_mut().expect("responses"); + responses.remove("409"); + responses.remove("412"); + responses.insert( + "204".into(), + json!({"description":"The read position was recorded"}), + ); + } + operation["requestBody"] = json!({"required":true,"content":{"application/json":{"schema":{ + "type":"object","additionalProperties":false,"required":[member],"properties":{(member):member_schema} + }}}}); + // A caller without Get is answered with the review context, or with + // the thread alone while no review context is readable. + operation["responses"]["200"]["content"]["application/json"]["schema"] = + json!({"oneOf":[proposal,review,proposal_messages_schema(false)]}); + merge_operation(paths, format!("{path}{suffix}"), "post", operation)?; + } + for (path, operations) in paths + .iter_mut() + .filter(|(path, _)| path.starts_with("/v1/proposals")) + { + for operation in operations + .as_object_mut() + .expect("path operations") + .values_mut() + { + let Some(schema) = + operation.pointer_mut("/responses/200/content/application~1json/schema") + else { + continue; + }; + if path == "/v1/proposals" { + if let Some(item) = schema.pointer_mut("/properties/items/items") { + item["properties"]["messages"] = proposal_messages_schema(true); + } + } else if schema.pointer("/properties/actionRevision").is_some() + && schema.pointer("/properties/links").is_some() + { + schema["properties"]["messages"] = proposal_messages_schema(false); + } else if path.ends_with("/review-context") { + if let Some(properties) = schema.pointer_mut("/properties/context/properties") { + properties["messages"] = proposal_messages_schema(false); + } + if path == "/v1/proposals/review-context" { + if let Some(properties) = schema.pointer_mut("/properties/items/items/oneOf/0/properties/context/properties/context/properties") { + properties["messages"] = proposal_messages_schema(true); + } + } else if let Some(parameter) = + operation["parameters"] + .as_array_mut() + .and_then(|parameters| { + parameters + .iter_mut() + .find(|parameter| parameter["name"] == "include") + }) + { + parameter["schema"] = json!({"type":"array","maxItems":2,"uniqueItems":true, + "items":{"enum":["answers","messages"]}}); + parameter["style"] = json!("form"); + parameter["explode"] = json!(true); + } + } + } + } + Ok(()) +} + +fn proposal_message_schema() -> Value { + json!({"type":"object","additionalProperties":false,"required":["id","from","mine","sentAt"], + "properties":{"id":{"type":"string","format":"uuid"},"from":{"enum":["party","official"]}, + "partyRole":{"enum":["owner","subject"]},"mine":{"type":"boolean"}, + "sentAt":{"type":"string","format":"date-time"}, + "text":{"type":"string","maxLength":2000,"description":"Render the text as plain text. Escape it before placing it in HTML."}}, + "if":{"properties":{"from":{"const":"party"}}}, + "then":{"required":["partyRole"]},"else":{"not":{"required":["partyRole"]}} + }) +} + +pub(crate) fn proposal_messages_schema(summary: bool) -> Value { + let mut schema = json!({"type":"object","additionalProperties":false,"required":["count","unread"], + "properties":{"count":{"type":"integer","minimum":0,"maximum":2 * MAX_PROPOSAL_MESSAGE_COUNT}, + "unread":{"type":"integer","minimum":0,"maximum":MAX_PROPOSAL_MESSAGE_COUNT},"lastSentAt":{"type":"string","format":"date-time"}} + }); + if !summary { + schema["properties"]["items"] = + json!({"type":"array","maxItems":20,"items":proposal_message_schema()}); + let links = [("message","POST",true),("markRead","POST",false),("list","GET",false)] + .into_iter().map(|(name,method,keyed)| { + let mut link = json!({"type":"object","additionalProperties":false, + "required":["method","path","accessProfile","operation","availability"], + "properties":{"method":{"const":method},"path":{"type":"string"},"accessProfile":{"type":"string"}, + "operation":{"const":"message"},"availability":availability_schema()} + }); + if keyed { + link["required"].as_array_mut().expect("link required members").push(json!("ifMatch")); + link["properties"]["ifMatch"] = json!({"type":"string"}); + } + (name.to_owned(),link) + }).collect::>(); + schema["properties"]["links"] = + json!({"type":"object","additionalProperties":false,"properties":links}); + } + schema +} + fn task_context_request_schema() -> Value { let digest = json!({"type":"string","pattern":"^sha256:[0-9a-f]{64}$"}); json!({"type":"object","additionalProperties":false, @@ -720,6 +953,12 @@ pub(super) fn append_operation_problems(operation: &mut Value, method: &str) { ProblemCode::SourceUnavailable, ProblemCode::RequestTimeout, ]; + if id == "proposals.message" { + codes.push(ProblemCode::ProposalMessageLimitReached); + } + if id == "proposals.list-messages" { + codes.extend([ProblemCode::QueryCursorInvalid, ProblemCode::RequestInvalid]); + } if id == "proposals.list" { codes.push(ProblemCode::QueryInvalid); } @@ -729,7 +968,12 @@ pub(super) fn append_operation_problems(operation: &mut Value, method: &str) { ProblemCode::UnsupportedMediaType, ]); } - if mutation { + if id == "proposals.mark-messages-read" { + codes.extend([ + ProblemCode::RequestInvalid, + ProblemCode::UnsupportedMediaType, + ]); + } else if mutation { codes.extend([ ProblemCode::RequestInvalid, ProblemCode::PreconditionFailed, @@ -754,6 +998,12 @@ pub(super) fn append_operation_problems(operation: &mut Value, method: &str) { if addition { codes.push(ProblemCode::AttachmentLimitReached); } + if id == "proposals.add-form" { + codes.extend([ + ProblemCode::ProposalFormLimitReached, + ProblemCode::ProposalFormUndeclared, + ]); + } } if id == "proposals.get-submission" { codes.push(ProblemCode::ProposalSubmissionExpired); diff --git a/crates/registry-breg/src/proposal_ddl.rs b/crates/registry-breg/src/proposal_ddl.rs index d915c28ee5..f32fab1684 100644 --- a/crates/registry-breg/src/proposal_ddl.rs +++ b/crates/registry-breg/src/proposal_ddl.rs @@ -73,6 +73,7 @@ pub(super) fn target_policies( ProposalOperation::GetReviewContext => "get-review-context", ProposalOperation::GetTaskGrantContext => "get-task-grant-context", ProposalOperation::GetReviewStatus => "get-review-status", + ProposalOperation::Message => "message", ProposalOperation::GetApplicationActor => continue, }; add_read_policies( diff --git a/crates/registry-breg/src/proposal_events.rs b/crates/registry-breg/src/proposal_events.rs index cee46b35c5..2f83c2cd9a 100644 --- a/crates/registry-breg/src/proposal_events.rs +++ b/crates/registry-breg/src/proposal_events.rs @@ -23,6 +23,7 @@ pub(crate) struct ProposalLifecycleEvent<'a> { pub from_state: &'a str, pub state: &'a str, pub transition: &'a str, + pub message_from: Option<&'a str>, pub effect_digest: Option<&'a str>, pub authority_kind: &'a str, pub system_grant_revision: Option<&'a str>, @@ -47,6 +48,11 @@ pub(crate) async fn insert_proposal_lifecycle_event( if event.version == 0 || event.revision == 0 || event.action_id.is_empty() + || match (event.transition, event.message_from) { + ("messaged", Some("party" | "official")) => false, + ("messaged", _) | (_, Some(_)) => true, + _ => false, + } || !matches!( event.transition, "started" @@ -62,6 +68,7 @@ pub(crate) async fn insert_proposal_lifecycle_event( | "applied" | "rejected" | "review-returned" + | "messaged" ) { return Err(OutboxError::InvalidProjection); @@ -83,6 +90,14 @@ pub(crate) async fn insert_proposal_lifecycle_event( event_type.clone(), crate::proposal_hooks::PROPOSAL_EVENT_SCHEMA.to_owned(), )]); + let mut data = json!({"actionId":event.action_id,"actionRevision":event.action_revision, + "proposalId":event.proposal_id,"submissionVersion":event.version,"revision":event.revision, + "fromState":event.from_state,"state":event.state,"transition":event.transition, + "effectDigest":event.effect_digest,"authorityKind":event.authority_kind, + "systemApplyGrantRevision":event.system_grant_revision,"turn":event.turn}); + if let Some(side) = event.message_from { + data["messageFrom"] = json!(side); + } let envelope = capture_envelope( &EnvelopeBinding { source: event.source, @@ -97,11 +112,7 @@ pub(crate) async fn insert_proposal_lifecycle_event( event.reference, i64::try_from(event.revision).map_err(|_| OutboxError::Unavailable)?, ), - data: json!({"actionId":event.action_id,"actionRevision":event.action_revision, - "proposalId":event.proposal_id,"submissionVersion":event.version,"revision":event.revision, - "fromState":event.from_state,"state":event.state,"transition":event.transition, - "effectDigest":event.effect_digest,"authorityKind":event.authority_kind, - "systemApplyGrantRevision":event.system_grant_revision,"turn":event.turn}), + data, }, )?; let payload = envelope_payload( diff --git a/crates/registry-breg/src/proposal_hooks.rs b/crates/registry-breg/src/proposal_hooks.rs index 49badf3851..0325cdcc39 100644 --- a/crates/registry-breg/src/proposal_hooks.rs +++ b/crates/registry-breg/src/proposal_hooks.rs @@ -39,10 +39,14 @@ pub fn proposal_event_schema() -> Value { "submissionVersion":{"type":"integer","minimum":1,"maximum":4294967295u64}, "revision":{"type":"integer","minimum":1,"maximum":9007199254740991u64}, "fromState":{"anyOf":[states.clone(),{"const":"none"}]},"state":states, - "transition":{"type":"string","enum":["started","edited","submitted","revised","rebased","retried","cancelled","applied","rejected","review-returned","added","asked","answered"]}, + "transition":{"type":"string","enum":["started","edited","submitted","revised","rebased","retried","cancelled","applied","rejected","review-returned","added","asked","answered","messaged"]}, "effectDigest":nullable_digest.clone(),"authorityKind":{"enum":["caller","system","review"]}, "systemApplyGrantRevision":nullable_digest, - "turn":{"type":"string","enum":["party","official","nobody"]}}}) + "turn":{"type":"string","enum":["party","official","nobody"]}, + "messageFrom":{"enum":["party","official"]}}, + "if":{"properties":{"transition":{"const":"messaged"}}}, + "then":{"required":["messageFrom"]}, + "else":{"not":{"required":["messageFrom"]}}}) } pub fn source_hooks( @@ -336,6 +340,7 @@ pub fn matching_transitions( ProposalEventTransition::Added, ProposalEventTransition::Asked, ProposalEventTransition::Answered, + ProposalEventTransition::Messaged, ] .into_iter() .filter(|transition| transitions.is_empty() || transitions.contains(transition)) diff --git a/crates/registry-breg/src/proposal_messages.rs b/crates/registry-breg/src/proposal_messages.rs new file mode 100644 index 0000000000..daed6a1ffe --- /dev/null +++ b/crates/registry-breg/src/proposal_messages.rs @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The message thread on one Proposal: text between its party (the owner or +//! the subject) and the office. The caller's admission decides the side a +//! message is written from; nothing here reads a token. Text leaves this +//! store only in a served document, never in an event, audit entry or log. + +use serde_json::{json, Value}; +use tokio_postgres::Transaction; +use uuid::Uuid; + +use crate::model::ProposalParty; +use crate::mutation::MutationError; + +/// The longest message, in UTF-8 bytes: the limit of answers and Casework notes. +pub(crate) const MAX_TEXT_BYTES: usize = 2000; +/// The newest messages a Proposal document carries. +pub(crate) const DOCUMENT_ITEMS: i64 = 20; +/// The most messages one page of the thread carries. +pub(crate) const MAX_PAGE_ITEMS: i64 = 50; + +/// The side of the thread a message is written from or read by. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) enum Side { + Party, + Official, +} + +impl Side { + /// A party-bound entry writes and reads as the party; any other grant + /// as the office. The writer does not choose. + pub(crate) fn of(party: Option) -> Self { + if party.is_some() { + Self::Party + } else { + Self::Official + } + } + + pub(crate) const fn as_str(self) -> &'static str { + match self { + Self::Party => "party", + Self::Official => "official", + } + } + + const fn read_position_column(self) -> &'static str { + match self { + Self::Party => "party_read_position", + Self::Official => "official_read_position", + } + } +} + +/// Text a person can read as written: not empty, within the byte limit, and +/// free of control characters other than line breaks and tabs, of the +/// characters that reorder how text displays, and of characters that do not +/// display at all. A carriage return is kept only before a line feed, as a +/// form post sends a line break. +pub(crate) fn valid_text(text: &str) -> bool { + let mut characters = text.chars().peekable(); + while let Some(character) = characters.next() { + let allowed = match character { + '\r' => characters.peek() == Some(&'\n'), + '\n' | '\t' => true, + _ => !character.is_control() && !hidden_or_reordering(character), + }; + if !allowed { + return false; + } + } + !text.trim().is_empty() && text.len() <= MAX_TEXT_BYTES +} + +/// Characters that reorder text, take no visible space, or carry hidden +/// tags, so a reader cannot see what was written. +fn hidden_or_reordering(character: char) -> bool { + matches!( + character, + '\u{061C}' + | '\u{200B}'..='\u{200F}' + | '\u{2028}'..='\u{202E}' + | '\u{2060}'..='\u{2064}' + | '\u{2066}'..='\u{2069}' + | '\u{FEFF}' + | '\u{E0000}'..='\u{E007F}' + ) +} + +/// Whether the thread has opened: it opens at the first Submit. +pub(crate) async fn opened( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, +) -> Result { + tx.query_one( + "SELECT EXISTS (SELECT 1 FROM registry_internal.registry_proposal_submissions + WHERE action_id=$1 AND proposal_id=$2)", + &[&action_id, &proposal_id], + ) + .await + .map(|row| row.get(0)) + .map_err(|_| MutationError::Unavailable) +} + +/// The number of messages one side has written. Each side has its own +/// share of the Action's `maximumCount`, so neither can close the thread +/// for the other. +pub(crate) async fn count( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, + side: Side, +) -> Result { + tx.query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_messages + WHERE action_id=$1 AND proposal_id=$2 AND side=$3", + &[&action_id, &proposal_id, &side.as_str()], + ) + .await + .map(|row| row.get(0)) + .map_err(|_| MutationError::Unavailable) +} + +/// One message to append. The caller holds the Proposal's state row lock. +pub(crate) struct NewMessage<'a> { + pub action_id: &'a str, + pub proposal_id: Uuid, + pub submission_version: i64, + pub side: Side, + pub party_role: Option, + pub sent_by: &'a str, + pub text: &'a str, + pub maximum_count: u32, +} + +pub(crate) async fn append( + tx: &Transaction<'_>, + message: NewMessage<'_>, +) -> Result { + if !valid_text(message.text) { + return Err(MutationError::InvalidRequestAt( + crate::problem_location::RequestLocation::proposal_message_text(), + )); + } + if count(tx, message.action_id, message.proposal_id, message.side).await? + >= i64::from(message.maximum_count) + { + return Err(MutationError::ProposalMessageLimitReached); + } + let id = Uuid::new_v4(); + let party_role = match (message.side, message.party_role) { + (Side::Party, Some(ProposalParty::Owner)) => Some("owner"), + (Side::Party, Some(ProposalParty::Subject)) => Some("subject"), + (Side::Official, None) => None, + _ => return Err(MutationError::InvalidRequest), + }; + tx.execute( + "INSERT INTO registry_internal.registry_proposal_messages + (action_id,proposal_id,message_id,position,submission_version,side,party_role,sent_by,text) + SELECT $1,$2,$3,COALESCE(max(position),0)+1,$4,$5,$6,$7,$8 + FROM registry_internal.registry_proposal_messages + WHERE action_id=$1 AND proposal_id=$2", + &[ + &message.action_id, + &message.proposal_id, + &id, + &message.submission_version, + &message.side.as_str(), + &party_role, + &message.sent_by, + &message.text, + ], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + Ok(id) +} + +/// What one side sees of the thread without its text. +pub(crate) struct Summary { + pub count: i64, + pub unread: i64, + pub last_sent_at: Option, +} + +impl Summary { + pub(crate) fn to_json(&self) -> Value { + let mut value = json!({"count":self.count,"unread":self.unread}); + if let Some(last) = &self.last_sent_at { + value["lastSentAt"] = json!(last); + } + value + } +} + +/// `unread` counts the other side's messages past the reader's side position. +pub(crate) async fn summary( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, + reader: Side, +) -> Result { + let row = tx + .query_one( + &format!( + "SELECT count(m.message_id), + count(m.message_id) FILTER (WHERE m.side<>$3 AND m.position>s.{}), + to_char(max(m.sent_at) AT TIME ZONE 'UTC','YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"') + FROM registry_internal.registry_proposal_state s + LEFT JOIN registry_internal.registry_proposal_messages m + ON m.action_id=s.action_id AND m.proposal_id=s.proposal_id + WHERE s.action_id=$1 AND s.proposal_id=$2", + reader.read_position_column() + ), + &[&action_id, &proposal_id, &reader.as_str()], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + Ok(Summary { + count: row.get(0), + unread: row.get(1), + last_sent_at: row.get(2), + }) +} + +/// The newest messages before `before` (a position), newest first. Each +/// item says whether `reader` wrote it; it never names who did. +pub(crate) async fn page( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, + before: Option, + limit: i64, + reader: &str, +) -> Result, MutationError> { + let rows = tx + .query( + "SELECT message_id,position,side,party_role,sent_by,text, + to_char(sent_at AT TIME ZONE 'UTC','YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"') + FROM registry_internal.registry_proposal_messages + WHERE action_id=$1 AND proposal_id=$2 AND ($3::bigint IS NULL OR position<$3) + ORDER BY position DESC LIMIT $4", + &[&action_id, &proposal_id, &before, &limit], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + Ok(rows + .iter() + .map(|row| (row.get(1), message_item(row, reader))) + .collect()) +} + +/// Check retained items outside the newest-items window of an admitted thread. +pub(crate) async fn receipt_items_match( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, + items: &[Value], + reader: &str, +) -> Result { + let Some(ids) = items + .iter() + .map(|item| item.get("id")?.as_str()?.parse::().ok()) + .collect::>>() + else { + return Ok(false); + }; + let rows = tx + .query( + "SELECT message_id,position,side,party_role,sent_by,text, + to_char(sent_at AT TIME ZONE 'UTC','YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"') + FROM registry_internal.registry_proposal_messages + WHERE action_id=$1 AND proposal_id=$2 AND message_id=ANY($3) + ORDER BY position DESC", + &[&action_id, &proposal_id, &ids], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + Ok(rows.len() == items.len() + && rows + .iter() + .zip(items) + .all(|(row, item)| message_item(row, reader) == *item)) +} + +fn message_item(row: &tokio_postgres::Row, reader: &str) -> Value { + let mut item = json!({"id":row.get::<_, Uuid>(0),"from":row.get::<_, String>(2), + "mine":row.get::<_, Option>(4).as_deref()==Some(reader),"sentAt":row.get::<_, String>(6)}); + if let Some(role) = row.get::<_, Option>(3) { + item["partyRole"] = json!(role); + } + // An erased message keeps its place and loses its text. + if let Some(text) = row.get::<_, Option>(5) { + item["text"] = json!(text); + } + item +} + +/// Move `reader`'s side forward through the message `through`. Returns +/// whether the position moved; reading again, or backwards, changes nothing. +/// The caller holds the Proposal's state row lock. +pub(crate) async fn mark_read( + tx: &Transaction<'_>, + action_id: &str, + proposal_id: Uuid, + reader: Side, + through: Uuid, +) -> Result { + let position: i64 = tx + .query_opt( + "SELECT position FROM registry_internal.registry_proposal_messages + WHERE action_id=$1 AND proposal_id=$2 AND message_id=$3", + &[&action_id, &proposal_id, &through], + ) + .await + .map_err(|_| MutationError::Unavailable)? + .ok_or_else(|| { + MutationError::InvalidRequestAt( + crate::problem_location::RequestLocation::proposal_message_through(), + ) + })? + .get(0); + let column = reader.read_position_column(); + let changed = tx + .execute( + &format!( + "UPDATE registry_internal.registry_proposal_state SET {column}=$3 + WHERE action_id=$1 AND proposal_id=$2 AND {column}<$3" + ), + &[&action_id, &proposal_id, &position], + ) + .await + .map_err(|_| MutationError::Unavailable)?; + Ok(changed == 1) +} + +/// Correlated with the Proposal row `p`: an office message the party has +/// not read. While the Proposal is open this makes it the party's turn. +pub(crate) const PARTY_UNREAD_SQL: &str = "EXISTS ( + SELECT 1 FROM registry_internal.registry_proposal_messages m + WHERE m.action_id=p.action_id AND m.proposal_id=p.proposal_id + AND m.side='official' AND m.position>p.party_read_position)"; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn text_is_readable_as_written_and_bounded_in_utf8_bytes() { + assert!(valid_text("Is a scan enough?\nThanks.")); + assert!(valid_text("bold & ")); + assert!(valid_text(&"\u{e9}".repeat(1000))); + assert!(!valid_text(&"\u{e9}".repeat(1001))); + assert!(!valid_text("")); + assert!(!valid_text(" \n ")); + assert!(!valid_text("Bell \u{0007}")); + for reordering in ['\u{202E}', '\u{2066}', '\u{200F}', '\u{061C}'] { + assert!(!valid_text(&format!("Reordered {reordering}text"))); + } + } +} diff --git a/crates/registry-breg/src/proposal_retention.rs b/crates/registry-breg/src/proposal_retention.rs index 6fc96623d5..d134bb9b13 100644 --- a/crates/registry-breg/src/proposal_retention.rs +++ b/crates/registry-breg/src/proposal_retention.rs @@ -145,6 +145,9 @@ pub struct ProposalDetailErasure { pub review_asks: u64, pub review_answers: u64, pub review_answer_files: u64, + pub messages: u64, + pub form_entries: u64, + pub review_answer_form_entries: u64, } #[derive(Clone, Debug, Eq, PartialEq, Serialize)] @@ -1251,6 +1254,94 @@ async fn load_erasure_plan( }) } +// A later round's response can include the earlier thread. Erase that +// exact receipt as well when its stored body contains text from this version. +// The message ID still identifies the round after its live text is erased. +const DETAIL_RECEIPT_KEYS: &str = " + SELECT l.key_reference + FROM registry_internal.registry_proposal_idempotency_links l + WHERE l.action_id=$1 AND l.proposal_id=$2 + AND (l.submission_version=$3 OR EXISTS ( + SELECT 1 FROM registry_internal.registry_proposal_messages m + WHERE m.action_id=$1 AND m.proposal_id=$2 + AND m.submission_version=$3 + AND jsonb_path_exists( + coalesce( + convert_from(receipt.response_body,'UTF8')::jsonb #> '{messages,items}', + convert_from(receipt.response_body,'UTF8')::jsonb #> '{context,messages,items}', + convert_from(receipt.response_body,'UTF8')::jsonb #> '{items}' + ), + '$[*] ? (@.id == $id && exists(@.text))', + jsonb_build_object('id',m.message_id) + ) + ))"; + +#[cfg(all(test, feature = "postgres-test"))] +mod receipt_erasure_tests { + use super::*; + use serde_json::json; + + #[tokio::test] + async fn message_receipt_erasure_covers_each_document_shape() { + let url = std::env::var("BREG_TEST_DATABASE_URL") + .expect("BREG_TEST_DATABASE_URL is required for erasure selection"); + let (client, connection) = tokio_postgres::connect(&url, tokio_postgres::NoTls) + .await + .expect("connect to disposable PostgreSQL"); + let connection = tokio::spawn(connection); + let message = Uuid::from_u128(1); + let item = json!({"id":message,"text":"example"}); + let receipts = json!({ + "proposal":{"version":2,"body":{"messages":{"items":[item]}}}, + "review":{"version":2,"body":{"context":{"messages":{"items":[item]}}}}, + "thread":{"version":2,"body":{"count":1,"items":[item]}}, + "textless":{"version":2,"body":{"count":1,"items":[{"id":message}]}}, + "unrelated":{"version":2,"body":{"count":1,"items":[{"id":Uuid::from_u128(2),"text":"example"}]}}, + "scoped":{"version":1,"body":{"state":"submitted"}} + }); + // Use the production selector over synthetic rows without creating or + // updating a registry. Repeat it with the source text already erased. + let selector = DETAIL_RECEIPT_KEYS.replace("registry_internal.", ""); + let query = format!( + "WITH registry_proposal_messages(action_id, proposal_id, submission_version, message_id, text) AS ( + VALUES ($1::text, $2::uuid, $3::bigint, $4::uuid, $5::text) + ), receipts AS ( + SELECT key AS key_reference, convert_to((value->'body')::text,'UTF8') AS response_body, + (value->>'version')::bigint AS submission_version + FROM jsonb_each($6) + ), registry_proposal_idempotency_links AS ( + SELECT key_reference, $1 AS action_id, $2 AS proposal_id, submission_version + FROM receipts + ) + SELECT key_reference FROM receipts receipt + WHERE key_reference IN ({selector}) ORDER BY key_reference" + ); + for text in [Some("example"), None] { + let rows = client + .query( + &query, + &[ + &"synthetic", + &Uuid::from_u128(3), + &1_i64, + &message, + &text, + &receipts, + ], + ) + .await + .expect("evaluate receipt erasure selection"); + let keys = rows + .iter() + .map(|row| row.get::<_, &str>(0)) + .collect::>(); + assert_eq!(keys, ["proposal", "review", "scoped", "thread"]); + } + drop(client); + connection.await.unwrap().unwrap(); + } +} + async fn count_request_detail_erasure( transaction: &tokio_postgres::Transaction<'_>, scope: ProposalDetailErasureScope<'_>, @@ -1258,7 +1349,7 @@ async fn count_request_detail_erasure( ) -> Result { let row = transaction .query_one( - "SELECT + &format!("SELECT (SELECT count(*) FROM registry_internal.registry_proposal_submissions WHERE action_id = $1 AND proposal_id = $2 @@ -1269,15 +1360,8 @@ async fn count_request_detail_erasure( AND proposal_id = $2 AND submission_version = $3 AND (base_snapshot IS NOT NULL OR after_snapshot IS NOT NULL)), - (SELECT count(*) FROM registry_internal.registry_idempotency - WHERE key_reference IN ( - SELECT key_reference - FROM registry_internal.registry_proposal_idempotency_links - WHERE action_id = $1 - AND proposal_id = $2 - AND submission_version = $3 - ) - AND response_body IS NOT NULL), + (SELECT count(*) FROM registry_internal.registry_idempotency receipt + WHERE response_body IS NOT NULL AND key_reference IN ({DETAIL_RECEIPT_KEYS})), (SELECT count(*) FROM registry_internal.registry_proposal_applications WHERE action_id = $1 AND proposal_id = $2 @@ -1292,7 +1376,7 @@ async fn count_request_detail_erasure( (SELECT count(*) FROM registry_internal.registry_proposal_review_submissions s WHERE s.action_id=$1 AND s.proposal_id=$2 AND s.submission_version=$3 - AND s.create_request <> '{}'::jsonb + AND s.create_request <> '{{}}'::jsonb AND (s.state IN ('cancelled','failed') OR ( s.state='accepted' AND EXISTS ( SELECT 1 @@ -1306,7 +1390,7 @@ async fn count_request_detail_erasure( FROM registry_internal.registry_proposal_review_submissions s WHERE s.action_id=$1 AND s.proposal_id=$2 AND s.submission_version=$3 AND s.accepted_binding IS NOT NULL - AND s.accepted_binding <> '{}'::jsonb + AND s.accepted_binding <> '{{}}'::jsonb AND (s.state IN ('cancelled','failed') OR ( s.state='accepted' AND EXISTS ( SELECT 1 @@ -1318,10 +1402,13 @@ async fn count_request_detail_erasure( ))), (SELECT count(*) FROM registry_internal.registry_proposal_review_results WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 - AND result <> '{}'::jsonb), + AND result <> '{{}}'::jsonb), (SELECT count(*) FROM registry_internal.registry_proposal_review_asks WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND text IS NOT NULL), (SELECT count(*) FROM registry_internal.registry_proposal_review_ask_answers WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL), - (SELECT count(*) FROM registry_internal.registry_proposal_review_ask_files WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3)", + (SELECT count(*) FROM registry_internal.registry_proposal_review_ask_files WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3), + (SELECT count(*) FROM registry_internal.registry_proposal_form_entries WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL), + (SELECT count(*) FROM registry_internal.registry_proposal_review_ask_form_entries WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3), + (SELECT count(*) FROM registry_internal.registry_proposal_messages WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL)"), &[ &scope.action_id, &scope.proposal_id, @@ -1343,6 +1430,9 @@ async fn count_request_detail_erasure( review_asks: count_to_u64(row.get(8))?, review_answers: count_to_u64(row.get(9))?, review_answer_files: count_to_u64(row.get(10))?, + form_entries: count_to_u64(row.get(11))?, + review_answer_form_entries: count_to_u64(row.get(12))?, + messages: count_to_u64(row.get(13))?, }) } @@ -1369,6 +1459,24 @@ async fn erase_proposal_detail_in_transaction( .map_err(map_retention_error)?; // Remove citation references with their source-owned answer detail before // attachment erasure considers whether any bytes are still referenced. + let version = &[ + &scope.action_id as &(dyn tokio_postgres::types::ToSql + Sync), + &scope.proposal_id, + &scope.submission_version, + ]; + let review_answer_form_entries = transaction + .execute( + "DELETE FROM registry_internal.registry_proposal_review_ask_form_entries + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3", + version, + ) + .await + .map_err(map_retention_error)?; + let form_entries = transaction.execute( + "UPDATE registry_internal.registry_proposal_form_entries + SET input=NULL, added_by=NULL, detail_erased_at=transaction_timestamp() + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL", version, + ).await.map_err(map_retention_error)?; let review_answer_files=transaction.execute("DELETE FROM registry_internal.registry_proposal_review_ask_files WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3",&[&scope.action_id,&scope.proposal_id,&scope.submission_version]).await.map_err(map_retention_error)?; let review_answers=transaction.execute("UPDATE registry_internal.registry_proposal_review_ask_answers SET text=NULL,answered_by=NULL,detail_erased_at=transaction_timestamp(),claim_token=NULL,lease_until=NULL,delivery_state=CASE WHEN delivery_state='pending' THEN 'superseded' ELSE delivery_state END WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL",&[&scope.action_id,&scope.proposal_id,&scope.submission_version]).await.map_err(map_retention_error)?; let review_asks=transaction.execute("UPDATE registry_internal.registry_proposal_review_asks SET text=NULL,detail_erased_at=transaction_timestamp() WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND text IS NOT NULL",&[&scope.action_id,&scope.proposal_id,&scope.submission_version]).await.map_err(map_retention_error)?; @@ -1495,25 +1603,21 @@ async fn erase_proposal_detail_in_transaction( .map_err(map_retention_error)?; let idempotency_results = transaction .execute( - "UPDATE registry_internal.registry_idempotency - SET response_body = NULL, - erased_at = transaction_timestamp() - WHERE key_reference IN ( - SELECT key_reference - FROM registry_internal.registry_proposal_idempotency_links - WHERE action_id = $1 - AND proposal_id = $2 - AND submission_version = $3 - ) - AND response_body IS NOT NULL", - &[ - &scope.action_id, - &scope.proposal_id, - &scope.submission_version, - ], + &format!( + "UPDATE registry_internal.registry_idempotency receipt + SET response_body=NULL,erased_at=transaction_timestamp() + WHERE response_body IS NOT NULL AND key_reference IN ({DETAIL_RECEIPT_KEYS})" + ), + version, ) .await .map_err(map_retention_error)?; + let messages = transaction.execute( + "UPDATE registry_internal.registry_proposal_messages + SET text=NULL,sent_by=NULL,detail_erased_at=transaction_timestamp() + WHERE action_id=$1 AND proposal_id=$2 AND submission_version=$3 AND detail_erased_at IS NULL", + version, + ).await.map_err(map_retention_error)?; let draft_inputs = if plan.erase_draft_input { transaction .execute( @@ -1549,6 +1653,9 @@ async fn erase_proposal_detail_in_transaction( review_asks, review_answers, review_answer_files, + form_entries, + review_answer_form_entries, + messages, }; if erasure != plan.erasure { return Err(ProposalRetentionError::Unavailable); @@ -1637,6 +1744,9 @@ fn retention_terminal_entry( .and_then(|count| count.checked_add(erasure.review_asks)) .and_then(|count| count.checked_add(erasure.review_answers)) .and_then(|count| count.checked_add(erasure.review_answer_files)) + .and_then(|count| count.checked_add(erasure.messages)) + .and_then(|count| count.checked_add(erasure.form_entries)) + .and_then(|count| count.checked_add(erasure.review_answer_form_entries)) .ok_or(ProposalRetentionError::Unavailable)?; terminal_entry( profile, diff --git a/crates/registry-breg/src/proposal_store.rs b/crates/registry-breg/src/proposal_store.rs index 4f3cdd7a2f..0f8e69c605 100644 --- a/crates/registry-breg/src/proposal_store.rs +++ b/crates/registry-breg/src/proposal_store.rs @@ -33,6 +33,7 @@ pub(crate) const PROPOSAL_TABLES: &[(&str, &[&str])] = &[ ("registry_proposal_evidence_uses", &["INSERT"]), ("registry_proposal_results", &["INSERT", "SELECT"]), ("registry_proposal_idempotency_links", &["INSERT", "SELECT"]), + ("registry_proposal_messages", &["INSERT", "SELECT"]), ]; pub(crate) async fn install( @@ -236,6 +237,30 @@ pub(crate) async fn install( CREATE INDEX IF NOT EXISTS registry_proposal_idempotency_by_request ON registry_internal.registry_proposal_idempotency_links (action_id, proposal_id, submission_version); + ALTER TABLE registry_internal.registry_proposal_state + ADD COLUMN IF NOT EXISTS party_read_position bigint NOT NULL DEFAULT 0 + CHECK (party_read_position >= 0), + ADD COLUMN IF NOT EXISTS official_read_position bigint NOT NULL DEFAULT 0 + CHECK (official_read_position >= 0); + CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_messages ( + action_id text NOT NULL, + proposal_id uuid NOT NULL, + message_id uuid NOT NULL, + position bigint NOT NULL CHECK (position > 0), + submission_version bigint NOT NULL CHECK (submission_version > 0), + side text NOT NULL CHECK (side IN ('party','official')), + party_role text CHECK (party_role IS NULL OR party_role IN ('owner','subject')), + sent_by text CHECK (sent_by IS NULL OR sent_by <> ''), + text text CHECK (text IS NULL OR octet_length(text) BETWEEN 1 AND 2000), + sent_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + detail_erased_at timestamptz, + PRIMARY KEY (action_id, proposal_id, message_id), + UNIQUE (action_id, proposal_id, position), + FOREIGN KEY (action_id, proposal_id) + REFERENCES registry_internal.registry_proposal_state, + CHECK ((side = 'party') = (party_role IS NOT NULL)), + CHECK ((text IS NULL) = (detail_erased_at IS NOT NULL)) + ); " ).await.map_err(|_| MutationError::Unavailable)?; crate::attachment_store::install(client, runtime_role).await?; @@ -558,6 +583,8 @@ pub(crate) struct ProposalDocument { pub input_targets: Vec<(String, Uuid)>, pub blocked_reason: Option, pub ask_open: bool, + /// An office message on the thread the party has not read. + pub party_message_unread: bool, /// When the draft was started, as RFC 3339 UTC text. pub created_at: String, pub header: ProposalWorkflowHeader, @@ -595,9 +622,11 @@ pub(crate) async fn load_document_with_ask( let sql = format!( "SELECT action_id, action_revision, action_title, input, blocked_reason, input_targets, to_char(created_at AT TIME ZONE 'UTC','YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"'), - CASE WHEN $2::bigint=p.workflow_revision THEN $3::boolean ELSE ({OPEN_ASK_SQL}) END - FROM registry_internal.registry_proposal_state p WHERE proposal_id=$1{}", - match lock { + CASE WHEN $2::bigint=p.workflow_revision THEN $3::boolean ELSE ({OPEN_ASK_SQL}) END, + {PARTY_UNREAD_SQL} + FROM registry_internal.registry_proposal_state p WHERE proposal_id=$1{lock}", + PARTY_UNREAD_SQL = crate::proposal_messages::PARTY_UNREAD_SQL, + lock = match lock { DocumentLock::None => "", DocumentLock::Share => " FOR SHARE", DocumentLock::Update => " FOR UPDATE", @@ -630,6 +659,7 @@ pub(crate) async fn load_document_with_ask( blocked_reason: row.get(4), created_at: row.get(6), ask_open: row.get(7), + party_message_unread: row.get(8), header, input_targets: serde_json::from_value(row.get(5)) .map_err(|_| MutationError::Unavailable)?, diff --git a/crates/registry-breg/src/proposal_workflow.rs b/crates/registry-breg/src/proposal_workflow.rs index 04a02bc258..8a551fc63c 100644 --- a/crates/registry-breg/src/proposal_workflow.rs +++ b/crates/registry-breg/src/proposal_workflow.rs @@ -292,6 +292,23 @@ impl ProposalWorkflow { Ok(transition) } + /// Record a message on the thread, or one side reading it, without + /// changing the submission. The thread is open while the Proposal is. + pub fn record_message( + mut self, + _context: TrustedTransitionContext, + ) -> Result { + self.refuse_rejected()?; + if !matches!(self.state, ProposalState::Draft | ProposalState::Submitted) { + return Err(WorkflowError::InvalidTransition); + } + self.workflow_revision = self.workflow_revision.next()?; + Ok(WorkflowTransition { + workflow: self, + effect: TransitionEffect::Messaged, + }) + } + /// Records the review authority's rejection of the current submission. /// A rejection is terminal: the review policy's changes-requested outcome, /// not this state, is how a reviewer allows another attempt. @@ -1740,6 +1757,7 @@ pub enum TransitionEffect { Asked, AskChanged, Answered, + Messaged, RetryScheduled, Submitted { version: SubmissionVersion, @@ -2374,6 +2392,7 @@ impl fmt::Debug for TransitionEffect { Self::Asked => formatter.write_str("Asked"), Self::AskChanged => formatter.write_str("AskChanged"), Self::Answered => formatter.write_str("Answered"), + Self::Messaged => formatter.write_str("Messaged"), Self::RetryScheduled => formatter.write_str("RetryScheduled"), Self::Submitted { version, .. } => formatter .debug_struct("Submitted") diff --git a/crates/registry-breg/src/review_store.rs b/crates/registry-breg/src/review_store.rs index 8eb1b5c6a2..fa0fe1d7be 100644 --- a/crates/registry-breg/src/review_store.rs +++ b/crates/registry-breg/src/review_store.rs @@ -1669,6 +1669,11 @@ pub(crate) const REVIEW_TABLES: &[(&str, &[&str])] = &[ "registry_proposal_review_ask_answers", &["INSERT", "SELECT", "UPDATE"], ), + ("registry_proposal_form_entries", &["INSERT", "SELECT"]), + ( + "registry_proposal_review_ask_form_entries", + &["INSERT", "SELECT"], + ), ("registry_proposal_review_ask_files", &["INSERT", "SELECT"]), ( "registry_proposal_review_ask_feed_events", diff --git a/crates/registry-breg/src/review_store/asks.rs b/crates/registry-breg/src/review_store/asks.rs index 321453e26c..805ce97c85 100644 --- a/crates/registry-breg/src/review_store/asks.rs +++ b/crates/registry-breg/src/review_store/asks.rs @@ -66,6 +66,40 @@ pub(super) async fn install(client: &impl GenericClient) -> Result<(), MutationE CREATE INDEX IF NOT EXISTS registry_proposal_review_ask_answer_jobs ON registry_internal.registry_proposal_review_ask_answers(next_attempt_at,answered_at) WHERE delivery_state='pending'; + CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_form_entries ( + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL, + form_id text NOT NULL, + entry_id uuid NOT NULL, + input jsonb CHECK (jsonb_typeof(input)='object'), + contract_digest text NOT NULL, + added_by text, + added_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + detail_erased_at timestamptz, + PRIMARY KEY (action_id,proposal_id,submission_version,entry_id), + FOREIGN KEY (action_id,proposal_id,submission_version) + REFERENCES registry_internal.registry_proposal_review_submissions, + CHECK ((detail_erased_at IS NULL) = (input IS NOT NULL)) + ); + CREATE INDEX IF NOT EXISTS registry_proposal_form_entries_form + ON registry_internal.registry_proposal_form_entries + (action_id,proposal_id,submission_version,form_id); + CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_form_entries ( + authority text NOT NULL, + review_request_id uuid NOT NULL, + ask_id uuid NOT NULL, + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL, + entry_id uuid NOT NULL, + PRIMARY KEY (action_id,proposal_id,submission_version,entry_id), + FOREIGN KEY (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) + REFERENCES registry_internal.registry_proposal_review_ask_answers + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version), + FOREIGN KEY (action_id,proposal_id,submission_version,entry_id) + REFERENCES registry_internal.registry_proposal_form_entries + ); CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_files ( authority text NOT NULL, review_request_id uuid NOT NULL, @@ -129,6 +163,8 @@ pub(crate) struct AnswerBody { pub(crate) text: Option, #[serde(default)] pub(crate) additions: Vec, + #[serde(default, rename = "formEntries", skip_serializing_if = "Vec::is_empty")] + pub(crate) form_entries: Vec, } #[derive(serde::Serialize)] @@ -168,7 +204,21 @@ impl AnswerBody { { return Err("additions"); } - if self.text.is_none() && self.additions.is_empty() { + let distinct = self + .form_entries + .iter() + .collect::>(); + if self.form_entries.len() > 32 + || distinct.len() != self.form_entries.len() + || self.form_entries.iter().any(Uuid::is_nil) + || (self.form_entries.is_empty() + && wants + .iter() + .any(|want| matches!(want, registry_review_client::ReviewAskWant::Form { .. }))) + { + return Err("formEntries"); + } + if self.text.is_none() && self.additions.is_empty() && self.form_entries.is_empty() { return Err("text"); } Ok(()) @@ -216,12 +266,14 @@ mod tests { let body = AnswerBody { text, additions: vec![], + form_entries: Vec::new(), }; assert_eq!(body.validate(&wants), Err("text")); } let body = AnswerBody { text: Some("A multiline\nanswer".to_owned()), additions: vec![], + form_entries: Vec::new(), }; assert_eq!(body.validate(&wants), Ok(())); assert!(serde_json::from_value::(json!({"other":"private"})).is_err()); @@ -232,20 +284,23 @@ mod tests { assert_eq!( AnswerBody { text: None, - additions: vec![] + additions: vec![], + form_entries: vec![], } .validate(&[]), Err("text") ); assert!(AnswerBody { text: Some("explanation".into()), - additions: vec![] + additions: vec![], + form_entries: vec![], } .validate(&[]) .is_ok()); assert!(AnswerBody { text: None, - additions: vec![Uuid::new_v4()] + additions: vec![Uuid::new_v4()], + form_entries: vec![], } .validate(&[]) .is_ok()); @@ -264,7 +319,8 @@ mod tests { assert_eq!( AnswerBody { text: None, - additions + additions, + form_entries: vec![], } .validate(&wants), Err("additions") @@ -273,7 +329,8 @@ mod tests { assert_eq!( AnswerBody { text: None, - additions: vec![id] + additions: vec![id], + form_entries: vec![], } .validate(&wants), Ok(()) @@ -281,7 +338,8 @@ mod tests { assert_eq!( AnswerBody { text: None, - additions: vec![] + additions: vec![], + form_entries: vec![], } .validate(&[]), Err("text") diff --git a/crates/registry-breg/src/startup.rs b/crates/registry-breg/src/startup.rs index ecaccfdd3c..b1dcc77000 100644 --- a/crates/registry-breg/src/startup.rs +++ b/crates/registry-breg/src/startup.rs @@ -2650,7 +2650,7 @@ pub async fn serve_until_shutdown( BackgroundTask::AttachmentVerificationWorker, worker.run(worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut record_timer_worker = record_timer_worker.map(|worker| { @@ -2658,7 +2658,7 @@ pub async fn serve_until_shutdown( BackgroundTask::RecordTimerWorker, worker.run(worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut review_worker = review_worker.map(|worker| { @@ -2666,7 +2666,7 @@ pub async fn serve_until_shutdown( BackgroundTask::ReviewWorker, worker.run(worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut evidence_worker = evidence_retention.map(|worker| { @@ -2674,7 +2674,7 @@ pub async fn serve_until_shutdown( BackgroundTask::EvidenceRetention, worker.run(worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut external_projection_worker = @@ -2683,7 +2683,7 @@ pub async fn serve_until_shutdown( BackgroundTask::ExternalProjectionRetention, backend.run_retention(last_success, worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut external_refresh_worker = external_refresh.map(|(service, last_success)| { @@ -2695,7 +2695,7 @@ pub async fn serve_until_shutdown( worker_shutdown_rx.clone(), ), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut access_log_worker = access_log_retention.map(|(pool, last_success)| { @@ -2707,7 +2707,7 @@ pub async fn serve_until_shutdown( worker_shutdown_rx.clone(), ), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let mut worker = hook_worker.map(|worker| { @@ -2715,7 +2715,7 @@ pub async fn serve_until_shutdown( BackgroundTask::HookWorker, worker.run(worker_shutdown_rx.clone()), worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); let (shutdown_tx, shutdown_rx) = oneshot::channel::<()>(); @@ -2731,7 +2731,7 @@ pub async fn serve_until_shutdown( .await }, worker_shutdown_rx.clone(), - task_stopped_tx.clone(), + Some(task_stopped_tx.clone()), ) }); // Only the supervisors hold senders, so the stop branch below is disabled @@ -2843,10 +2843,9 @@ enum ServeExit { TaskStopped, } -/// One background task `serve` owns. The task runs under a supervisor that -/// reports how it ended; serve cancels the task itself and joins the -/// supervisor, so a joined supervisor means the task has stopped too. -struct SupervisedTask { +/// One owned background task. The supervisor reports how it ended. Joining +/// the supervisor also proves the task stopped. +pub(crate) struct SupervisedTask { task: BackgroundTask, supervisor: tokio::task::JoinHandle<()>, cancel: tokio::task::AbortHandle, @@ -2855,16 +2854,15 @@ struct SupervisedTask { impl SupervisedTask { /// Run `future` under a supervisor. A panic is always reported. A return - /// before `shutdown` turns true is reported and sent on `stopped`, which - /// ends serve; a return after it is the requested stop. Only the shutdown - /// grace timeout cancels a task, and serve reports that timeout itself. + /// before `shutdown` turns true is reported and sent to the optional + /// owner notification channel. A return after it is the requested stop. /// A task's own output, such as the metrics listener's accept error, /// counts as a return. - fn spawn( + pub(crate) fn spawn( task: BackgroundTask, future: F, shutdown: watch::Receiver, - stopped: mpsc::UnboundedSender, + stopped: Option>, ) -> Self where F: Future + Send + 'static, @@ -2883,10 +2881,9 @@ impl SupervisedTask { return; } OperationalEvent::BackgroundTaskStopped(task, stop).emit(); - if !requested { - // serve holds the receiver until it has joined every - // supervisor, so a refused send means serve is already - // stopping and has nothing left to end. + if let Some(stopped) = stopped.filter(|_| !requested) { + // Serve holds the receiver until its supervisors join. + // A refused send means serve is already stopping. let _ = stopped.send(task); } }); @@ -2900,7 +2897,7 @@ impl SupervisedTask { /// Wait for the supervisor once. A supervisor that panicked is reported /// as its task panicking. - async fn join(&mut self) { + pub(crate) async fn join(&mut self) { if self.joined { return; } @@ -2911,12 +2908,18 @@ impl SupervisedTask { } } - async fn abort_and_join(&mut self) { + pub(crate) async fn abort_and_join(&mut self) { self.cancel.abort(); self.join().await; } } +impl Drop for SupervisedTask { + fn drop(&mut self) { + self.cancel.abort(); + } +} + /// Install the stop-signal handlers with `install`. A failure refuses startup /// with [`StartupError::Shutdown`], so the runtime never serves with no way to /// be stopped by a signal. diff --git a/crates/registry-breg/tests/compiled_ddl_pins.rs b/crates/registry-breg/tests/compiled_ddl_pins.rs index 15b57df635..0bfa81cee3 100644 --- a/crates/registry-breg/tests/compiled_ddl_pins.rs +++ b/crates/registry-breg/tests/compiled_ddl_pins.rs @@ -104,6 +104,8 @@ //! The generated project SDK passes `limit` to the native list calls, which //! changes the packaged SDK and artifact revisions. SQL and Action pins stay //! fixed. +//! The Proposal additional form and message OpenAPI problems move the +//! artifact revisions while preserving the SQL and Action fingerprints. use registry_breg::compiler::{compile_project, CompileProfile}; use registry_breg::contract::{parse_module_yaml, parse_project_yaml}; diff --git a/crates/registry-breg/tests/compiler_contract.rs b/crates/registry-breg/tests/compiler_contract.rs index fd9a828f17..060be3e7f7 100644 --- a/crates/registry-breg/tests/compiler_contract.rs +++ b/crates/registry-breg/tests/compiler_contract.rs @@ -6683,6 +6683,9 @@ fn generated_openapi_routes_and_physical_names_share_one_compiled_inventory() { "precondition.failed", "precondition.required", "profile.not-authorized", + "proposal.form-limit-reached", + "proposal.form-undeclared", + "proposal.message-limit-reached", "proposal.rejected", "proposal.review-result-mismatch", "proposal.subject-changed", diff --git a/crates/registry-breg/tests/fixtures/automatic-application/journeys.yaml b/crates/registry-breg/tests/fixtures/automatic-application/journeys.yaml new file mode 100644 index 0000000000..6a820dd42d --- /dev/null +++ b/crates/registry-breg/tests/fixtures/automatic-application/journeys.yaml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/breg/journeys/journeys.v1.schema.json +apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: applied + steps: + - id: start-note + action: file-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: start, input: {body: Filed note}} + expect: {outcome: success, status: 201, fields: {state: draft}} + capture: draft + - id: submit-note + action: file-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: submit, proposalCapture: draft, idempotencyKey: submit-note} + expect: {outcome: success, status: 200, fields: {state: submitted}} + - id: await-application + action: file-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: get, proposalCapture: draft, waitSeconds: 10} + expect: + outcome: success + status: 200 + fields: {state: applied, applicationStatus: {mode: automatic, state: applied}} + captureResults: {filed: filed-note} + - id: read-note + recordType: note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: get, recordCapture: filed-note} + expect: {outcome: success, status: 200, fields: {body: Filed note}} diff --git a/crates/registry-breg/tests/fixtures/automatic-application/never-applied.yaml b/crates/registry-breg/tests/fixtures/automatic-application/never-applied.yaml new file mode 100644 index 0000000000..a4033ea1c9 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/automatic-application/never-applied.yaml @@ -0,0 +1,25 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/breg/journeys/journeys.v1.schema.json +apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: held + steps: + - id: start-note + action: hold-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: start, input: {body: Held note}} + expect: {outcome: success, status: 201, fields: {state: draft}} + capture: draft + - id: submit-note + action: hold-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: submit, proposalCapture: draft, idempotencyKey: submit-note} + expect: {outcome: success, status: 200, fields: {state: submitted}} + - id: await-application + action: hold-note + accessProfile: clerk + claims: {principal: synthetic-clerk, scopes: ['notes:file'], purpose: note-handling} + request: {type: proposal, transition: get, proposalCapture: draft, waitSeconds: 1} + expect: {outcome: success, status: 200, fields: {state: applied}} diff --git a/crates/registry-breg/tests/fixtures/automatic-application/project.yaml b/crates/registry-breg/tests/fixtures/automatic-application/project.yaml new file mode 100644 index 0000000000..ba3fd0f3ec --- /dev/null +++ b/crates/registry-breg/tests/fixtures/automatic-application/project.yaml @@ -0,0 +1,54 @@ +# Synthetic project for journeys that wait for automatic Proposal application. +apiVersion: id.registrystack.org/formats/breg/project/v1alpha1 +kind: BRegProject +project: {id: journey-automatic-application, version: '1', defaultLanguage: en, canonicalBaseIri: 'https://journey-automatic-application.example.test'} +package: {sourceRevision: fixture-project-source} +datasets: {notes: {}} +recordTypes: + note: + route: notes + primaryDataset: notes + mutationMode: mutable + classification: internal + fields: + - {id: body, type: string, maximumLength: 64, required: true, classification: internal} +actions: + file-note: + execution: + mode: proposal + proposal: + review: {type: none} + retention: {mode: retain} + inputs: + - {id: body, type: string, maximumLength: 64, required: true, classification: internal} + plan: + type: fixed + effects: + - {id: filed, target: {recordType: note}, operation: create, set: {body: {fromInput: body}}} + hold-note: + execution: + mode: proposal + proposal: + review: {type: none} + application: {mode: manual} + retention: {mode: retain} + inputs: + - {id: body, type: string, maximumLength: 64, required: true, classification: internal} + plan: + type: fixed + effects: + - {id: note, target: {recordType: note}, operation: create, set: {body: {fromInput: body}}} +accessProfiles: + clerk: + principalClaim: registry_principal + requiredPurposes: [note-handling] + requiredScopes: ['notes:file'] + permissions: + records: + - {recordType: note, operations: [get], readableFields: [body], rowBoundaries: unrestricted} + actions: + - {action: file-note, operations: [start], targets: [{recordType: note, rowBoundaries: unrestricted}]} + - {action: hold-note, operations: [start], targets: [{recordType: note, rowBoundaries: unrestricted}]} + proposals: + - {action: file-note, party: owner, operations: [get, list, submit], readableInputs: [body], targets: [{recordType: note, rowBoundaries: unrestricted}]} + - {action: hold-note, party: owner, operations: [get, list, submit], readableInputs: [body], targets: [{recordType: note, rowBoundaries: unrestricted}]} diff --git a/crates/registry-breg/tests/fixtures/message-journeys/journeys.yaml b/crates/registry-breg/tests/fixtures/message-journeys/journeys.yaml new file mode 100644 index 0000000000..81654a91ac --- /dev/null +++ b/crates/registry-breg/tests/fixtures/message-journeys/journeys.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://id.registrystack.org/schemas/breg/journeys/journeys.v1.schema.json +apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: thread + steps: + - id: start-note + actor: applicant + action: file-note + accessProfile: applicant + claims: {principal: synthetic-applicant, scopes: ['notes:file'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: start, input: {body: First note}} + expect: {outcome: success, status: 201, fields: {state: draft}} + capture: draft + - id: submit-note + actor: applicant + action: file-note + accessProfile: applicant + claims: {principal: synthetic-applicant, scopes: ['notes:file'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: submit, proposalCapture: draft} + expect: {outcome: success, status: 200, fields: {state: submitted, turn: official}} + capture: submitted + - id: office-view + actor: office + action: file-note + accessProfile: office + claims: {principal: synthetic-officer, scopes: ['notes:office'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: get, proposalCapture: submitted} + expect: {outcome: success, status: 200} + capture: office-view + - id: office-writes + actor: office + action: file-note + accessProfile: office + claims: {principal: synthetic-officer, scopes: ['notes:office'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: message, proposalCapture: office-view, text: Please add the full address.} + expect: {outcome: success, status: 200} + - id: applicant-view + actor: applicant + action: file-note + accessProfile: applicant + claims: {principal: synthetic-applicant, scopes: ['notes:file'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: get, proposalCapture: submitted} + expect: {outcome: success, status: 200, fields: {status: processing, turn: party}} + capture: applicant-view + - id: applicant-reads + actor: applicant + action: file-note + accessProfile: applicant + claims: {principal: synthetic-applicant, scopes: ['notes:file'], purpose: note-handling, actorKind: human} + request: {type: proposal, transition: read-messages, proposalCapture: applicant-view} + expect: {outcome: success, status: 200, fields: {status: processing, turn: official}} diff --git a/crates/registry-breg/tests/fixtures/message-journeys/project.yaml b/crates/registry-breg/tests/fixtures/message-journeys/project.yaml new file mode 100644 index 0000000000..71cc548c80 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/message-journeys/project.yaml @@ -0,0 +1,50 @@ +# Synthetic project for the Proposal message thread journey operations. +apiVersion: id.registrystack.org/formats/breg/project/v1alpha1 +kind: BRegProject +project: {id: journey-messages, version: '1', defaultLanguage: en, canonicalBaseIri: 'https://journey-messages.example.test'} +package: {sourceRevision: fixture-project-source} +datasets: {notes: {}} +recordTypes: + note: + route: notes + primaryDataset: notes + mutationMode: mutable + classification: internal + fields: + - {id: body, type: string, maximumLength: 64, required: true, classification: internal} +actions: + file-note: + execution: + mode: proposal + proposal: + review: {type: none} + application: {mode: manual} + retention: {mode: retain} + messages: {maximumCount: 10} + inputs: + - {id: body, type: string, maximumLength: 64, required: true, classification: internal} + plan: + type: fixed + effects: + - {id: note, target: {recordType: note}, operation: create, set: {body: {fromInput: body}}} +accessProfiles: + applicant: + actorKind: human + principalClaim: registry_principal + requiredPurposes: [note-handling] + requiredScopes: ['notes:file'] + permissions: + actions: + - {action: file-note, operations: [start], targets: [{recordType: note, rowBoundaries: unrestricted}]} + proposals: + - {action: file-note, party: owner, operations: [get, list, edit, submit, cancel, message], readableInputs: [body], targets: [{recordType: note, rowBoundaries: unrestricted}]} + office: + actorKind: human + principalClaim: registry_principal + requiredPurposes: [note-handling] + requiredScopes: ['notes:office'] + permissions: + records: + - {recordType: note, operations: [create, get], readableFields: [body], writableFields: [body], rowBoundaries: unrestricted} + proposals: + - {action: file-note, operations: [get, list, apply, message], readableInputs: [body], targets: [{recordType: note, rowBoundaries: unrestricted}]} diff --git a/crates/registry-breg/tests/native_inspection_inventory.rs b/crates/registry-breg/tests/native_inspection_inventory.rs index 9d1f18f02a..98202d6bda 100644 --- a/crates/registry-breg/tests/native_inspection_inventory.rs +++ b/crates/registry-breg/tests/native_inspection_inventory.rs @@ -620,7 +620,8 @@ fn event_inspection_uses_owner_hooks_for_phase_and_transitions() { "review-returned", "added", "asked", - "answered" + "answered", + "messaged" ]) ); let model = inspect_registry(®istry); diff --git a/crates/registry-breg/tests/postgres_fixture_journeys.rs b/crates/registry-breg/tests/postgres_fixture_journeys.rs index e3033f6012..ffd4736646 100644 --- a/crates/registry-breg/tests/postgres_fixture_journeys.rs +++ b/crates/registry-breg/tests/postgres_fixture_journeys.rs @@ -250,6 +250,331 @@ async fn fixture_import_uses_real_ingestion_and_leaves_no_open_authority() { database.cleanup().await; } +const AUTOMATIC_PROJECT_SOURCE: &[u8] = + include_bytes!("fixtures/automatic-application/project.yaml"); +const AUTOMATIC_JOURNEY_SOURCE: &[u8] = + include_bytes!("fixtures/automatic-application/journeys.yaml"); +const NEVER_APPLIED_JOURNEY_SOURCE: &[u8] = + include_bytes!("fixtures/automatic-application/never-applied.yaml"); + +fn clerk_token(idp: &MockIdp) -> String { + idp.mint_token(json!({ + "aud": AUDIENCE, + "registry_actor_kind": "service", + "registry_principal": "synthetic-clerk", + "scope": "notes:file", + "purpose": "note-handling", + })) +} + +/// Run one journeys document over the automatic-application project with +/// the clerk's credential on every step. +async fn run_automatic_application_journeys( + journeys: &[u8], + steps: [(&'static str, &'static str); 3], + read_step: Option<(&'static str, &'static str)>, + block_application: bool, +) -> ( + Result, + i64, +) { + let _runtime_guard = WASM_RUNTIME_TEST_LOCK.lock().await; + let compiled = compile_project( + &parse_project_yaml(AUTOMATIC_PROJECT_SOURCE).expect("automatic project parses"), + &[], + CompileProfile::Authoring, + ) + .expect("automatic project compiles"); + let schema_fingerprint = measure_compiled_schema_fingerprint(&compiled).await; + let package = package_fixture_with_modules( + AUTOMATIC_PROJECT_SOURCE, + &schema_fingerprint, + journeys, + Vec::new(), + ); + let suite = validate_fixture_journeys(journeys, &compiled).expect("journeys preflight"); + let mut database = TestDatabase::create(8).await; + let idp = MockIdp::start().await; + let config_path = package.write_runtime_config(&database, &idp); + let config = + load_runtime_config(&config_path, DEVELOPMENT_POSTURE).expect("runtime config loads"); + let prepared_database = prepare_schema_test_database_with_connection_configs_for_test( + &config, + &package.prepared, + &database.migration_config, + &database.runtime_config, + ) + .await + .expect("database prepares"); + let bindings = steps + .into_iter() + .chain(read_step) + .map(|(journey, step)| { + SchemaTestCredentialBinding::bearer(journey, step, Zeroizing::new(clerk_token(&idp))) + }) + .collect(); + let credentials = + SchemaTestCredentialBindings::new(&suite, bindings).expect("credentials bind"); + let execution = execute_schema_test( + prepared_database, + &config, + &package.prepared, + &suite, + credentials, + ); + let result = if block_application { + let table = format!( + "registry_data.{}", + quote_identifier(&compiled.entities()["note"].physical_table) + ); + let barrier = database.admin.transaction().await.expect("barrier begins"); + barrier + .batch_execute(&format!("LOCK TABLE {table} IN SHARE MODE")) + .await + .expect("the barrier holds the application's insert"); + tokio::pin!(execution); + let observe_blocked_insert = async { + loop { + let blocked: bool = barrier + .query_one( + "SELECT EXISTS (SELECT 1 FROM pg_locks + WHERE relation=$1::text::regclass AND mode='RowExclusiveLock' + AND NOT granted AND pg_backend_pid()=ANY(pg_blocking_pids(pid)))", + &[&table], + ) + .await + .expect("application lock status reads") + .get(0); + if blocked { + break; + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }; + tokio::select! { + result = &mut execution => panic!("journey finished before Apply reached the barrier: {result:?}"), + observed = tokio::time::timeout(Duration::from_secs(10), observe_blocked_insert) => { + observed.expect("Apply reaches the PostgreSQL barrier"); + } + } + // The wait started before this insert. Hold it beyond the one-second + // journey deadline, then let the same leased attempt finish normally. + let timed = tokio::time::timeout(Duration::from_millis(1250), &mut execution).await; + assert!( + timed.is_err(), + "the test must join the leased attempt during cleanup" + ); + barrier + .commit() + .await + .expect("application barrier releases"); + let result = execution.await; + tokio::time::timeout(Duration::from_secs(5), async { + loop { + let job = database + .admin + .query_one( + "SELECT state, attempt_count FROM registry_internal.registry_proposal_application_jobs", + &[], + ) + .await + .expect("application job reads"); + assert_eq!(job.get::<_, i32>(1), 1); + match job.get::<_, String>(0).as_str() { + "applied" => break, + "applying" => tokio::time::sleep(Duration::from_millis(10)).await, + state => panic!("the leased attempt ended in {state}"), + } + } + }) + .await + .expect("the in-flight attempt commits after the barrier releases"); + result + } else { + execution.await + }; + let notes: i64 = database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_results", + &[], + ) + .await + .expect("results read") + .get(0); + idp.stop().await; + drop(package); + database.cleanup().await; + (result, notes) +} + +/// A journey waits on a Get step while the built-in executor applies a +/// review-free automatic Proposal, then reads the record it created. +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn fixture_journey_waits_for_automatic_application_and_reads_the_result() { + let (result, results) = run_automatic_application_journeys( + AUTOMATIC_JOURNEY_SOURCE, + [ + ("applied", "start-note"), + ("applied", "submit-note"), + ("applied", "await-application"), + ], + Some(("applied", "read-note")), + false, + ) + .await; + let receipt = result.expect("the waiting journey completes"); + assert_eq!(receipt.successful_journey_ids(), ["applied"]); + assert_eq!(results, 1); +} + +/// A wait that never sees its expectation stops at its bound with a named +/// refusal instead of hanging or reporting an ordinary mismatch. +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn fixture_journey_wait_times_out_with_a_named_failure() { + let started = std::time::Instant::now(); + let (result, results) = run_automatic_application_journeys( + NEVER_APPLIED_JOURNEY_SOURCE, + [ + ("held", "start-note"), + ("held", "submit-note"), + ("held", "await-application"), + ], + None, + false, + ) + .await; + assert_named_application_wait_timeout(result); + assert_eq!(results, 0); + assert!(started.elapsed() < Duration::from_secs(60)); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn fixture_journey_wait_times_out_during_an_in_flight_application() { + let journeys = std::str::from_utf8(AUTOMATIC_JOURNEY_SOURCE) + .expect("journeys are UTF-8") + .replace("waitSeconds: 10", "waitSeconds: 1"); + let (result, results) = run_automatic_application_journeys( + journeys.as_bytes(), + [ + ("applied", "start-note"), + ("applied", "submit-note"), + ("applied", "await-application"), + ], + Some(("applied", "read-note")), + true, + ) + .await; + assert_named_application_wait_timeout(result); + assert_eq!(results, 1); +} + +fn assert_named_application_wait_timeout( + result: Result, +) { + let Err(FixtureError::StepFailed { + journey_index: 0, + step_index: 2, + error, + }) = result + else { + panic!("the wait must fail on its own step: {result:?}"); + }; + assert!(matches!( + *error, + FixtureError::ProposalWaitTimedOut { wait_seconds: 1 } + )); + assert!(error + .to_string() + .starts_with("fixture.proposal.wait-timed-out")); +} + +const MESSAGE_PROJECT_SOURCE: &[u8] = include_bytes!("fixtures/message-journeys/project.yaml"); +const MESSAGE_JOURNEY_SOURCE: &[u8] = include_bytes!("fixtures/message-journeys/journeys.yaml"); + +fn person_token(idp: &MockIdp, principal: &str, scope: &str) -> String { + idp.mint_token(json!({ + "aud": AUDIENCE, + "registry_actor_kind": "human", + "registry_principal": principal, + "scope": scope, + "purpose": "note-handling", + })) +} + +/// The `message` and `read-messages` journey steps drive the real thread +/// routes: the office writes, the applicant sees it is their turn, and +/// reading the thread hands the turn back without moving the status. +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn fixture_message_journey_writes_reads_and_moves_the_turn() { + let _runtime_guard = WASM_RUNTIME_TEST_LOCK.lock().await; + let compiled = compile_project( + &parse_project_yaml(MESSAGE_PROJECT_SOURCE).expect("message project parses"), + &[], + CompileProfile::Authoring, + ) + .expect("message project compiles"); + let schema_fingerprint = measure_compiled_schema_fingerprint(&compiled).await; + let package = package_fixture_with_modules( + MESSAGE_PROJECT_SOURCE, + &schema_fingerprint, + MESSAGE_JOURNEY_SOURCE, + Vec::new(), + ); + let suite = validate_fixture_journeys(MESSAGE_JOURNEY_SOURCE, &compiled) + .expect("message journey preflights"); + let database = TestDatabase::create(8).await; + let idp = MockIdp::start().await; + let config_path = package.write_runtime_config_for_actor_kind(&database, &idp, "human"); + let config = + load_runtime_config(&config_path, DEVELOPMENT_POSTURE).expect("runtime config loads"); + let prepared_database = prepare_schema_test_database_with_connection_configs_for_test( + &config, + &package.prepared, + &database.migration_config, + &database.runtime_config, + ) + .await + .expect("database prepares"); + let applicant = || person_token(&idp, "synthetic-applicant", "notes:file"); + let officer = || person_token(&idp, "synthetic-officer", "notes:office"); + let credentials = credential_bindings_for_tokens( + &suite, + [ + ("thread", "start-note", applicant()), + ("thread", "submit-note", applicant()), + ("thread", "office-view", officer()), + ("thread", "office-writes", officer()), + ("thread", "applicant-view", applicant()), + ("thread", "applicant-reads", applicant()), + ], + ); + let receipt = execute_schema_test( + prepared_database, + &config, + &package.prepared, + &suite, + credentials, + ) + .await + .expect("message journey completes"); + assert_eq!(receipt.successful_journey_ids(), ["thread"]); + let messages: i64 = database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_messages WHERE side='official'", + &[], + ) + .await + .expect("thread reads") + .get(0); + assert_eq!(messages, 1); + + idp.stop().await; + drop(package); + database.cleanup().await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn fixture_test_runs_strict_journeys_through_the_real_postgres_router() { let _runtime_guard = WASM_RUNTIME_TEST_LOCK.lock().await; @@ -1226,6 +1551,16 @@ fn spatial_package_fixture(project: &[u8], schema_fingerprint: &str) -> PackageF impl PackageFixture { fn write_runtime_config(&self, database: &TestDatabase, idp: &MockIdp) -> PathBuf { + self.write_runtime_config_for_actor_kind(database, idp, "service") + } + + /// The issuer asserts one actor kind for every token it signs. + fn write_runtime_config_for_actor_kind( + &self, + database: &TestDatabase, + idp: &MockIdp, + actor_kind: &str, + ) -> PathBuf { let secrets = self.directory.join("secrets"); fs::create_dir_all(&secrets).expect("fixture secret root creates"); write_private(&secrets.join("database-url"), b"unused-by-test-startup"); @@ -1282,7 +1617,7 @@ authentication: accessTokenType: JWT scopeClaim: scope scopeSeparator: " " - actorKind: service + actorKind: {actor_kind} allowedClients: unrestricted maximumTokenLifetimeSeconds: 3600 leewayMilliseconds: 60000 @@ -1307,7 +1642,7 @@ cursor: maximumAgeSeconds: 300 operationalTimeouts: httpRequestMilliseconds: 5000 - shutdownGraceMilliseconds: 1000 + shutdownGraceMilliseconds: 3000 recordLockMilliseconds: 2000 migrationLockMilliseconds: 2000 migrationStatementMilliseconds: 5000 diff --git a/crates/registry-breg/tests/postgres_proposal_messages.rs b/crates/registry-breg/tests/postgres_proposal_messages.rs new file mode 100644 index 0000000000..8919788fb4 --- /dev/null +++ b/crates/registry-breg/tests/postgres_proposal_messages.rs @@ -0,0 +1,1881 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A Proposal whose Action declares `messages` carries one thread between +//! the party (its owner or subject) and the office. BReg stores the thread, +//! decides both sides' authority, and keeps the turn: an unread office +//! message makes it the party's turn without changing the status. +#![cfg(feature = "postgres-test")] +#[path = "support/client_http.rs"] +#[allow(dead_code)] +mod client_http; +#[path = "support/postgres_harness.rs"] +#[allow(dead_code)] +mod postgres_harness; + +use axum::http::{HeaderMap, StatusCode}; +use registry_breg::api::VerifiedRequestClaims; +use registry_breg::compiler::{compile_project, CompileProfile}; +use registry_breg::contract::parse_project_json; +use registry_platform_oidc::ActorKind; +use serde_json::{json, Value}; +use std::collections::{BTreeMap, BTreeSet}; +use uuid::Uuid; + +const CLERK: &str = "clerk-canary"; +const CITIZEN: &str = "citizen-a-canary"; +const NEIGHBOUR: &str = "citizen-b-canary"; +const REVIEWER: &str = "reviewer-canary"; +const OFFICER: &str = "officer-canary"; + +const QUESTION: &str = "Is a scanned copy enough?"; +const ANSWER: &str = "A scan is enough."; + +fn targets() -> Value { + json!([{"recordType":"licence","rowBoundaries":"unrestricted"}]) +} + +fn source() -> Value { + let policy = + json!({"id":"licence-review","version":"1","digest":format!("sha256:{}","b".repeat(64))}); + let inputs = json!([ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}]); + let plan = json!({"type":"fixed","effects":[{"id":"issued","target":{"recordType":"licence"},"operation":"create", + "set":{"holder":{"fromInput":"holder"},"statement":{"fromInput":"statement"}}}]}); + let review_free = |messages: Option| { + let mut proposal = json!({"review":{"type":"none"},"application":{"mode":"manual"},"retention":{"mode":"retain"}}); + if messages + .as_ref() + .is_some_and(|messages| messages.get("automatic").is_some()) + { + proposal["application"] = json!({"mode":"automatic","maximumAttempts":3}); + } + let messages = messages.map(|mut messages| { + messages.as_object_mut().unwrap().remove("automatic"); + messages + }); + if let Some(messages) = messages { + proposal["messages"] = messages; + } + json!({"execution":{"mode":"proposal","proposal":proposal},"inputs":inputs,"plan":plan}) + }; + let owner = |action: &str, operations: Value| { + json!({"action":action,"party":"owner","operations":operations, + "readableInputs":["holder","statement"],"writableInputs":["holder","statement"],"targets":targets()}) + }; + json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + "project":{"id":"proposal-messages","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://proposal-messages.example.test"}, + "datasets":{"licences": {}}, + "reviewAuthorities":{"local-review": {"protocol":"id.registrystack.org/protocols/review/v1"}}, + "recordTypes":{ + "licence": {"route":"licences","primaryDataset":"licences","mutationMode":"mutable","classification":"internal", + "batch":{"maximumItems":3,"maximumBytes":8192}, + "fields":[ + {"id":"holder","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"statement","type":"string","maximumLength":64,"required":false,"classification":"internal"}]}}, + "actions":{ + // Reviewed, with a declared subject and a small thread limit. + "apply-for-licence": {"execution":{"mode":"proposal","proposal":{ + "review":{"type":"required","authority":"local-review","source":"licence-test","policy":policy}, + "application":{"mode":"manual"},"retention":{"mode":"operator-erase"}, + "subject":{"input":"holder"}, + "messages":{"maximumCount":4}, + "reviewContext":{"id":"licence-context","fields":{"holder":{"type":"input","input":"holder"}}}}}, + "inputs":inputs,"plan":plan}, + // No review: an officer who applies by hand can still talk to the applicant (D6). + "record-change": review_free(Some(json!({}))), + "automatic-change": review_free(Some(json!({"automatic":true}))), + // No thread. + "quiet-change": review_free(None)}, + "accessProfiles":{ + "desk": {"principalClaim":"sub","requiredScopes":["licence:desk"],"actorKind":"human", + "permissions":{ + "actions":[{"action":"apply-for-licence","operations":["start"],"targets":targets()}], + "proposals":[{"action":"apply-for-licence","party":"owner","submitsFor":"anyone", + "operations":["get","list","edit","submit","revise","cancel","get-review-status"], + "readableInputs":["holder","statement"],"targets":targets()}]}}, + "citizen": {"principalClaim":"sub","requiredScopes":["licence:self"],"actorKind":"human", + "permissions":{ + "actions":[ + {"action":"apply-for-licence","operations":["start"],"targets":targets()}, + {"action":"record-change","operations":["start"],"targets":targets()}, + {"action":"automatic-change","operations":["start"],"targets":targets()}, + {"action":"quiet-change","operations":["start"],"targets":targets()}], + "proposals":[ + owner("apply-for-licence", json!(["get","list","edit","submit","revise","cancel","get-review-status","message"])), + {"action":"apply-for-licence","party":"subject", + "operations":["get","list","cancel","get-review-status","message"], + "readableInputs":["holder"],"targets":targets()}, + owner("record-change", json!(["get","list","edit","submit","cancel","message"])), + owner("automatic-change", json!(["get","list","edit","submit","cancel","message"])), + owner("quiet-change", json!(["get","list","edit","submit","cancel"]))]}}, + // The usual reviewer: the review context and the thread, nothing else. + "reviewer": {"principalClaim":"sub","requiredScopes":["licence:review"],"actorKind":"human", + "permissions":{"proposals":[ + {"action":"apply-for-licence","operations":["get-review-context","message"], + "readableContextFields":["holder"],"targets":targets()}]}}, + // Written for any actor kind: only the human test keeps a + // service with a reviewer's grant out of the thread. + "relay": {"principalClaim":"sub","requiredScopes":["licence:relay"], + "permissions":{"proposals":[ + {"action":"apply-for-licence","operations":["get-review-context","message"], + "readableContextFields":["holder"],"targets":targets()}]}}, + // The office side of the review-free Actions. + "office": {"principalClaim":"sub","requiredScopes":["licence:office"],"actorKind":"human", + "permissions":{ + "records":[{"recordType":"licence","operations":["create","get"], + "readableFields":["holder","statement"],"writableFields":["holder","statement"],"rowBoundaries":"unrestricted"}], + "proposals":[ + {"action":"record-change","operations":["get","list","apply","message"], + "readableInputs":["holder","statement"],"targets":targets()}, + {"action":"automatic-change","operations":["get","list","message"], + "readableInputs":["holder","statement"],"targets":targets()}, + {"action":"quiet-change","operations":["get","list","apply"], + "readableInputs":["holder","statement"],"targets":targets()}]}}} + }) +} + +fn compile(source: &Value) -> registry_breg::CompiledRegistry { + let project = parse_project_json(&serde_json::to_vec(source).unwrap()).unwrap(); + compile_project(&project, &[], CompileProfile::Authoring).expect("messages project compiles") +} + +fn person(principal: &str, scope: &str, kind: ActorKind) -> VerifiedRequestClaims { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + principal, + BTreeSet::from([scope.to_owned()]), + Some("licence-portal".into()), + BTreeMap::new(), + kind, + ) + .unwrap() +} + +fn clerk() -> VerifiedRequestClaims { + person(CLERK, "licence:desk", ActorKind::Human) +} + +fn citizen(principal: &str) -> VerifiedRequestClaims { + person(principal, "licence:self", ActorKind::Human) +} + +fn reviewer() -> VerifiedRequestClaims { + person(REVIEWER, "licence:review", ActorKind::Human) +} + +fn officer() -> VerifiedRequestClaims { + person(OFFICER, "licence:office", ActorKind::Human) +} + +struct NoToken; +#[async_trait::async_trait] +impl registry_platform_httputil::TokenProvider for NoToken { + async fn bearer_token( + &self, + ) -> Result + { + Err(registry_platform_httputil::TokenError::Unavailable) + } +} + +struct NoResult; +#[async_trait::async_trait] +impl registry_breg::review_store::ReviewResultSource for NoResult { + async fn approved_evidence( + &self, + _authority: &str, + _accepted: ®istry_review_client::ReviewRequestAccepted, + ) -> Result< + registry_breg::review_integration::AcceptedReviewEvidence, + registry_breg::mutation::MutationError, + > { + Err(registry_breg::mutation::MutationError::Unavailable) + } +} + +fn local_review() -> std::sync::Arc { + use registry_breg::review_store::{ReviewAuthorityClient, ReviewAuthorityRegistry}; + let client = registry_review_client::ReviewClient::new( + registry_review_client::ReviewClientConfig::new_without_peer_policy( + "http://127.0.0.1:9/".parse().unwrap(), + ), + ) + .unwrap(); + let authority = std::sync::Arc::new( + ReviewAuthorityClient::new( + "local-review".into(), + client, + std::sync::Arc::new(NoToken), + "producer".into(), + "proposal-producer".into(), + 7, + None, + None, + ) + .unwrap(), + ); + std::sync::Arc::new( + ReviewAuthorityRegistry::new(BTreeMap::from([("local-review".into(), authority)])).unwrap(), + ) +} + +async fn fixture() -> client_http::ClientFixture { + client_http::ClientFixture::start_with_mutations(compile(&source()), officer(), |mutations| { + mutations + .with_proposal_review_substitute_for_test(local_review(), std::sync::Arc::new(NoResult)) + }) + .await +} + +async fn request( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + method: &str, + path: &str, + etag: Option<&str>, + key: Option<&str>, + body: Value, +) -> (StatusCode, HeaderMap, Value) { + use tower::ServiceExt; + let mut req = axum::http::Request::builder() + .method(method) + .uri(path) + .header("content-type", "application/json"); + if let Some(etag) = etag { + req = req.header("if-match", etag); + } + if let Some(key) = key { + req = req.header("idempotency-key", key); + } + let response = registry_breg::api::router(fixture.service()) + .layer(axum::Extension(caller)) + .oneshot( + req.body(if method == "GET" { + axum::body::Body::empty() + } else { + axum::body::Body::from(serde_json::to_vec(&body).unwrap()) + }) + .unwrap(), + ) + .await + .unwrap(); + let status = response.status(); + let headers = response.headers().clone(); + let bytes = axum::body::to_bytes(response.into_body(), 1 << 22) + .await + .unwrap(); + let value = if bytes.is_empty() { + Value::Null + } else { + serde_json::from_slice(&bytes).unwrap() + }; + (status, headers, value) +} + +async fn get( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + id: Uuid, +) -> (StatusCode, Option, Value) { + let (status, headers, value) = request( + fixture, + caller, + "GET", + &format!("/v1/proposals/{id}"), + None, + None, + Value::Null, + ) + .await; + let etag = headers + .get("etag") + .map(|etag| etag.to_str().unwrap().to_owned()); + (status, etag, value) +} + +/// Run a Proposal command as `caller` against the caller's current ETag. +async fn command( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + id: Uuid, + operation: &str, + key: &str, + body: Value, +) -> (StatusCode, Value) { + let (status, etag, document) = get(fixture, caller.clone(), id).await; + assert_eq!(status, StatusCode::OK, "{document}"); + let (status, _, value) = request( + fixture, + caller, + "POST", + &format!("/v1/proposals/{id}/{operation}"), + etag.as_deref(), + Some(key), + body, + ) + .await; + (status, value) +} + +async fn start( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + action: &str, + input: Value, + key: &str, +) -> Uuid { + let (status, _, value) = request( + fixture, + caller, + "POST", + &format!("/v1/actions/{action}/proposals"), + None, + Some(key), + json!({ "input": input }), + ) + .await; + assert_eq!(status, StatusCode::CREATED, "{value}"); + Uuid::parse_str(value["id"].as_str().unwrap()).unwrap() +} + +/// A Proposal of `action` that `caller` filed naming `holder`, submitted. +async fn filed( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + action: &str, + holder: &str, + key: &str, +) -> Uuid { + let id = start( + fixture, + caller.clone(), + action, + json!({"holder":holder,"statement":"Original statement"}), + &format!("{key}-start"), + ) + .await; + let (status, value) = command( + fixture, + caller, + id, + "submit", + &format!("{key}-submit"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + id +} + +/// Write `text` to the thread as a caller who can Get the Proposal. +async fn write( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + profile: &str, + id: Uuid, + text: &str, + key: &str, +) -> (StatusCode, HeaderMap, Value) { + let (status, etag, document) = get(fixture, caller.clone(), id).await; + assert_eq!(status, StatusCode::OK, "{document}"); + request( + fixture, + caller, + "POST", + &format!("/v1/proposals/{id}/messages?accessProfile={profile}"), + etag.as_deref(), + Some(key), + json!({ "text": text }), + ) + .await +} + +async fn review_context( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + profile: &str, + id: Uuid, + include: &str, +) -> (StatusCode, Value) { + let (status, _, value) = request( + fixture, + caller, + "GET", + &format!("/v1/proposals/{id}/review-context?accessProfile={profile}{include}"), + None, + None, + Value::Null, + ) + .await; + (status, value) +} + +async fn list( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + query: &str, +) -> Vec { + let (status, _, page) = request( + fixture, + caller, + "GET", + &format!("/v1/proposals{query}"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + page["items"].as_array().unwrap().clone() +} + +async fn mark_read( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + profile: &str, + id: Uuid, + through: &str, +) -> (StatusCode, Value) { + let (status, _, value) = request( + fixture, + caller, + "POST", + &format!("/v1/proposals/{id}/messages/read?accessProfile={profile}"), + None, + None, + json!({ "through": through }), + ) + .await; + (status, value) +} + +/// Each command link's name and availability, apart from the thread's own. +fn offered(document: &Value) -> BTreeMap { + document["links"] + .as_object() + .map(|links| { + links + .iter() + .map(|(name, link)| { + let mut availability = link["availability"].clone(); + if let Some(availability) = availability.as_object_mut() { + availability.remove("observedRevision"); + } + (name.clone(), availability) + }) + .collect() + }) + .unwrap_or_default() +} + +/// A served message carries no officer name, pseudonym or sender reference. +fn assert_value_free_sender(item: &Value) { + let keys = item + .as_object() + .unwrap() + .keys() + .map(String::as_str) + .collect::>(); + let allowed = BTreeSet::from(["id", "from", "partyRole", "mine", "sentAt", "text"]); + assert!(keys.is_subset(&allowed), "{item}"); + assert!(!item.to_string().contains(REVIEWER), "{item}"); + assert!(!item.to_string().contains(OFFICER), "{item}"); +} + +/// Return the current review round with changes requested, so the party has +/// the turn and Revise is open. +async fn request_changes(fixture: &client_http::ClientFixture, id: Uuid) { + decide(fixture, id, "changes-requested").await; +} + +/// Record the review authority's `outcome` for the current round. +async fn decide(fixture: &client_http::ClientFixture, id: Uuid, outcome: &str) { + let row = fixture + .database + .admin + .query_one( + "SELECT create_request,expected_submission_digest FROM registry_internal.registry_proposal_review_submissions + WHERE proposal_id=$1 ORDER BY submission_version DESC LIMIT 1", + &[&id], + ) + .await + .unwrap(); + let create: registry_review_client::ReviewCreateRequest = + serde_json::from_value(row.get(0)).unwrap(); + let accepted = registry_review_client::ReviewRequestAccepted { + request_id: Uuid::new_v4(), + subject: create.subject, + policy: serde_json::from_value(json!({"id":"licence-review","version":"1","digest":format!("sha256:{}","b".repeat(64))})).unwrap(), + submission_digest: serde_json::from_value(json!(row.get::<_, String>(1))).unwrap(), + }; + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_review_submissions SET state='accepted',accepted_binding=$2 + WHERE proposal_id=$1 AND state<>'accepted'", + &[&id, &serde_json::to_value(&accepted).unwrap()], + ) + .await + .unwrap(); + let now = chrono::Utc::now(); + let result = registry_review_client::ReviewResult { + result_id: Uuid::new_v4(), + request_id: accepted.request_id, + subject: accepted.subject.clone(), + policy: accepted.policy.clone(), + submission_digest: accepted.submission_digest.clone(), + status: serde_json::from_value(json!(outcome)).unwrap(), + outcome: Some(outcome.to_owned()), + public_reason: Some("Public reason for the applicant".to_owned()), + result: None, + completed_at: now - chrono::Duration::seconds(2), + available_until: now + chrono::Duration::minutes(5), + }; + let (mut migration, task) = fixture.database.connect_migration().await; + let tx = migration.transaction().await.unwrap(); + registry_breg::review_store::reconcile_result( + &tx, + "local-review", + &accepted, + &result, + &fixture.mutations, + ) + .await + .unwrap(); + tx.commit().await.unwrap(); + drop(migration); + task.abort(); +} + +/// The first acceptance criterion of #2801, and the turn rule (D4): the +/// applicant writes, the reviewer reads it in the review context and answers +/// through `links.message`, and the applicant reads the answer with a +/// Proposal grant only. +#[tokio::test] +async fn the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn() +{ + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "exchange", + ) + .await; + let (_, before_etag, before) = get(&fixture, citizen(CITIZEN), id).await; + let status_before = before["status"].clone(); + assert_ne!(before["turn"], "party", "{before}"); + assert_eq!(before["messages"]["count"], 0, "{before}"); + assert!(before["messages"].get("lastSentAt").is_none(), "{before}"); + assert_eq!( + before["messages"]["links"]["message"]["path"], + format!("/v1/proposals/{id}/messages") + ); + for operation in ["markRead", "list"] { + let link = &before["messages"]["links"][operation]; + assert!(link.get("ifMatch").is_none(), "{link}"); + let availability = &link["availability"]; + assert_eq!(availability["available"], true, "{availability}"); + assert!(availability.get("reason").is_none(), "{availability}"); + assert!(availability.get("recovery").is_none(), "{availability}"); + } + + let (status, headers, written) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + QUESTION, + "citizen-asks", + ) + .await; + assert_eq!(status, StatusCode::OK, "{written}"); + assert_ne!( + headers.get("etag").map(|etag| etag.to_str().unwrap()), + before_etag.as_deref() + ); + let question = &written["messages"]["items"][0]; + assert_eq!(written["messages"]["count"], 1, "{written}"); + assert_eq!(question["from"], "party"); + assert_eq!(question["partyRole"], "owner"); + assert_eq!(question["mine"], true); + assert_eq!(question["text"], QUESTION); + // A party message is not the party's turn to read. + assert_ne!(written["turn"], "party", "{written}"); + + // The review-context read carries the thread only when asked. + let (status, plain) = review_context(&fixture, reviewer(), "reviewer", id, "").await; + assert_eq!(status, StatusCode::OK, "{plain}"); + assert!(plain["context"].get("messages").is_none(), "{plain}"); + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + let thread = &context["context"]["messages"]; + assert_eq!(thread["count"], 1, "{context}"); + assert_eq!(thread["unread"], 1, "{context}"); + assert_eq!(thread["items"][0]["text"], QUESTION); + assert_eq!(thread["items"][0]["from"], "party"); + assert_eq!(thread["items"][0]["partyRole"], "owner"); + assert_eq!(thread["items"][0]["mine"], false); + let link = &thread["links"]["message"]; + assert_eq!(link["method"], "POST"); + assert_eq!(link["path"], format!("/v1/proposals/{id}/messages")); + assert_eq!(link["operation"], "message"); + + // The reviewer holds no `get`: the answer returns the review context. + let (status, answer_headers, answered) = request( + &fixture, + reviewer(), + "POST", + &format!("{}?accessProfile=reviewer", link["path"].as_str().unwrap()), + link["ifMatch"].as_str(), + Some("reviewer-answers"), + json!({ "text": ANSWER }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + let official = &answered["context"]["messages"]["items"][0]; + assert_eq!(official["from"], "official", "{answered}"); + assert_eq!(official["mine"], true); + assert!(official.get("partyRole").is_none(), "{official}"); + + // The applicant reads the answer with a Proposal grant only. While it + // is unread it is the party's turn; the status does not move. + let (status, _, waiting) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{waiting}"); + let messages = &waiting["messages"]; + assert_eq!(messages["count"], 2, "{waiting}"); + assert_eq!(messages["unread"], 1, "{waiting}"); + assert!(messages["lastSentAt"].is_string(), "{waiting}"); + let answer = &messages["items"][0]; + assert_eq!(answer["text"], ANSWER); + assert_eq!(answer["from"], "official"); + assert_eq!(answer["mine"], false); + for item in messages["items"].as_array().unwrap() { + assert_value_free_sender(item); + } + assert_eq!(waiting["turn"], "party", "{waiting}"); + assert_eq!(waiting["status"], status_before, "{waiting}"); + // Every offered command keeps its availability. + assert_eq!( + offered(&waiting), + offered(&before), + "an unread message changed what the party may do" + ); + let listed = list(&fixture, citizen(CITIZEN), "?turn=party").await; + assert_eq!(listed.len(), 1, "{listed:?}"); + assert_eq!(listed[0]["id"], id.to_string()); + assert_eq!(listed[0]["messages"]["unread"], 1); + assert_eq!(listed[0]["messages"]["count"], 2); + assert!( + listed[0]["messages"].get("items").is_none(), + "{:?}", + listed[0] + ); + + // Mark-read moves the party's side forward; repeating it changes nothing. + let through = answer["id"].as_str().unwrap().to_owned(); + for _ in 0..2 { + let (status, read) = mark_read(&fixture, citizen(CITIZEN), "citizen", id, &through).await; + assert_eq!(status, StatusCode::OK, "{read}"); + assert_eq!(read["messages"]["unread"], 0, "{read}"); + assert_ne!(read["turn"], "party", "{read}"); + assert_eq!(read["status"], status_before, "{read}"); + } + assert!(list(&fixture, citizen(CITIZEN), "?turn=party") + .await + .is_empty()); + + let (status, replay_headers, replay) = request( + &fixture, + reviewer(), + "POST", + &format!("{}?accessProfile=reviewer", link["path"].as_str().unwrap()), + link["ifMatch"].as_str(), + Some("reviewer-answers"), + json!({"text":ANSWER}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{replay}"); + assert_eq!(replay_headers["etag"], answer_headers["etag"]); + assert_eq!( + replay, answered, + "the held review response is exact after mark-read" + ); + + let events = fixture + .database + .admin + .query( + "SELECT payload FROM registry_internal.registry_outbox + WHERE event_type='proposal.messaged' ORDER BY record_revision", + &[], + ) + .await + .unwrap(); + assert_eq!( + events.len(), + 2, + "read markers and replays emit no message event" + ); + for (event, side) in events.iter().zip(["party", "official"]) { + let bytes: Vec = event.get(0); + let wire: Value = serde_json::from_slice(&bytes).unwrap(); + assert_eq!(wire["data"]["messageFrom"], side); + assert!(wire["data"].get("text").is_none()); + let serialized = String::from_utf8_lossy(&bytes); + assert!(!serialized.contains(QUESTION) && !serialized.contains(ANSWER)); + } + + // The paged list returns newest first. + let (status, _, page) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=citizen&limit=1"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + assert_eq!(page["items"].as_array().unwrap().len(), 1, "{page}"); + assert_eq!(page["items"][0]["text"], ANSWER); + let cursor = page["nextCursor"] + .as_str() + .expect("a second page") + .to_owned(); + let (status, _, rest) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=citizen&limit=1&after={cursor}"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{rest}"); + assert_eq!(rest["items"][0]["text"], QUESTION); + assert!(rest.get("nextCursor").is_none() || rest["nextCursor"].is_null()); + + // The batch read the task inbox uses carries counts and never text. + let (status, _, batch) = request( + &fixture, + reviewer(), + "GET", + &format!("/v1/proposals/review-context?ids={id}&accessProfile=reviewer"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{batch}"); + let summary = &batch["items"][0]["context"]["context"]["messages"]; + assert_eq!(summary["count"], 2, "{batch}"); + assert!(summary["lastSentAt"].is_string(), "{batch}"); + assert!(summary.get("items").is_none(), "{batch}"); + let served = batch.to_string(); + assert!(!served.contains(QUESTION) && !served.contains(ANSWER)); + + // Text never reaches audit. + let audit = serde_json::to_string(&fixture.audit_capture.entries()).unwrap(); + assert!(!audit.contains(QUESTION) && !audit.contains(ANSWER)); + fixture.finish().await; +} + +/// The party is the owner or the subject. Both post and read; a neighbour +/// with the same profile learns nothing on any thread route. +#[tokio::test] +async fn the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found() { + let fixture = fixture().await; + let id = filed( + &fixture, + clerk(), + "apply-for-licence", + CITIZEN, + "desk-files", + ) + .await; + + let (status, _, written) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + "Filed for me: what happens next?", + "subject-writes", + ) + .await; + assert_eq!(status, StatusCode::OK, "{written}"); + assert_eq!(written["partyRole"], "subject"); + let item = &written["messages"]["items"][0]; + assert_eq!(item["from"], "party"); + assert_eq!(item["partyRole"], "subject"); + assert_eq!(item["mine"], true); + + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + assert_eq!( + context["context"]["messages"]["items"][0]["partyRole"], + "subject" + ); + let link = context["context"]["messages"]["links"]["message"].clone(); + let (status, _, answered) = request( + &fixture, + reviewer(), + "POST", + &format!("{}?accessProfile=reviewer", link["path"].as_str().unwrap()), + link["ifMatch"].as_str(), + Some("reviewer-answers-subject"), + json!({ "text": ANSWER }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + let (status, _, followed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{followed}"); + assert_eq!(followed["messages"]["items"][0]["text"], ANSWER); + assert_eq!(followed["messages"]["unread"], 1); + + // The clerk owns the Proposal through a grant without `message`: no + // member, and the write is refused by name, not concealed. + let (status, etag, filer) = get(&fixture, clerk(), id).await; + assert_eq!(status, StatusCode::OK, "{filer}"); + assert!(filer.get("messages").is_none(), "{filer}"); + let (status, _, refused) = request( + &fixture, + clerk(), + "POST", + &format!("/v1/proposals/{id}/messages?accessProfile=desk"), + etag.as_deref(), + Some("clerk-writes"), + json!({"text":"From the desk"}), + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{refused}"); + assert_eq!(refused["code"], "profile.not-authorized"); + + // A neighbour gets 404 on every thread route. + let neighbour_routes = [ + ( + "POST", + format!("/v1/proposals/{id}/messages?accessProfile=citizen"), + Some("\"breg-proposal-guess\""), + Some("neighbour-writes"), + json!({"text":"Guess"}), + ), + ( + "GET", + format!("/v1/proposals/{id}/messages?accessProfile=citizen"), + None, + None, + Value::Null, + ), + ( + "POST", + format!("/v1/proposals/{id}/messages/read?accessProfile=citizen"), + None, + None, + json!({"through": Uuid::new_v4()}), + ), + ]; + for (method, path, etag, key, body) in neighbour_routes { + let (status, _, concealed) = + request(&fixture, citizen(NEIGHBOUR), method, &path, etag, key, body).await; + assert_eq!( + status, + StatusCode::NOT_FOUND, + "{method} {path}: {concealed}" + ); + assert_eq!(concealed["code"], "resource.not-found", "{concealed}"); + } + let (status, _, _) = get(&fixture, citizen(NEIGHBOUR), id).await; + assert_eq!(status, StatusCode::NOT_FOUND); + for item in list(&fixture, citizen(NEIGHBOUR), "").await { + assert_ne!(item["id"], id.to_string()); + } + fixture.finish().await; +} + +/// D6: an Action without review carries a thread. The office talks to the +/// applicant and applies by hand; applying closes the thread for writes and +/// leaves it readable. +#[tokio::test] +async fn messages_need_no_review_and_close_for_writes_when_the_request_is_applied() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "record-change", + CITIZEN, + "review-free", + ) + .await; + let (status, _, written) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + QUESTION, + "review-free-asks", + ) + .await; + assert_eq!(status, StatusCode::OK, "{written}"); + + let (status, _, office_view) = get(&fixture, officer(), id).await; + assert_eq!(status, StatusCode::OK, "{office_view}"); + assert_eq!(office_view["messages"]["items"][0]["text"], QUESTION); + assert_eq!(office_view["messages"]["items"][0]["from"], "party"); + assert!(office_view.get("partyRole").is_none(), "{office_view}"); + let (status, _, answered) = write( + &fixture, + officer(), + "office", + id, + ANSWER, + "review-free-answers", + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + assert_eq!(answered["messages"]["items"][0]["from"], "official"); + + let (_, _, waiting) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(waiting["messages"]["unread"], 1, "{waiting}"); + assert_eq!(waiting["turn"], "party", "{waiting}"); + + let apply = json!({"submissionVersion":waiting["submissionVersion"],"effectDigest":waiting["effectDigest"]}); + let (_, etag, _) = get(&fixture, officer(), id).await; + let path = format!("/v1/proposals/{id}/apply"); + let (status, applied_headers, applied) = request( + &fixture, + officer(), + "POST", + &path, + etag.as_deref(), + Some("apply"), + apply.clone(), + ) + .await; + assert_eq!(status, StatusCode::OK, "{applied}"); + assert_eq!(applied["messages"]["items"][0]["text"], ANSWER); + let (status, replay_headers, replay) = request( + &fixture, + officer(), + "POST", + &path, + etag.as_deref(), + Some("apply"), + apply, + ) + .await; + assert_eq!(status, StatusCode::OK, "{replay}"); + assert_eq!(replay_headers["etag"], applied_headers["etag"]); + assert_eq!(replay, applied); + let (status, _, refused) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + "One more thing", + "after-apply", + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED, "{refused}"); + assert_eq!(refused["code"], "precondition.failed"); + let (status, _, closed) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{closed}"); + assert_eq!(closed["messages"]["count"], 2, "{closed}"); + assert!( + closed["messages"]["links"]["message"] + .to_string() + .contains("already-applied"), + "{closed}" + ); + let (status, _, page) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=citizen"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + assert_eq!(page["items"].as_array().unwrap().len(), 2, "{page}"); + fixture.finish().await; +} + +/// Thread activity never fences automatic application. A party message or +/// a mark-read that lands between the worker's read and its Apply leaves the +/// approved request applied, not refused and handed back to the party. +#[tokio::test] +async fn thread_activity_during_automatic_application_does_not_strand_the_request() { + for activity in ["party-message", "party-mark-read"] { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "automatic-change", + CITIZEN, + activity, + ) + .await; + let mut through = None; + if activity == "party-mark-read" { + let (status, _, answered) = write( + &fixture, + officer(), + "office", + id, + ANSWER, + &format!("{activity}-office"), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + through = Some( + answered["messages"]["items"][0]["id"] + .as_str() + .unwrap() + .to_owned(), + ); + } + fixture + .database + .admin + .execute( + "UPDATE registry_internal.registry_proposal_application_jobs + SET next_attempt_at=transaction_timestamp()-interval '1 minute'", + &[], + ) + .await + .unwrap(); + let loaded = std::sync::Arc::new(tokio::sync::Notify::new()); + let resume = std::sync::Arc::new(tokio::sync::Notify::new()); + let worker = fixture + .mutations + .as_ref() + .clone() + .with_automatic_apply_barrier_for_test(loaded.clone(), resume.clone()); + let (attempt, ()) = tokio::join!(worker.run_automatic_proposal_once_for_test(), async { + tokio::time::timeout(std::time::Duration::from_secs(5), loaded.notified()) + .await + .expect("the worker reached Apply"); + match through.as_deref() { + None => { + let (status, _, written) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + QUESTION, + &format!("{activity}-party"), + ) + .await; + assert_eq!(status, StatusCode::OK, "{written}"); + } + Some(through) => { + let (status, read) = + mark_read(&fixture, citizen(CITIZEN), "citizen", id, through).await; + assert!(status.is_success(), "{read}"); + } + } + resume.notify_one(); + }); + assert!(attempt.unwrap(), "{activity}: the worker claimed the job"); + let row = fixture + .database + .admin + .query_one( + "SELECT state,last_error_code FROM registry_internal.registry_proposal_application_jobs", + &[], + ) + .await + .unwrap(); + assert_eq!( + row.get::<_, String>(0), + "applied", + "{activity}: {:?}", + row.get::<_, Option>(1) + ); + let (status, _, applied) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{applied}"); + assert_eq!(applied["state"], "applied", "{activity}: {applied}"); + fixture.finish().await; + } +} + +#[tokio::test] +async fn an_action_without_messages_serves_no_thread() { + let fixture = fixture().await; + let id = filed(&fixture, citizen(CITIZEN), "quiet-change", CITIZEN, "quiet").await; + let (status, etag, document) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(status, StatusCode::OK, "{document}"); + assert!(document.get("messages").is_none(), "{document}"); + for (method, path, etag, key, body) in [ + ( + "POST", + format!("/v1/proposals/{id}/messages?accessProfile=citizen"), + etag.as_deref(), + Some("quiet-writes"), + json!({"text": QUESTION}), + ), + ( + "GET", + format!("/v1/proposals/{id}/messages?accessProfile=citizen"), + None, + None, + Value::Null, + ), + ( + "POST", + format!("/v1/proposals/{id}/messages/read?accessProfile=citizen"), + None, + None, + json!({"through": Uuid::new_v4()}), + ), + ] { + let (status, _, value) = + request(&fixture, citizen(CITIZEN), method, &path, etag, key, body).await; + assert_eq!(status, StatusCode::NOT_FOUND, "{method} {path}: {value}"); + } + // The route exists for Actions that declare a thread, so the refusal + // above is the declaration's, not a missing route's. + let threaded = filed( + &fixture, + citizen(CITIZEN), + "record-change", + CITIZEN, + "threaded", + ) + .await; + let (status, _, value) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{threaded}/messages?accessProfile=citizen"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + fixture.finish().await; +} + +/// Read and write take the human test, whatever the grant says. +#[tokio::test] +async fn only_a_person_acting_for_themselves_reads_or_writes_the_thread() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "people-only", + ) + .await; + let (status, _, written) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + QUESTION, + "people-only-asks", + ) + .await; + assert_eq!(status, StatusCode::OK, "{written}"); + let relay = |kind| person("relay-canary", "licence:relay", kind); + + // A human under the any-kind profile is admitted. + let (status, context) = review_context( + &fixture, + relay(ActorKind::Human), + "relay", + id, + "&include=messages", + ) + .await; + assert_eq!(status, StatusCode::OK, "{context}"); + assert_eq!(context["context"]["messages"]["items"][0]["text"], QUESTION); + let link = context["context"]["messages"]["links"]["message"].clone(); + + // A service with the same grant neither reads nor writes. + let (status, context) = review_context( + &fixture, + relay(ActorKind::Service), + "relay", + id, + "&include=messages", + ) + .await; + assert!( + status != StatusCode::OK || context["context"].get("messages").is_none(), + "{context}" + ); + assert!(!context.to_string().contains(QUESTION), "{context}"); + let (status, _, refused) = request( + &fixture, + relay(ActorKind::Service), + "POST", + &format!("/v1/proposals/{id}/messages?accessProfile=relay"), + link["ifMatch"].as_str(), + Some("service-writes"), + json!({"text":"Automated"}), + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{refused}"); + assert_eq!(refused["code"], "profile.not-authorized"); + let (status, _, page) = request( + &fixture, + relay(ActorKind::Service), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=relay"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::FORBIDDEN, "{page}"); + // An agent on the same profile, writing or marking read, is refused too. + let message = context_message_id(&fixture, id).await; + for (method, path, key, body) in [ + ( + "POST", + format!("/v1/proposals/{id}/messages?accessProfile=relay"), + Some("agent-writes"), + json!({"text":"Automated"}), + ), + ( + "POST", + format!("/v1/proposals/{id}/messages/read?accessProfile=relay"), + None, + json!({"through":message}), + ), + ( + "GET", + format!("/v1/proposals/{id}/messages?accessProfile=relay"), + None, + Value::Null, + ), + ] { + for kind in [ActorKind::Agent, ActorKind::Service] { + let (status, _, refused) = request( + &fixture, + relay(kind), + method, + &path, + link["ifMatch"].as_str(), + key, + body.clone(), + ) + .await; + assert_eq!( + status, + StatusCode::FORBIDDEN, + "{kind:?} {method} {path}: {refused}" + ); + assert!(!refused.to_string().contains(QUESTION), "{refused}"); + } + } + fixture.finish().await; +} + +/// The newest message's ID, read as the usual human reviewer. +async fn context_message_id(fixture: &client_http::ClientFixture, id: Uuid) -> String { + let (status, context) = + review_context(fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + context["context"]["messages"]["items"][0]["id"] + .as_str() + .unwrap() + .to_owned() +} + +#[tokio::test] +async fn the_thread_refuses_stale_writes_replays_keys_checks_text_and_stops_at_its_limit() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "limits", + ) + .await; + let (_, stale, _) = get(&fixture, citizen(CITIZEN), id).await; + let path = format!("/v1/proposals/{id}/messages?accessProfile=citizen"); + let (status, _, first) = request( + &fixture, + citizen(CITIZEN), + "POST", + &path, + stale.as_deref(), + Some("first"), + json!({ "text": QUESTION }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{first}"); + + // A replayed key returns the stored response; a new key on the old + // ETag is refused. + let (status, _, replayed) = request( + &fixture, + citizen(CITIZEN), + "POST", + &path, + stale.as_deref(), + Some("first"), + json!({ "text": QUESTION }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{replayed}"); + assert_eq!(replayed, first); + let (status, _, refused) = request( + &fixture, + citizen(CITIZEN), + "POST", + &path, + stale.as_deref(), + Some("second-on-stale"), + json!({"text":"Stale"}), + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED, "{refused}"); + assert_eq!(refused["code"], "precondition.failed"); + + // Every write names its condition and its key, and a key is bound to its + // request. + let (_, current, _) = get(&fixture, citizen(CITIZEN), id).await; + for (etag, key, text, status, code) in [ + ( + None, + Some("no-condition"), + "Unconditioned", + StatusCode::PRECONDITION_REQUIRED, + "precondition.required", + ), + ( + current.as_deref(), + None, + "Unkeyed", + StatusCode::BAD_REQUEST, + "request.invalid", + ), + ( + current.as_deref(), + Some("first"), + "Changed body", + StatusCode::CONFLICT, + "idempotency.key-reused", + ), + ] { + let (actual, _, refused) = request( + &fixture, + citizen(CITIZEN), + "POST", + &path, + etag, + key, + json!({ "text": text }), + ) + .await; + assert_eq!(actual, status, "{text}: {refused}"); + assert_eq!(refused["code"], code, "{text}: {refused}"); + } + + for (text, key) in [ + (String::new(), "empty"), + ("a".repeat(2001), "too-long"), + ("Bell \u{0007}".to_owned(), "control"), + ("Reordered \u{202E}txet".to_owned(), "reordering"), + ("\u{200B}\u{200C}\u{FEFF}".to_owned(), "invisible-only"), + ( + "Hidden \u{E0041}\u{E0042} tags".to_owned(), + "tag-characters", + ), + ("Joined\u{2060}word".to_owned(), "word-joiner"), + ("Line\u{2028}separator".to_owned(), "line-separator"), + ("Lone\rreturn".to_owned(), "lone-return"), + ] { + let (status, _, refused) = + write(&fixture, citizen(CITIZEN), "citizen", id, &text, key).await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{key}: {refused}"); + assert_eq!(refused["code"], "request.invalid", "{key}"); + assert_eq!(refused["fieldPath"], "/text", "{key}: {refused}"); + } + + // Markup is stored and returned byte for byte; 2,000 bytes fit. + let markup = "bold & "; + let (status, _, stored) = + write(&fixture, citizen(CITIZEN), "citizen", id, markup, "markup").await; + assert_eq!(status, StatusCode::OK, "{stored}"); + assert_eq!(stored["messages"]["items"][0]["text"], markup); + let full = "\u{e9}".repeat(1000); + let (status, _, value) = write(&fixture, citizen(CITIZEN), "citizen", id, &full, "full").await; + assert_eq!(status, StatusCode::OK, "{value}"); + // A form post's line breaks arrive as CRLF and are kept. + let crlf = "Line one\r\nLine two"; + let (status, _, value) = write(&fixture, citizen(CITIZEN), "citizen", id, crlf, "four").await; + assert_eq!(status, StatusCode::OK, "{value}"); + assert_eq!(value["messages"]["items"][0]["text"], crlf); + + // The Action allows four messages from each side. + let (status, _, limited) = + write(&fixture, citizen(CITIZEN), "citizen", id, "Five", "five").await; + assert_eq!(status, StatusCode::CONFLICT, "{limited}"); + assert_eq!(limited["code"], "proposal.message-limit-reached"); + let (_, _, document) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(document["messages"]["count"], 4, "{document}"); + assert!( + document["messages"]["links"]["message"] + .to_string() + .contains("limit-reached"), + "{document}" + ); + // A full party side leaves the office its own share. + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + let link = &context["context"]["messages"]["links"]["message"]; + assert_eq!(link["availability"]["available"], true, "{context}"); + let (status, _, answered) = request( + &fixture, + reviewer(), + "POST", + &format!("/v1/proposals/{id}/messages?accessProfile=reviewer"), + link["ifMatch"].as_str(), + Some("office-after-party-limit"), + json!({ "text": ANSWER }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + assert_eq!(answered["context"]["messages"]["count"], 5, "{answered}"); + fixture.finish().await; +} + +/// The thread belongs to the Proposal, not to a review round. +#[tokio::test] +async fn the_thread_stays_open_across_revise_and_the_next_round_reads_all_of_it() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "rounds", + ) + .await; + let (status, _, value) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + "Round one question", + "round-one", + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + request_changes(&fixture, id).await; + let (status, revised) = command( + &fixture, + citizen(CITIZEN), + id, + "revise", + "revise", + json!({"input":{"holder":CITIZEN,"statement":"Revised"}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{revised}"); + let (status, _, value) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + "What exactly is wrong?", + "between-rounds", + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (status, value) = command( + &fixture, + citizen(CITIZEN), + id, + "submit", + "resubmit", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + assert_eq!(context["submissionVersion"], 2, "{context}"); + let texts = context["context"]["messages"]["items"] + .as_array() + .unwrap() + .iter() + .map(|item| item["text"].as_str().unwrap().to_owned()) + .collect::>(); + assert_eq!( + texts, + ["What exactly is wrong?", "Round one question"], + "{context}" + ); + let before: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_idempotency r + JOIN registry_internal.registry_proposal_idempotency_links l USING(key_reference) + WHERE l.proposal_id=$1 AND l.submission_version=2 + AND position('Round one question' in convert_from(r.response_body,'UTF8')) > 0", + &[&id], + ) + .await + .unwrap() + .get(0); + assert!(before > 0); + let (mut client, task) = fixture.database.connect_migration().await; + let erased = registry_breg::proposal_retention::erase_proposal_detail( + &mut client, + &fixture.registry, + registry_breg::proposal_retention::ProposalDetailErasureScope { + action_id: "apply-for-licence", + proposal_id: id, + submission_version: 1, + }, + ) + .await + .unwrap(); + assert_eq!(erased.messages, 1); + let row = fixture + .database + .admin + .query_one( + "SELECT + (SELECT count(*) FROM registry_internal.registry_proposal_messages + WHERE proposal_id=$1 AND submission_version=1 AND text IS NULL AND sent_by IS NULL + AND detail_erased_at IS NOT NULL), + (SELECT count(*) FROM registry_internal.registry_proposal_messages + WHERE proposal_id=$1 AND submission_version=2 AND text='What exactly is wrong?'), + (SELECT count(*) FROM registry_internal.registry_idempotency r + JOIN registry_internal.registry_proposal_idempotency_links l USING(key_reference) + WHERE l.proposal_id=$1 AND l.submission_version=2 + AND position('Round one question' in convert_from(r.response_body,'UTF8')) > 0)", + &[&id], + ) + .await + .unwrap(); + assert_eq!(row.get::<_, i64>(0), 1); + assert_eq!(row.get::<_, i64>(1), 1); + assert_eq!(row.get::<_, i64>(2), 0); + drop(client); + task.abort(); + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_eq!(status, StatusCode::OK, "{context}"); + let items = context["context"]["messages"]["items"].as_array().unwrap(); + assert_eq!(items.len(), 2, "{context}"); + assert_eq!(items[0]["text"], "What exactly is wrong?"); + assert_eq!(items[1]["from"], "party"); + assert!(items[1].get("text").is_none(), "{context}"); + fixture.finish().await; +} + +/// The thread opens at the first Submit and closes for writes when the +/// Proposal is cancelled or rejected, as it does when it is applied. +#[tokio::test] +async fn the_thread_is_closed_before_the_first_submit_and_after_cancel_or_rejection() { + let fixture = fixture().await; + let draft = start( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + json!({"holder":CITIZEN,"statement":"Draft"}), + "unsubmitted-start", + ) + .await; + let (status, _, refused) = write( + &fixture, + citizen(CITIZEN), + "citizen", + draft, + QUESTION, + "before-submit", + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED, "{refused}"); + assert_eq!(refused["code"], "precondition.failed"); + + let cancelled = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "to-cancel", + ) + .await; + let (status, value) = command( + &fixture, + citizen(CITIZEN), + cancelled, + "cancel", + "cancel", + json!({}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let (status, _, refused) = write( + &fixture, + citizen(CITIZEN), + "citizen", + cancelled, + QUESTION, + "after-cancel", + ) + .await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED, "{refused}"); + assert_eq!(refused["code"], "precondition.failed"); + + let rejected = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "to-reject", + ) + .await; + decide(&fixture, rejected, "rejected").await; + let (status, _, refused) = write( + &fixture, + citizen(CITIZEN), + "citizen", + rejected, + QUESTION, + "after-rejection", + ) + .await; + assert_eq!(status, StatusCode::CONFLICT, "{refused}"); + assert_eq!(refused["code"], "proposal.rejected"); + let count: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_messages", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(count, 0); + fixture.finish().await; +} + +/// A reviewer who holds the thread but not Get can still reply between +/// review rounds, when no review context is readable: the first page of the +/// thread carries its links, and the write answers with the thread alone. +#[tokio::test] +async fn a_reviewer_without_get_replies_between_rounds_from_the_thread_alone() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "between", + ) + .await; + request_changes(&fixture, id).await; + let (status, revised) = command( + &fixture, + citizen(CITIZEN), + id, + "revise", + "between-revise", + json!({"input":{"holder":CITIZEN,"statement":"Revised"}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{revised}"); + let (status, _, asked) = write( + &fixture, + citizen(CITIZEN), + "citizen", + id, + "What exactly is wrong?", + "between-asks", + ) + .await; + assert_eq!(status, StatusCode::OK, "{asked}"); + let (status, context) = + review_context(&fixture, reviewer(), "reviewer", id, "&include=messages").await; + assert_ne!(status, StatusCode::OK, "{context}"); + + let (status, _, page) = request( + &fixture, + reviewer(), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=reviewer"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + assert_eq!(page["items"][0]["text"], "What exactly is wrong?", "{page}"); + let link = page["links"]["message"].clone(); + assert_eq!(link["availability"]["available"], true, "{page}"); + let (status, _, replied) = request( + &fixture, + reviewer(), + "POST", + &format!("/v1/proposals/{id}/messages?accessProfile=reviewer"), + link["ifMatch"].as_str(), + Some("between-reply"), + json!({ "text": ANSWER }), + ) + .await; + assert_eq!(status, StatusCode::OK, "{replied}"); + assert_eq!(replied["items"][0]["text"], ANSWER, "{replied}"); + assert_eq!(replied["items"][0]["from"], "official", "{replied}"); + assert_eq!(replied["count"], 2, "{replied}"); + assert!(replied.get("context").is_none(), "{replied}"); + + let question = page["items"][0]["id"].as_str().unwrap(); + let (status, read) = mark_read(&fixture, reviewer(), "reviewer", id, question).await; + assert_eq!(status, StatusCode::OK, "{read}"); + assert_eq!(read["unread"], 0, "{read}"); + + let (_, _, waiting) = get(&fixture, citizen(CITIZEN), id).await; + assert_eq!(waiting["messages"]["items"][0]["text"], ANSWER, "{waiting}"); + fixture.finish().await; +} + +/// Office staff whose grant does not reach a Proposal learn nothing about +/// it from a thread route, however malformed the request. +#[tokio::test] +async fn bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_unknown_one() { + let mut source = source(); + let mut bounded = source["accessProfiles"]["reviewer"].clone(); + bounded["requiredScopes"] = json!(["licence:district"]); + bounded["permissions"]["proposals"][0]["targets"] = json!([{"recordType":"licence", + "rowBoundaries":[{"field":"holder","claim":"holder_scope","operator":"equals"}]}]); + source["accessProfiles"]["district"] = bounded; + let fixture = client_http::ClientFixture::start_with_mutations( + compile(&source), + officer(), + |mutations| { + mutations.with_proposal_review_substitute_for_test( + local_review(), + std::sync::Arc::new(NoResult), + ) + }, + ) + .await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "hidden", + ) + .await; + let district = |scope: &str| { + VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + "district-officer", + BTreeSet::from(["licence:district".to_owned()]), + Some("licence-portal".into()), + BTreeMap::from([( + "holder_scope".to_owned(), + registry_breg::api::VerifiedClaimValue::direct_string(scope).unwrap(), + )]), + ActorKind::Human, + ) + .unwrap() + }; + let (status, _, page) = request( + &fixture, + district(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=district"), + None, + None, + Value::Null, + ) + .await; + assert_eq!( + status, + StatusCode::OK, + "the district that holds it reads it: {page}" + ); + let unknown = Uuid::new_v4(); + for target in [id, unknown] { + for (method, path, etag, key, body) in [ + ( + "POST", + format!("/v1/proposals/{target}/messages?accessProfile=district"), + None, + Some("hidden-write"), + json!({"text":QUESTION}), + ), + ( + "POST", + format!("/v1/proposals/{target}/messages?accessProfile=district"), + Some("\"stale\""), + None, + json!({"text":QUESTION}), + ), + ( + "POST", + format!("/v1/proposals/{target}/messages?accessProfile=district"), + Some("\"stale\""), + Some("hidden-text"), + json!({"text":""}), + ), + ( + "GET", + format!("/v1/proposals/{target}/messages?accessProfile=district&after=0"), + None, + None, + Value::Null, + ), + ( + "GET", + format!("/v1/proposals/{target}/messages?accessProfile=district&limit=0"), + None, + None, + Value::Null, + ), + ( + "POST", + format!("/v1/proposals/{target}/messages/read?accessProfile=district"), + None, + None, + json!({"through":"not-a-message"}), + ), + ] { + let (status, _, refused) = request( + &fixture, + district("elsewhere"), + method, + &path, + etag, + key, + body, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{method} {path}: {refused}"); + assert_eq!( + refused["code"], "resource.not-found", + "{method} {path}: {refused}" + ); + } + } + fixture.finish().await; +} diff --git a/crates/registry-breg/tests/postgres_record_timer_metrics.rs b/crates/registry-breg/tests/postgres_record_timer_metrics.rs index 856f93a9ec..ccd2f6c3c4 100644 --- a/crates/registry-breg/tests/postgres_record_timer_metrics.rs +++ b/crates/registry-breg/tests/postgres_record_timer_metrics.rs @@ -93,6 +93,9 @@ async fn stuck_hook_deliveries(harness: &mut NativeTimerHarness) -> Result<(), S for code in ["hook.claim.recovery_failed", "hook.worker.iteration_failed"] { harness.expect_non_info_code_range(0, code, 0, 100)?; } + // The first retention tick may also encounter that lock. Its next tick + // is a minute later, after the scrape has released the relation. + harness.expect_non_info_code_range(0, "hook.retention.lock_timeout", 0, 1)?; let locked = harness .scrape_with_relation_locked(0, "registry_internal.registry_webhook_delivery_state") .await?; diff --git a/crates/registry-breg/tests/postgres_record_timer_native.rs b/crates/registry-breg/tests/postgres_record_timer_native.rs index 7d65b97d82..507414f6e4 100644 --- a/crates/registry-breg/tests/postgres_record_timer_native.rs +++ b/crates/registry-breg/tests/postgres_record_timer_native.rs @@ -918,6 +918,7 @@ async fn removed_timer_fences_predecessor_process( .wait_for_one_checkpoint(armed.occurrence_id, Duration::from_secs(10)) .await?; + let activation_started = std::time::Instant::now(); let activation = harness.activate_reviewed_timer_removal_successor().await?; if activation.predecessor_package_digest == activation.successor_package_digest || activation.predecessor_activation_id == activation.successor_activation_id @@ -960,8 +961,6 @@ async fn removed_timer_fences_predecessor_process( 1, 6, )?; - harness.expect_non_info_code_range(predecessor, "hook.claim.identity_refused", 0, 6)?; - harness.expect_non_info_code_range(predecessor, "hook.worker.iteration_failed", 0, 6)?; harness.expect_non_info_code_range(predecessor, "review.worker.iteration_failed", 0, 2)?; let after_stale_owner = harness.timer_evidence(&record_id).await?; if after_stale_owner != after_apply { @@ -974,6 +973,22 @@ async fn removed_timer_fences_predecessor_process( } harness.crash_all_replicas()?; + // The hook worker polls every 100 ms and can refuse the predecessor + // throughout activation and the wait for the parked timer worker. + let hook_warning_maximum = usize::try_from( + activation_started + .elapsed() + .as_millis() + .div_ceil(100) + .saturating_add(4), + ) + .map_err(|_| "timer-removal hook warning bound exceeded the host integer range".to_owned())?; + for code in [ + "hook.claim.identity_refused", + "hook.worker.iteration_failed", + ] { + harness.expect_non_info_code_range(predecessor, code, 0, hook_warning_maximum)?; + } harness.disable_before_claim_barrier(); harness.start_replicas(1).await?; let cancelled = wait_for_terminal_state(harness, &record_id, "cancelled").await?; diff --git a/crates/registry-breg/tests/proposal_additional_forms.rs b/crates/registry-breg/tests/proposal_additional_forms.rs new file mode 100644 index 0000000000..35c7e0fd34 --- /dev/null +++ b/crates/registry-breg/tests/proposal_additional_forms.rs @@ -0,0 +1,398 @@ +// SPDX-License-Identifier: Apache-2.0 +#[path = "support/proposal_hooks_model.rs"] +#[allow(dead_code)] +mod model; + +use registry_breg::{ + compiler::{compile_project, CompileProfile}, + contract::parse_project_json, + diagnostics::CompileFailure, + immediate_actions::migration_review_revision, + model::CompiledRegistry, +}; +use serde_json::{json, Value}; + +const PROPOSAL: &str = "/actions/correct-name/execution/proposal"; + +fn reviewed_action() -> Value { + let mut source = model::source(json!([])); + source["reviewAuthorities"] = + json!({"local-review":{"protocol":"id.registrystack.org/protocols/review/v1"}}); + source.pointer_mut(PROPOSAL).unwrap()["review"] = json!({ + "type":"required", "authority":"local-review", "source":"proposal-test", + "policy":{"id":"name-correction"} + }); + source +} + +fn form() -> Value { + json!({"inputs":[ + {"id":"explanation","type":"string","maximumLength":240, + "required":true,"classification":"restricted"}, + {"id":"confirmed","type":"boolean","classification":"restricted"} + ]}) +} + +fn compile(source: &Value) -> Result { + let project = parse_project_json(&serde_json::to_vec(source).unwrap())?; + compile_project(&project, &[], CompileProfile::Authoring) +} + +#[test] +fn additional_forms_compile_as_separate_review_metadata() { + let mut source = reviewed_action(); + let ordinary = compile(&source).unwrap(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + let with_form = compile(&source).unwrap(); + let before = &ordinary.actions().actions[0]; + let after = &with_form.actions().actions[0]; + let before_execution = serde_json::to_value(&before.execution).unwrap(); + let execution = serde_json::to_value(&after.execution).unwrap(); + let fields = &execution["proposal"]["additionalForms"]["clarification"]["inputs"]; + assert_eq!(fields[0]["id"], "explanation"); + assert_eq!(fields[0]["required"], true); + assert_eq!(fields[0]["classification"], "restricted"); + assert_eq!(fields[1]["id"], "confirmed"); + assert!(before_execution["proposal"] + .get("additionalForms") + .is_none()); + assert_eq!(after.inputs, before.inputs); + assert_eq!(after.effects, before.effects); + assert_eq!(after.definition_revision, before.definition_revision); + assert_eq!( + migration_review_revision(after), + migration_review_revision(before) + ); + assert_eq!( + execution["proposal"]["permissions"], + before_execution["proposal"]["permissions"] + ); + assert_eq!(with_form.actions().routes, ordinary.actions().routes); + assert_ne!(with_form.revision(), ordinary.revision()); +} + +#[test] +fn additional_forms_refuse_nonreviewed_actions_and_invalid_inputs() { + let mut source = reviewed_action(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + let mut no_review = source.clone(); + no_review.pointer_mut(PROPOSAL).unwrap()["review"] = json!({"type":"none"}); + let mut empty = source.clone(); + empty.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"] = json!([]); + let mut duplicate = source.clone(); + duplicate.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"][1] + ["id"] = json!("explanation"); + let mut reference = source.clone(); + reference.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"][1] = + json!({"id":"linked","type":"reference","target":"target","classification":"restricted"}); + let mut pattern = source.clone(); + pattern.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"][0] + ["pattern"] = json!("^yes$"); + let mut vocabulary = source.clone(); + vocabulary.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"][1] = json!({"id":"category","type":"vocabulary-code","vocabulary":"categories","values":["a"],"classification":"restricted"}); + let mut invalid_option = source.clone(); + invalid_option.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"] + [1]["values"] = json!([]); + let mut lookalike = source.clone(); + lookalike.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = + json!({"extra-details":form(), "extra_details":form()}); + let mut too_many = source.clone(); + for index in 0..8 { + too_many.pointer_mut(PROPOSAL).unwrap()["additionalForms"][format!("form-{index}")] = + form(); + } + let mut too_many_inputs = source.clone(); + too_many_inputs.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"] = + json!((0..17).map(|index| json!({"id":format!("input-{index}"),"type":"boolean","classification":"restricted"})).collect::>()); + for (invalid, code) in [ + (no_review, "breg.additional-form.review-required"), + (empty, "breg.additional-form.input-count"), + (duplicate, "breg.action.input-id-duplicate"), + (reference, "breg.additional-form.input-type"), + (pattern, "breg.additional-form.input-pattern"), + (vocabulary, "breg.additional-form.input-type"), + (invalid_option, "config.invalid-value"), + (lookalike, "breg.additional-form.id-collision"), + (too_many, "breg.additional-form.count"), + (too_many_inputs, "breg.additional-form.input-count"), + ] { + let failure = compile(&invalid).unwrap_err(); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code), + "{failure:?}" + ); + } +} + +/// Form values reach only a person reading for themselves. A profile whose +/// callers can never be that person, an agent, a service or a task-granted +/// profile, may not hold a review-context field that shows a form. +#[test] +fn an_additional_form_context_field_is_refused_to_profiles_no_person_reads_through() { + let mut source = reviewed_action(); + let proposal = source.pointer_mut(PROPOSAL).unwrap(); + proposal["additionalForms"] = json!({"clarification":form()}); + proposal["reviewContext"] = json!({"id":"form-context","fields":{ + "value":{"type":"input","input":"value"}, + "clarification":{"type":"additional-form","form":"clarification"}}}); + let reviewer = |fields: Value| { + json!({"principalClaim":"sub","requiredScopes":["proposal:review"],"permissions":{"proposals":[ + {"action":"correct-name","operations":["get-review-context"],"readableContextFields":fields, + "targets":[{"recordType":"target","rowBoundaries":"unrestricted"}]}]}}) + }; + let mut human = source.clone(); + let mut person = reviewer(json!(["value", "clarification"])); + person["actorKind"] = json!("human"); + human["accessProfiles"]["reviewer"] = person; + compile(&human).expect("a human reviewer may read the form field"); + let mut unbound = source.clone(); + unbound["accessProfiles"]["reviewer"] = reviewer(json!(["value", "clarification"])); + compile(&unbound).expect("a profile written for any kind may serve a person"); + + for (kind, task) in [("agent", false), ("service", false), ("agent", true)] { + let mut invalid = source.clone(); + let mut profile = reviewer(json!(["value", "clarification"])); + profile["actorKind"] = json!(kind); + profile["requesterClients"] = json!(["agent-client"]); + if task { + profile["requiredPurposes"] = json!(["registry-administration"]); + profile["taskGrant"] = json!({"sourceIssuer":"https://casework.example"}); + } + invalid["accessProfiles"]["reviewer"] = profile.clone(); + let failure = compile(&invalid).unwrap_err(); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == "breg.additional-form.context-reader-invalid"), + "{kind} task={task}: {failure:?}" + ); + // The same profile without the form field compiles. + profile["permissions"]["proposals"][0]["readableContextFields"] = json!(["value"]); + let mut valid = source.clone(); + valid["accessProfiles"]["reviewer"] = profile; + compile(&valid).unwrap_or_else(|failure| panic!("{kind} task={task}: {failure:?}")); + } +} + +#[cfg(feature = "schema")] +#[test] +fn author_inspection_exposes_a_closed_form_contract_with_its_own_digest() { + let mut source = reviewed_action(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + let compiled = compile(&source).unwrap(); + let action = &compiled.actions().actions[0]; + let inspected = registry_breg::artifacts::inspect_action(action); + let contract = &inspected["additionalFormContracts"]["clarification"]; + let digest = contract["digest"].as_str().unwrap(); + registry_review_protocol::ContentDigest::parse(digest).unwrap(); + let validator = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft202012) + .compile(&contract["schema"]) + .unwrap(); + assert!(validator.is_valid(&json!({"explanation":"Details", "confirmed":true}))); + for rejected in [ + json!({}), + json!({"confirmed":true}), + json!({"explanation":"Details", "confirmed":null}), + json!({"explanation":"Details", "value":"not a form field"}), + json!({"explanation":"x".repeat(241)}), + ] { + assert!(!validator.is_valid(&rejected)); + } + + let mut presented = source.clone(); + let inputs = presented.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"] + ["inputs"] + .as_array_mut() + .unwrap(); + inputs[0]["display"] = json!({"label":"Explain what changed"}); + inputs.swap(0, 1); + let presented = compile(&presented).unwrap(); + let presented = registry_breg::artifacts::inspect_action(&presented.actions().actions[0]); + assert_eq!( + presented["additionalFormContracts"]["clarification"]["digest"], + digest + ); + + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"][0] + ["classification"] = json!("internal"); + let reclassified = compile(&source).unwrap(); + let after = &reclassified.actions().actions[0]; + let reclassified = registry_breg::artifacts::inspect_action(after); + assert_ne!( + reclassified["additionalFormContracts"]["clarification"]["digest"], + digest + ); + assert_eq!(after.definition_revision, action.definition_revision); +} + +#[cfg(feature = "schema")] +#[test] +fn generated_authoring_schema_checks_the_form_shape() { + let schemas = registry_breg::schema::documents().unwrap(); + let schema: Value = serde_json::from_str(&schemas["registry-project.schema.json"]).unwrap(); + let validator = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft202012) + .compile(&schema) + .unwrap(); + let mut source = reviewed_action(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + if let Err(errors) = validator.validate(&source) { + panic!( + "the reviewed form must match its schema: {:?}", + errors.collect::>() + ); + } + let mut over_limit = source.clone(); + for index in 0..8 { + over_limit.pointer_mut(PROPOSAL).unwrap()["additionalForms"][format!("form-{index}")] = + form(); + } + assert!(!validator.is_valid(&over_limit)); + let inputs = &mut over_limit.pointer_mut(PROPOSAL).unwrap()["additionalForms"]; + *inputs = json!({"clarification":{"inputs": []}}); + assert!(!validator.is_valid(&over_limit)); + for input in [ + json!({"id":"missing-bound","type":"string","classification":"restricted"}), + json!({"id":"linked","type":"reference","target":"target","classification":"restricted"}), + json!({"id":"invalid-ref","typeRef":"name-type","classification":"restricted"}), + json!({"id":"category","type":"vocabulary-code","vocabulary":"categories","values":["a"],"classification":"restricted"}), + json!({"id":"confirmed","type":"boolean","classification":"restricted","values":[]}), + json!({"id":"pattern","type":"string","maximumLength":64,"classification":"restricted","pattern":"^yes$"}), + ] { + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"]["clarification"]["inputs"] = + json!([input]); + assert!(!validator.is_valid(&source)); + } +} + +#[test] +fn additional_form_entry_count_defaults_to_eight_and_accepts_both_boundaries() { + for (authored, expected) in [(None, 8), (Some(1), 1), (Some(32), 32)] { + let mut source = reviewed_action(); + let mut declaration = form(); + if let Some(count) = authored { + declaration["maximumCount"] = json!(count); + } + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = + json!({"clarification":declaration}); + let compiled = compile(&source).expect("a bounded entry count must compile"); + let execution = serde_json::to_value(&compiled.actions().actions[0].execution).unwrap(); + assert_eq!( + execution["proposal"]["additionalForms"]["clarification"]["maximumCount"], + expected + ); + } +} + +#[cfg(feature = "schema")] +#[test] +fn additional_form_entry_count_is_bounded_in_the_authoring_schema() { + let schemas = registry_breg::schema::documents().unwrap(); + let schema: Value = serde_json::from_str(&schemas["registry-project.schema.json"]).unwrap(); + let validator = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft202012) + .compile(&schema) + .unwrap(); + for (count, valid) in [(1, true), (32, true), (0, false), (33, false)] { + let mut source = reviewed_action(); + let mut declaration = form(); + declaration["maximumCount"] = json!(count); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = + json!({"clarification":declaration}); + assert_eq!(validator.is_valid(&source), valid, "maximumCount {count}"); + assert_eq!(compile(&source).is_ok(), valid, "maximumCount {count}"); + } +} + +#[test] +fn additional_form_grants_require_a_declared_form_and_the_matching_operation() { + for (key, operation, name, valid) in [ + ("readableForms", "get", "clarification", true), + ("writableForms", "add", "clarification", true), + ("readableForms", "get", "unknown", false), + ("writableForms", "add", "unknown", false), + ("readableForms", "add", "clarification", false), + ("writableForms", "get", "clarification", false), + ] { + let mut source = reviewed_action(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["operations"] = json!([operation]); + grant.as_object_mut().unwrap().remove("readableAttachments"); + grant.as_object_mut().unwrap().remove("writableAttachments"); + grant.as_object_mut().unwrap().remove("readableInputs"); + grant[key] = json!([name]); + if valid { + compile(&source).expect("a declared form with its matching operation must compile"); + } else { + assert_diagnostic(&source, "breg.additional-form.grant-invalid"); + } + } +} + +#[test] +fn additional_form_context_fields_must_name_a_declared_form() { + let mut source = reviewed_action(); + let proposal = source.pointer_mut(PROPOSAL).unwrap(); + proposal["additionalForms"] = json!({"clarification":form()}); + proposal["reviewContext"]["fields"]["clarification"] = + json!({"type":"additional-form","form":"clarification"}); + compile(&source).expect("a context field may disclose a declared form"); + source.pointer_mut(PROPOSAL).unwrap()["reviewContext"]["fields"]["clarification"]["form"] = + json!("unknown"); + assert_diagnostic(&source, "breg.additional-form.context-unknown"); +} + +fn assert_diagnostic(source: &Value, code: &str) { + let failure = compile(source).unwrap_err(); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code), + "expected {code}: {failure:?}" + ); +} + +#[test] +fn add_form_openapi_binds_the_input_shape_and_publishes_exact_refusals() { + let mut source = reviewed_action(); + source.pointer_mut(PROPOSAL).unwrap()["additionalForms"] = json!({"clarification":form()}); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["operations"] + .as_array_mut() + .unwrap() + .push(json!("add")); + grant["writableForms"] = json!(["clarification"]); + let registry = compile(&source).unwrap(); + let api: Value = + serde_json::from_slice(®istry.artifacts().entries()["generated/openapi.json"].bytes) + .unwrap(); + let operation = &api["paths"]["/v1/proposals/{proposal_id}/additional-forms/{form_id}"]["post"]; + assert_eq!(operation["operationId"], "proposals.add-form"); + let schema = &operation["requestBody"]["content"]["application/json"]["schema"]; + let validator = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft202012) + .compile(schema) + .unwrap(); + assert!(validator.is_valid(&json!({"input":{"explanation":"Details","confirmed":true}}))); + assert!(!validator.is_valid(&json!({"input":{"explanation":25}}))); + for (status, code) in [ + ("404", "proposal.form-undeclared"), + ("409", "proposal.form-limit-reached"), + ] { + assert_eq!( + operation["responses"][status]["content"]["application/problem+json"]["examples"][code] + ["value"]["code"], + code, + ); + } + assert!(operation + .pointer("/responses/200/content/application~1json/schema/properties/additionalForms") + .is_some()); +} diff --git a/crates/registry-breg/tests/proposal_asks.rs b/crates/registry-breg/tests/proposal_asks.rs index 0fa3baffd2..9c128100ae 100644 --- a/crates/registry-breg/tests/proposal_asks.rs +++ b/crates/registry-breg/tests/proposal_asks.rs @@ -148,3 +148,35 @@ fn answer_openapi_declares_the_exact_problem_set_and_closed_ask_documents() { assert_eq!(body["additionalProperties"], false); assert_eq!(body["properties"]["additions"]["maxItems"], 32); } + +#[test] +fn a_messaged_event_is_selected_by_unfiltered_hooks_and_requires_a_side() { + use registry_breg::contract::ProposalEventTransition; + use registry_breg::proposal_hooks::{matching_transitions, proposal_event_schema}; + use serde_json::json; + use std::collections::BTreeSet; + + assert!(matching_transitions(&BTreeSet::new()) + .any(|transition| transition == ProposalEventTransition::Messaged)); + assert!( + !matching_transitions(&BTreeSet::from([ProposalEventTransition::Added])) + .any(|transition| transition == ProposalEventTransition::Messaged) + ); + let event = json!({ + "actionId":"correct-name","actionRevision":format!("sha256:{}","a".repeat(64)), + "proposalId":"00000000-0000-4000-8000-000000000001","submissionVersion":1,"revision":3, + "fromState":"submitted","state":"submitted","transition":"messaged","effectDigest":null, + "authorityKind":"caller","systemApplyGrantRevision":null,"turn":"party" + }); + let schema = proposal_event_schema(); + let validator = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft202012) + .compile(&schema) + .unwrap(); + assert!(!validator.is_valid(&event)); + let mut event = event; + event["messageFrom"] = json!("official"); + assert!(validator.is_valid(&event)); + event["transition"] = json!("added"); + assert!(!validator.is_valid(&event)); +} diff --git a/crates/registry-breg/tests/proposal_messages_compiler.rs b/crates/registry-breg/tests/proposal_messages_compiler.rs new file mode 100644 index 0000000000..33554a0332 --- /dev/null +++ b/crates/registry-breg/tests/proposal_messages_compiler.rs @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! An Action opens a message thread on its Proposals by declaring +//! `execution.proposal.messages`. The thread needs no review, and the +//! declaration changes the registry package but not the Action revision. +#[path = "support/proposal_hooks_model.rs"] +#[allow(dead_code)] +mod model; + +use registry_breg::{ + compiler::{compile_project, CompileProfile}, + contract::parse_project_json, + diagnostics::CompileFailure, + immediate_actions::migration_review_revision, + model::CompiledRegistry, +}; +use serde_json::{json, Value}; + +const PROPOSAL: &str = "/actions/correct-name/execution/proposal"; +const CLERK_GRANT: &str = "/accessProfiles/clerk/permissions/proposals/0"; + +fn compile(source: &Value) -> Result { + let project = parse_project_json(&serde_json::to_vec(source).unwrap())?; + compile_project(&project, &[], CompileProfile::Authoring) +} + +fn compiled(source: &Value) -> CompiledRegistry { + compile(source).unwrap_or_else(|failure| panic!("{:?}", failure.diagnostics())) +} + +fn with_messages(mut source: Value, messages: Value) -> Value { + source.pointer_mut(PROPOSAL).unwrap()["messages"] = messages; + source +} + +fn required_review(mut source: Value) -> Value { + source["reviewAuthorities"] = + json!({"local-review":{"protocol":"id.registrystack.org/protocols/review/v1"}}); + source.pointer_mut(PROPOSAL).unwrap()["review"] = json!({ + "type":"required", "authority":"local-review", "source":"proposal-test", + "policy":{"id":"name-correction"} + }); + source +} + +fn execution(registry: &CompiledRegistry) -> Value { + serde_json::to_value(®istry.actions().actions[0].execution).unwrap() +} + +fn refusals(source: &Value) -> Vec<(String, String)> { + match compile(source) { + Ok(_) => panic!("project compiled; expected a refusal"), + Err(failure) => failure + .diagnostics() + .iter() + .map(|diagnostic| (diagnostic.code.clone(), diagnostic.path.clone())) + .collect(), + } +} + +/// Presence opens the thread, with or without review (D6), and leaves the +/// Action revision alone: requests already in flight get the thread at +/// activation. +#[test] +fn messages_open_a_thread_with_or_without_review_without_changing_the_action_revision() { + for base in [ + model::source(json!([])), + required_review(model::source(json!([]))), + ] { + let omitted = compiled(&base); + let enabled = compiled(&with_messages(base.clone(), json!({"maximumCount": 50}))); + assert_ne!(enabled.revision(), omitted.revision()); + let before = &omitted.actions().actions[0]; + let after = &enabled.actions().actions[0]; + assert!(execution(&omitted)["proposal"].get("messages").is_none()); + assert_eq!( + execution(&enabled)["proposal"]["messages"], + json!({"maximumCount": 50}) + ); + assert_eq!( + execution(&enabled)["proposal"]["permissions"], + execution(&omitted)["proposal"]["permissions"] + ); + assert_eq!(before.definition_revision, after.definition_revision); + assert_eq!( + migration_review_revision(before), + migration_review_revision(after) + ); + assert_eq!(omitted.actions().routes, enabled.actions().routes); + } +} + +#[test] +fn the_message_count_defaults_to_two_hundred_and_stays_within_one_to_one_thousand() { + let defaulted = compiled(&with_messages(model::source(json!([])), json!({}))); + assert_eq!( + execution(&defaulted)["proposal"]["messages"]["maximumCount"], + 200 + ); + for accepted in [1, 1000] { + let registry = compiled(&with_messages( + model::source(json!([])), + json!({ "maximumCount": accepted }), + )); + assert_eq!( + execution(®istry)["proposal"]["messages"]["maximumCount"], + accepted + ); + } + for refused in [json!(0), json!(1001), json!(-1), json!("200")] { + let source = with_messages( + model::source(json!([])), + json!({ "maximumCount": refused.clone() }), + ); + assert!( + refusals(&source) + .iter() + .any(|(_, path)| path.contains("messages")), + "maximumCount {refused} was not refused at the messages key" + ); + } + let unknown = with_messages(model::source(json!([])), json!({"maximumBytes": 10})); + assert!(refusals(&unknown) + .iter() + .any(|(_, path)| path.contains("messages"))); +} + +/// The archived boolean is not the key: one concept has one word. +#[test] +fn applicant_correspondence_is_not_a_proposal_key() { + let mut source = model::source(json!([])); + source.pointer_mut(PROPOSAL).unwrap()["applicantCorrespondence"] = json!(true); + assert!(compile(&source).is_err()); +} + +#[test] +fn the_message_operation_needs_a_thread_and_a_human_profile() { + // Owner and staff grants may hold `message` on an Action with a thread. + let mut source = with_messages(model::source(json!([])), json!({"maximumCount": 20})); + source.pointer_mut(CLERK_GRANT).unwrap()["operations"] = + json!(["get", "edit", "submit", "cancel", "apply", "message"]); + let mut staff = source["accessProfiles"]["clerk"].clone(); + staff["default"] = json!(false); + staff["permissions"]["actions"] = json!([]); + staff["permissions"]["records"] = json!([]); + let grant = &mut staff["permissions"]["proposals"][0]; + grant.as_object_mut().unwrap().remove("party"); + grant["operations"] = json!(["get-review-context", "message"]); + grant["readableInputs"] = json!([]); + grant["readableAttachments"] = json!([]); + grant["writableAttachments"] = json!([]); + grant["readableContextFields"] = json!(["value"]); + source["accessProfiles"]["reviewer"] = staff.clone(); + let registry = compiled(&source); + let permissions = execution(®istry)["proposal"]["permissions"].to_string(); + assert!(permissions.contains("\"message\""), "{permissions}"); + + // The same grant on an Action without a thread is refused. + let mut without = source.clone(); + without + .pointer_mut(PROPOSAL) + .unwrap() + .as_object_mut() + .unwrap() + .remove("messages"); + assert!( + refusals(&without) + .iter() + .any(|(code, _)| code == "breg.proposal.message-grant-invalid"), + "{:?}", + refusals(&without) + ); + + // Agents and services neither read nor write messages. + for kind in ["agent", "service"] { + let mut machine = source.clone(); + machine["accessProfiles"]["reviewer"]["actorKind"] = json!(kind); + // A standing agent reads review context only for a named client. + machine["accessProfiles"]["reviewer"]["requesterClients"] = json!(["assistant-client"]); + assert!( + refusals(&machine) + .iter() + .any(|(code, path)| code == "breg.proposal.message-grant-invalid" + && path.contains("reviewer")), + "{kind}: {:?}", + refusals(&machine) + ); + } +} + +#[test] +fn message_openapi_describes_the_three_routes_and_their_preconditions() { + let mut source = with_messages(model::source(json!([])), json!({})); + source.pointer_mut(CLERK_GRANT).unwrap()["operations"] = + json!(["get", "edit", "submit", "cancel", "apply", "message"]); + let registry = compiled(&source); + let api: Value = + serde_json::from_slice(®istry.artifacts().entries()["generated/openapi.json"].bytes) + .unwrap(); + let thread = &api["paths"]["/v1/proposals/{proposal_id}/messages"]; + let send = &thread["post"]; + assert_eq!(thread["get"]["operationId"], "proposals.list-messages"); + assert_eq!(send["operationId"], "proposals.message"); + for header in ["If-Match", "Idempotency-Key"] { + assert!(send["parameters"].as_array().unwrap().iter().any(|entry| { + entry["in"] == "header" && entry["name"] == header && entry["required"] == true + })); + } + assert!(send + .pointer("/responses/409/content/application~1problem+json/examples/proposal.message-limit-reached") + .is_some()); + let read = &api["paths"]["/v1/proposals/{proposal_id}/messages/read"]["post"]; + assert_eq!(read["operationId"], "proposals.mark-messages-read"); + assert!(read["parameters"] + .as_array() + .unwrap() + .iter() + .all(|entry| entry["name"] != "If-Match" && entry["name"] != "Idempotency-Key")); + let response_schema = "/responses/200/content/application~1json/schema"; + let send_schema = send.pointer(response_schema).unwrap(); + for path in [ + "/oneOf/0/properties/messages", + "/oneOf/1/properties/context/properties/messages", + "/oneOf/2", + ] { + let messages = send_schema.pointer(path).unwrap(); + assert_eq!(messages["properties"]["count"]["maximum"], 2000, "{path}"); + assert_eq!(messages["properties"]["unread"]["maximum"], 1000, "{path}"); + assert_eq!(messages["properties"]["items"]["maxItems"], 20, "{path}"); + } + let list = thread["get"].pointer(response_schema).unwrap(); + assert_eq!(list["properties"]["items"]["maxItems"], 50); +} diff --git a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs index 32aa3fc7f8..576fd70639 100644 --- a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs +++ b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs @@ -40,7 +40,9 @@ const SOURCE_REVISION: &str = "rehearsal-source-revision"; // erasure markers. The migration ledger bounds statement checksums at 4,096 entries. // The fingerprint also includes the Proposal additions and review ask tables // and their indexes, the application-rebase blocked reason, and the Proposal -// subject reference column and its partial index. +// subject reference column and its partial index, the Proposal form entry +// and ask citation tables with the form entry index, and the message table +// with each side's read position on the Proposal state row. const PORTABLE_SCHEMA_FINGERPRINT: &str = "sha256:e0aa036bd82f0274b567be71a63f573cb2dc16e19de231c65f4eed701c081688"; const FIXTURE_JOURNEYS: &[u8] = br#"apiVersion: id.registrystack.org/formats/breg/journeys/v1 diff --git a/crates/registry-breg/tests/support/proposal_additions.rs b/crates/registry-breg/tests/support/proposal_additions.rs index af6de5d906..3d2c69d096 100644 --- a/crates/registry-breg/tests/support/proposal_additions.rs +++ b/crates/registry-breg/tests/support/proposal_additions.rs @@ -930,3 +930,446 @@ async fn additions_refuse_draft_approved_rejected_cancelled_and_revised_work() { fixture.finish().await; } } + +#[tokio::test] +async fn proposal_form_storage_exists_even_before_any_entry_is_added() { + let fixture = fixture().await; + for table in [ + "registry_proposal_form_entries", + "registry_proposal_review_ask_form_entries", + ] { + let qualified = format!("registry_internal.{table}"); + let installed: bool = fixture + .database + .admin + .query_one("SELECT to_regclass($1) IS NOT NULL", &[&qualified]) + .await + .unwrap() + .get(0); + assert!(installed, "missing form storage: {table}"); + } + fixture.finish().await; +} + +#[tokio::test] +async fn add_form_route_reports_an_undeclared_form_on_a_visible_submission() { + let fixture = fixture().await; + let submitted = submitted_addition_proposal(&fixture, "undeclared-form").await; + let before = serde_json::to_value(&submitted).unwrap(); + let etag = before["additions"]["other"]["links"]["add"]["ifMatch"] + .as_str() + .expect("current submission ETag"); + let response = reqwest::Client::new() + .post(format!( + "{}/v1/proposals/{}/additional-forms/unknown?accessProfile=clerk", + fixture.http.base_url, + submitted.id() + )) + .header("if-match", etag) + .header("idempotency-key", "unknown-form-entry") + .json(&json!({"input":{}})) + .send() + .await + .unwrap(); + assert_eq!(response.status(), 404); + let problem: Value = response.json().await.expect("typed Proposal refusal"); + assert_eq!(problem["code"], "proposal.form-undeclared", "{problem}"); + fixture.finish().await; +} + +#[tokio::test] +async fn adding_a_form_entry_preserves_the_submission_and_fences_replay_and_limits() { + let mut source = addition_source(); + source["actions"]["correct-name"]["execution"]["proposal"]["additionalForms"] = json!({ + "household-details":{ + "maximumCount":1, + "inputs":[{"id":"household-size","type":"int64","required":true,"classification":"restricted"}] + } + }); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["readableForms"] = json!(["household-details"]); + grant["writableForms"] = json!(["household-details"]); + let fixture = authority::with_source(source).await; + let submitted = submitted_addition_proposal(&fixture, "form-entries").await; + let before = serde_json::to_value(&submitted).unwrap(); + let etag = before["additions"]["other"]["links"]["add"]["ifMatch"] + .as_str() + .expect("current submission ETag"); + let http = reqwest::Client::new(); + let url = format!( + "{}/v1/proposals/{}/additional-forms/household-details?accessProfile=clerk", + fixture.http.base_url, + submitted.id() + ); + let add = |etag: Option<&str>, key: &str, input: Value| { + let request = http + .post(&url) + .header("idempotency-key", key) + .json(&json!({"input":input})); + match etag { + Some(etag) => request.header("if-match", etag), + None => request, + } + .send() + }; + for (input, field) in [ + (json!({}), "/input/householdSize"), + (json!({"householdSize":"four"}), "/input/householdSize"), + (json!({"householdSize":4,"unknown":true}), "/input/unknown"), + ] { + let response = add(Some(etag), "invalid-form", input).await.unwrap(); + assert_eq!(response.status(), 400); + let problem: Value = response.json().await.unwrap(); + assert_eq!(problem["code"], "request.invalid", "{problem}"); + assert_eq!(problem["fieldPath"], field, "{problem}"); + } + let input = json!({"householdSize":4}); + let missing = add(None, "missing-if-match", input.clone()).await.unwrap(); + assert_eq!(missing.status(), 428); + assert_eq!( + missing.json::().await.unwrap()["code"], + "precondition.required" + ); + let added = fixture + .http + .client + .add_proposal_form_entry( + &submitted, + "household-details", + input.as_object().unwrap(), + &key("first-form"), + ) + .await + .unwrap(); + let next = added.metadata.etag().unwrap().as_str().to_owned(); + assert_ne!(next, etag); + assert!(added.value.form_entry_id().is_some()); + let added = serde_json::to_value(added.value).unwrap(); + assert_eq!(added["submissionVersion"], before["submissionVersion"]); + assert_eq!(added["effectDigest"], before["effectDigest"]); + assert!(added["revision"].as_u64().unwrap() > before["revision"].as_u64().unwrap()); + let form = &added["additionalForms"]["household-details"]; + assert_eq!(form["maximumCount"], 1); + assert_eq!(form["items"].as_array().unwrap().len(), 1); + assert_eq!(form["items"][0]["input"], input); + let entry = uuid::Uuid::parse_str(form["items"][0]["id"].as_str().unwrap()).unwrap(); + assert_eq!( + form["links"]["add"]["availability"]["reason"], + "limit-reached" + ); + + let replay = add(Some(etag), "first-form", input.clone()).await.unwrap(); + assert_eq!(replay.status(), 200); + assert_eq!(replay.headers()["etag"], next); + assert_eq!( + replay.bytes().await.unwrap().as_ref(), + registry_platform_canonical_json::canonicalize_json(&added).unwrap() + ); + for (fence, key, input, status, code) in [ + ( + etag, + "first-form", + json!({"householdSize":5}), + 409, + "idempotency.key-reused", + ), + ( + etag, + "stale-form", + input.clone(), + 412, + "precondition.failed", + ), + ( + &next, + "excess-form", + input.clone(), + 409, + "proposal.form-limit-reached", + ), + ] { + let response = add(Some(fence), key, input).await.unwrap(); + assert_eq!(response.status(), status); + assert_eq!(response.json::().await.unwrap()["code"], code); + } + + let rows = fixture.database.admin.query( + "SELECT entry_id, input, contract_digest FROM registry_internal.registry_proposal_form_entries", + &[], + ).await.unwrap(); + assert_eq!(rows.len(), 1); + assert_eq!(rows[0].get::<_, uuid::Uuid>(0), entry); + assert_eq!(rows[0].get::<_, Value>(1), input); + registry_review_client::ContentDigest::parse(&rows[0].get::<_, String>(2)).unwrap(); + + let client = &fixture.http.client; + let current = client.read_proposal(&submitted).await.unwrap().value; + let current_value = serde_json::to_value(¤t).unwrap(); + assert_eq!( + current_value["additionalForms"]["household-details"]["items"], + form["items"] + ); + let cancelled = client + .execute_proposal( + &client + .prepare_proposal(¤t, "cancel", json!({}), &key("after-form-cancel")) + .unwrap(), + ) + .await + .unwrap() + .value; + let cancelled = serde_json::to_value(cancelled).unwrap(); + assert_eq!(cancelled["state"], "cancelled"); + assert_eq!( + cancelled["additionalForms"]["household-details"]["items"], + form["items"] + ); + fixture.finish().await; +} + +/// A source whose clerk writes one form it cannot read and reads another it +/// cannot write, so each grant key is tested on its own. +fn split_form_source() -> Value { + let mut source = addition_source(); + source["actions"]["correct-name"]["execution"]["proposal"]["additionalForms"] = json!({ + "household-details":{ + "maximumCount":2, + "inputs":[{"id":"household-size","type":"int64","required":true,"classification":"restricted"}] + }, + "housing-details":{ + "maximumCount":2, + "inputs":[{"id":"rented","type":"boolean","required":true,"classification":"restricted"}] + } + }); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["writableForms"] = json!(["household-details"]); + grant["readableForms"] = json!(["housing-details"]); + source +} + +async fn add_form( + base: &str, + id: &str, + form: &str, + etag: &str, + key: &str, + input: Value, +) -> reqwest::Response { + reqwest::Client::new() + .post(format!( + "{base}/v1/proposals/{id}/additional-forms/{form}?accessProfile=clerk" + )) + .header("if-match", etag) + .header("idempotency-key", key) + .json(&json!({ "input": input })) + .send() + .await + .unwrap() +} + +/// Only `writableForms` admits a write and only `readableForms` serves the +/// entries; a caller who is not the Proposal's party learns nothing. +#[tokio::test] +async fn form_entries_need_their_own_write_and_read_grants() { + let fixture = authority::with_source(split_form_source()).await; + let submitted = submitted_addition_proposal(&fixture, "split-forms").await; + let before = serde_json::to_value(&submitted).unwrap(); + let etag = before["additions"]["other"]["links"]["add"]["ifMatch"] + .as_str() + .unwrap() + .to_owned(); + let base = fixture.http.base_url.clone(); + + let refused = add_form( + &base, + submitted.id(), + "housing-details", + &etag, + "unwritable-form", + json!({"rented":true}), + ) + .await; + assert_eq!(refused.status(), 403); + assert_eq!( + refused.json::().await.unwrap()["code"], + "profile.not-authorized" + ); + + let stranger = fixture.client_for(claims("stranger", "zone-a")).await; + let concealed = add_form( + &stranger.base_url, + submitted.id(), + "household-details", + &etag, + "stranger-form", + json!({"householdSize":3}), + ) + .await; + assert_eq!(concealed.status(), 404); + // The owner outside the Proposal's row boundary is concealed too. + let moved = fixture.client_for(claims("author", "zone-b")).await; + let hidden = add_form( + &moved.base_url, + submitted.id(), + "household-details", + &etag, + "hidden-form", + json!({"householdSize":3}), + ) + .await; + assert_eq!(hidden.status(), 404); + assert_eq!( + hidden.json::().await.unwrap()["code"], + "resource.not-found" + ); + // A malformed Proposal ID is concealed like an unknown one. + let malformed = add_form( + &base, + "not-a-proposal", + "household-details", + &etag, + "malformed-form", + json!({"householdSize":3}), + ) + .await; + assert_eq!(malformed.status(), 404); + assert_eq!( + malformed.json::().await.unwrap()["code"], + "resource.not-found" + ); + + let added = add_form( + &base, + submitted.id(), + "household-details", + &etag, + "unreadable-form", + json!({"householdSize":3}), + ) + .await; + assert_eq!(added.status(), 200); + let added: Value = added.json().await.unwrap(); + assert!(added["formEntryId"].is_string(), "{added}"); + let current = fixture + .http + .client + .read_proposal(&submitted) + .await + .unwrap() + .value; + for document in [added, serde_json::to_value(¤t).unwrap()] { + let forms = &document["additionalForms"]; + assert!( + forms["household-details"].get("items").is_none(), + "an unreadable form served its entries: {forms}" + ); + assert_eq!(forms["housing-details"]["items"], json!([]), "{forms}"); + assert!( + !document.to_string().contains("householdSize"), + "{document}" + ); + } + let rows: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_form_entries", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(rows, 1); + fixture.finish().await; +} + +/// A form entry joins an open review only: once the review is decided, or +/// the submission is revised, the add route refuses the current ETag. +#[tokio::test] +async fn form_entries_refuse_a_decided_review_and_a_revised_submission() { + for state in ["approved", "revised"] { + let review = std::sync::Arc::new(LocalReview { + calls: 0.into(), + mode: 0.into(), + result_id: uuid::Uuid::new_v4(), + }); + let injected = review.clone(); + let fixture = client_http::ClientFixture::start_with_mutations( + compile(split_form_source()), + claims("author", "zone-a"), + move |mutations| { + mutations.with_proposal_review_substitute_for_test(local_review_binding(), injected) + }, + ) + .await; + let client = &fixture.http.client; + let mut current = submitted_addition_proposal(&fixture, &format!("{state}-form")).await; + if state == "approved" { + retain_queue_review( + &fixture, + ¤t, + &review, + registry_review_client::ReviewResultStatus::Approved, + false, + true, + ) + .await; + } else { + current = client + .execute_proposal( + &client + .prepare_proposal( + ¤t, + "revise", + json!({}), + &key(&format!("{state}-form-revise")), + ) + .unwrap(), + ) + .await + .unwrap() + .value; + } + let (status, headers) = { + let response = reqwest::Client::new() + .get(format!( + "{}/v1/proposals/{}?accessProfile=clerk", + fixture.http.base_url, + current.id() + )) + .send() + .await + .unwrap(); + (response.status(), response.headers().clone()) + }; + assert_eq!(status, 200, "{state}"); + let etag = headers["etag"].to_str().unwrap().to_owned(); + let refused = add_form( + &fixture.http.base_url, + current.id(), + "household-details", + &etag, + &format!("{state}-form-refused"), + json!({"householdSize":2}), + ) + .await; + assert_eq!(refused.status(), 412, "{state}"); + assert_eq!( + refused.json::().await.unwrap()["code"], + "precondition.failed", + "{state}" + ); + let rows: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_form_entries", + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!(rows, 0, "{state}"); + fixture.finish().await; + } +} diff --git a/crates/registry-breg/tests/support/proposal_additions_authority.rs b/crates/registry-breg/tests/support/proposal_additions_authority.rs index d14dab8114..f5ce068492 100644 --- a/crates/registry-breg/tests/support/proposal_additions_authority.rs +++ b/crates/registry-breg/tests/support/proposal_additions_authority.rs @@ -5,7 +5,7 @@ use std::sync::{ Arc, }; -async fn with_source(source: Value) -> client_http::ClientFixture { +pub(super) async fn with_source(source: Value) -> client_http::ClientFixture { let review = Arc::new(LocalReview { calls: 0.into(), mode: 0.into(), diff --git a/crates/registry-breg/tests/support/proposal_review_asks.rs b/crates/registry-breg/tests/support/proposal_review_asks.rs index b117edb0bc..1392ac90af 100644 --- a/crates/registry-breg/tests/support/proposal_review_asks.rs +++ b/crates/registry-breg/tests/support/proposal_review_asks.rs @@ -805,6 +805,44 @@ async fn matching_an_action_input_does_not_make_a_caller_the_proposal_subject() fixture.finish().await; } +#[tokio::test] +async fn ask_feed_refuses_a_form_id_on_an_answer_want_and_keeps_moving() { + let authority = Authority::start(false, true).await; + let fixture = fixture(&authority).await; + let id = submitted(&fixture, "ask-feed-want-contract").await; + let binding = retained_binding(&fixture, id).await; + accept(&fixture, id, &binding).await; + let (malformed, event) = announce(&authority, &binding); + authority + .state + .asks + .lock() + .unwrap() + .replies + .get_mut(&malformed) + .unwrap() + .1["wants"] = json!([{"kind":"answer","formId":"extra-details"}]); + let (valid, last) = announce(&authority, &binding); + + assert!(worker(&fixture, &authority).await.unwrap()); + let receipt = fixture.database.admin.query_one("SELECT state,error_code FROM registry_internal.registry_proposal_review_ask_feed_events WHERE event_id=$1", &[&event]).await.unwrap(); + assert_eq!(receipt.get::<_, String>(0), "refused"); + assert_eq!(receipt.get::<_, String>(1), "ask-protocol-refused"); + let mirrored = fixture.database.admin.query_one("SELECT ask_id FROM registry_internal.registry_proposal_review_asks WHERE proposal_id=$1", &[&id]).await.unwrap(); + assert_eq!(mirrored.get::<_, Uuid>(0), valid); + let checkpoint = fixture + .database + .admin + .query_one( + "SELECT cursor FROM registry_internal.registry_proposal_review_ask_feed_checkpoints", + &[], + ) + .await + .unwrap(); + assert_eq!(checkpoint.get::<_, Uuid>(0), last); + fixture.finish().await; +} + #[tokio::test] async fn ask_feed_turn_uses_the_shared_awaiting_party_rule_and_lists_only_live_unanswered_asks() { let authority = Authority::start(false, true).await; @@ -848,7 +886,14 @@ async fn answer_fixture_with_verification( authority: &Authority, verification: registry_breg::attachment_verification::AttachmentVerification, ) -> client_http::ClientFixture { - let source = answer_source(); + answer_fixture_from_source(authority, verification, answer_source()).await +} + +async fn answer_fixture_from_source( + authority: &Authority, + verification: registry_breg::attachment_verification::AttachmentVerification, + source: Value, +) -> client_http::ClientFixture { let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); let bindings = authority.registry.clone(); @@ -934,6 +979,25 @@ async fn request_as( key: Option<&str>, body: Value, ) -> (StatusCode, HeaderMap, Value) { + let (status, headers, bytes) = + request_bytes_as(fixture, caller, method, path, etag, key, body).await; + let value = if bytes.is_empty() { + Value::Null + } else { + serde_json::from_slice(&bytes).unwrap() + }; + (status, headers, value) +} + +async fn request_bytes_as( + fixture: &client_http::ClientFixture, + caller: VerifiedRequestClaims, + method: &str, + path: &str, + etag: Option<&str>, + key: Option<&str>, + body: Value, +) -> (StatusCode, HeaderMap, axum::body::Bytes) { use tower::ServiceExt; let mut req = axum::http::Request::builder() .method(method) @@ -962,12 +1026,80 @@ async fn request_as( let bytes = axum::body::to_bytes(response.into_body(), 1 << 20) .await .unwrap(); - let value = if bytes.is_empty() { - Value::Null - } else { - serde_json::from_slice(&bytes).unwrap() + (status, headers, bytes) +} + +#[tokio::test] +async fn applicant_message_replays_its_exact_receipt_after_answering_an_ask() { + let authority = Authority::start(false, true).await; + let mut source = answer_source(); + source["actions"]["correct-name"]["execution"]["proposal"]["messages"] = json!({}); + source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]["operations"] + .as_array_mut() + .unwrap() + .push(json!("message")); + let fixture = answer_fixture_from_source( + &authority, + registry_breg::attachment_verification::AttachmentVerification::Disabled, + source, + ) + .await; + let id = submitted(&fixture, "message-with-open-ask").await; + let binding = retained_binding(&fixture, id).await; + accept(&fixture, id, &binding).await; + let (ask, _) = announce(&authority, &binding); + worker(&fixture, &authority).await.unwrap(); + + let (_, headers, _) = request( + &fixture, + "GET", + &format!("/v1/proposals/{id}"), + None, + None, + Value::Null, + ) + .await; + let path = format!("/v1/proposals/{id}/messages"); + let etag = headers["etag"].to_str().unwrap(); + let body = json!({"text":"Thanks for the question."}); + let send = || { + request_bytes_as( + &fixture, + applicant(), + "POST", + &path, + Some(etag), + Some("message-with-open-ask"), + body.clone(), + ) }; - (status, headers, value) + let (status, held_headers, held_bytes) = send().await; + assert_eq!(status, StatusCode::OK); + let held: Value = serde_json::from_slice(&held_bytes).unwrap(); + assert_eq!(held["asks"][0]["state"], "open"); + assert!(held["asks"][0].get("answer").is_none()); + + let (status, _, answered) = request( + &fixture, + "POST", + &format!("/v1/proposals/{id}/asks/{ask}/answer"), + Some(held_headers["etag"].to_str().unwrap()), + Some("answer-after-message"), + json!({"text":"The date is correct."}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + assert_eq!(answered["asks"][0]["state"], "answered"); + + let (status, replay_headers, replay_bytes) = send().await; + assert_eq!(status, StatusCode::OK); + assert_eq!(replay_headers["etag"], held_headers["etag"]); + assert_eq!(replay_bytes, held_bytes); + let live = read_applicant(&fixture, &format!("/v1/proposals/{id}")).await; + assert_eq!(live["asks"][0]["state"], "answered"); + assert_eq!(live["messages"]["count"], 1); + assert_eq!(live["revision"], answered["revision"]); + fixture.finish().await; } #[tokio::test] @@ -1851,6 +1983,20 @@ async fn an_empty_answer_to_an_ask_without_wants_is_invalid_without_changing_the .await; assert_eq!(after.1["etag"], headers["etag"]); assert_eq!(after.2["revision"], before["revision"]); + let (status, answered_headers, answered) = request( + &fixture, + "POST", + &format!("/v1/proposals/{id}/asks/{ask}/answer"), + Some(headers["etag"].to_str().unwrap()), + Some("nonempty-answer"), + json!({"text":"Synthetic applicant answer"}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{answered}"); + assert_ne!(answered_headers["etag"], headers["etag"]); + assert_eq!(answered["submissionVersion"], before["submissionVersion"]); + assert_eq!(answered["effectDigest"], before["effectDigest"]); + assert_eq!(answered["asks"][0]["state"], "answered"); fixture.finish().await; } @@ -2228,8 +2374,38 @@ async fn agent_answer_fixture_with_checker( registry_platform_testing::MockIdp, registry_breg::auth::RegistryAuthenticator, ) { - let mut source = answer_source(); + agent_answer_fixture_from_source(authority, checker, answer_source()).await +} + +/// The agent fixture over `source`: its agent, task and staff profiles copy +/// the source's reviewer and clerk. +async fn agent_answer_fixture_from_source( + authority: &Authority, + checker: Arc, + mut source: Value, +) -> ( + client_http::ClientFixture, + registry_platform_testing::MockIdp, + registry_breg::auth::RegistryAuthenticator, +) { let mut standing = source["accessProfiles"]["reviewer"].clone(); + // No agent may hold a context field that shows an additional form. + let forms = source["actions"]["correct-name"]["execution"]["proposal"]["reviewContext"] + ["fields"] + .as_object() + .map(|fields| { + fields + .iter() + .filter(|(_, field)| field["type"] == "additional-form") + .map(|(name, _)| json!(name)) + .collect::>() + }) + .unwrap_or_default(); + if let Some(readable) = + standing["permissions"]["proposals"][0]["readableContextFields"].as_array_mut() + { + readable.retain(|field| !forms.contains(field)); + } standing["actorKind"] = json!("agent"); standing["requesterClients"] = json!(["agent-client"]); standing["permissions"] = json!({"proposals":standing["permissions"]["proposals"].clone()}); @@ -2270,7 +2446,9 @@ async fn agent_answer_fixture_with_checker( profile["requesterClients"] = json!(["agent-client"]); } let grant = &mut profile["permissions"]["proposals"][0]; - grant.as_object_mut().unwrap().remove("party"); + for key in ["party", "readableForms", "writableForms"] { + grant.as_object_mut().unwrap().remove(key); + } grant["operations"] = operations; grant["readableInputs"] = inputs; grant["readableContextFields"] = json!([]); @@ -2879,3 +3057,280 @@ async fn a_human_reviewer_without_answer_reads_answers_only_through_the_review_c assert!(!String::from_utf8_lossy(&bytes).contains("The requested statement")); fixture.finish().await; } + +#[tokio::test] +async fn a_form_want_discloses_only_the_cited_entry_in_live_review_context() { + let authority = Authority::start(false, true).await; + let mut source = answer_source(); + source["actions"]["correct-name"]["execution"]["proposal"]["additionalForms"] = json!({ + "household-details":{ + "inputs":[{"id":"household-size","type":"int64","required":true,"classification":"restricted"}] + }, + "housing-details":{ + "inputs":[{"id":"rented","type":"boolean","required":true,"classification":"restricted"}] + } + }); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["readableForms"] = json!(["household-details", "housing-details"]); + grant["writableForms"] = json!(["household-details", "housing-details"]); + let fixture = answer_fixture_from_source( + &authority, + registry_breg::attachment_verification::AttachmentVerification::Disabled, + source, + ) + .await; + let id = submitted(&fixture, "ask-form").await; + let binding = retained_binding(&fixture, id).await; + accept(&fixture, id, &binding).await; + let (ask, _) = announce(&authority, &binding); + let want = json!({"kind":"form","form":"household-details"}); + authority + .state + .asks + .lock() + .unwrap() + .replies + .get_mut(&ask) + .unwrap() + .1["wants"] = json!([want]); + assert!(worker(&fixture, &authority).await.unwrap()); + + let path = format!("/v1/proposals/{id}"); + let (status, headers, before) = request(&fixture, "GET", &path, None, None, Value::Null).await; + assert_eq!(status, StatusCode::OK, "{before}"); + assert_eq!(before["asks"][0]["wants"], json!([want])); + let mut etag = headers["etag"].to_str().unwrap().to_owned(); + let mut entries = Vec::new(); + for (form, key, input) in [ + ( + "housing-details", + "wrong-form-entry", + json!({"rented":true}), + ), + ( + "household-details", + "uncited-form-entry", + json!({"householdSize":7}), + ), + ( + "household-details", + "cited-form-entry", + json!({"householdSize":4}), + ), + ] { + let (status, headers, value) = request( + &fixture, + "POST", + &format!("{path}/additional-forms/{form}"), + Some(&etag), + Some(key), + json!({"input":input}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{value}"); + let items = value["additionalForms"][form]["items"].as_array().unwrap(); + let entry = items.iter().find(|item| item["input"] == input).unwrap(); + entries.push(entry["id"].clone()); + etag = headers["etag"].to_str().unwrap().to_owned(); + } + + let answer_path = format!("{path}/asks/{ask}/answer"); + for (key, cited) in [ + ("missing-form", json!([])), + ("answer-wrong-form", json!([entries[0]])), + ] { + let (status, _, problem) = request( + &fixture, + "POST", + &answer_path, + Some(&etag), + Some(key), + json!({"text":"Additional details","formEntries":cited}), + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{problem}"); + assert_eq!(problem["code"], "request.invalid", "{problem}"); + assert_eq!(problem["fieldPath"], "/formEntries", "{problem}"); + } + let (status, _, after) = request( + &fixture, + "POST", + &answer_path, + Some(&etag), + Some("form-answer"), + json!({"formEntries":[entries[2]]}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{after}"); + assert_eq!(after["submissionVersion"], before["submissionVersion"]); + assert_eq!(after["effectDigest"], before["effectDigest"]); + assert_eq!(after["asks"][0]["state"], "answered"); + + let (status, _, bytes) = reviewer_get( + &fixture, + &format!("{path}/review-context?accessProfile=reviewer&include=answers"), + "zone-a", + ) + .await; + assert_eq!(status, StatusCode::OK); + let context: Value = serde_json::from_slice(&bytes).unwrap(); + let cited = context["context"]["asks"][0]["answer"]["formEntries"] + .as_array() + .unwrap(); + assert_eq!(cited.len(), 1); + assert_eq!(cited[0]["id"], entries[2]); + assert_eq!(cited[0]["input"], json!({"householdSize":4})); + let retained_form_receipts: i64 = fixture + .database + .admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_idempotency r + JOIN registry_internal.registry_proposal_idempotency_links l USING(key_reference) + WHERE l.proposal_id=$1 AND l.submission_version=1 + AND convert_from(r.response_body, 'UTF8')::jsonb ? 'formEntryId'", + &[&id], + ) + .await + .unwrap() + .get(0); + assert_eq!(retained_form_receipts, 3); + *authority.state.accepted.lock().unwrap() = Some(binding); + let (_, headers, _) = request(&fixture, "GET", &path, None, None, Value::Null).await; + let cancelled = request( + &fixture, + "POST", + &format!("{path}/cancel"), + headers["etag"].to_str().ok(), + Some("cancel-form-review"), + json!({}), + ) + .await; + assert_eq!(cancelled.0, StatusCode::OK, "{}", cancelled.2); + worker(&fixture, &authority).await.unwrap(); + let (mut migration, migration_task) = fixture.database.connect_migration().await; + let erasure = registry_breg::proposal_retention::erase_proposal_detail( + &mut migration, + &fixture.registry, + registry_breg::proposal_retention::ProposalDetailErasureScope { + action_id: "correct-name", + proposal_id: id, + submission_version: 1, + }, + ) + .await + .unwrap(); + assert_eq!(serde_json::to_value(erasure).unwrap()["formEntries"], 3); + let row = fixture.database.admin.query_one( + "SELECT (SELECT count(*) FROM registry_internal.registry_proposal_form_entries + WHERE proposal_id=$1 AND input IS NULL AND added_by IS NULL + AND detail_erased_at IS NOT NULL), + (SELECT count(*) FROM registry_internal.registry_proposal_review_ask_form_entries + WHERE proposal_id=$1), + (SELECT count(*) FROM registry_internal.registry_idempotency r + JOIN registry_internal.registry_proposal_idempotency_links l USING(key_reference) + WHERE l.proposal_id=$1 AND l.submission_version=1 AND r.response_body IS NOT NULL)", + &[&id], + ).await.unwrap(); + assert_eq!(row.get::<_, i64>(0), 3); + assert_eq!(row.get::<_, i64>(1), 0); + assert_eq!(row.get::<_, i64>(2), 0); + drop(migration); + migration_task.abort(); + fixture.finish().await; +} + +/// A review-context field that shows an additional form serves its entries +/// to a person reading for themselves. A service reading through a profile +/// written for any kind is refused and receives no form value; agent, +/// service and task-grant profiles cannot hold the field at all +/// (`proposal_additional_forms.rs`). +#[tokio::test] +async fn a_form_context_field_serves_the_human_reviewer_and_refuses_a_non_person_reader() { + let authority = Authority::start(false, true).await; + let mut source = answer_source(); + let proposal = &mut source["actions"]["correct-name"]["execution"]["proposal"]; + proposal["additionalForms"] = json!({ + "household-details":{ + "inputs":[{"id":"household-size","type":"int64","required":true,"classification":"restricted"}] + } + }); + proposal["reviewContext"]["fields"]["household"] = + json!({"type":"additional-form","form":"household-details"}); + let grant = &mut source["accessProfiles"]["clerk"]["permissions"]["proposals"][0]; + grant["readableForms"] = json!(["household-details"]); + grant["writableForms"] = json!(["household-details"]); + source["accessProfiles"]["reviewer"]["permissions"]["proposals"][0]["readableContextFields"] = + json!(["value", "household"]); + // A profile written for any kind may hold the field; a service using it + // still receives no form value. + let mut any_kind = source["accessProfiles"]["reviewer"].clone(); + any_kind.as_object_mut().unwrap().remove("actorKind"); + source["accessProfiles"]["any-kind-reviewer"] = any_kind; + let (fixture, _idp, _auth) = + agent_answer_fixture_from_source(&authority, Arc::new(ActiveTaskGrant), source).await; + let id = submitted(&fixture, "form-context").await; + let binding = retained_binding(&fixture, id).await; + accept(&fixture, id, &binding).await; + let path = format!("/v1/proposals/{id}"); + let (status, headers, document) = + request(&fixture, "GET", &path, None, None, Value::Null).await; + assert_eq!(status, StatusCode::OK, "{document}"); + let (status, _, added) = request( + &fixture, + "POST", + &format!("{path}/additional-forms/household-details"), + Some(headers["etag"].to_str().unwrap()), + Some("context-form-entry"), + json!({"input":{"householdSize":6}}), + ) + .await; + assert_eq!(status, StatusCode::OK, "{added}"); + + let (status, _, bytes) = reviewer_get( + &fixture, + &format!("{path}/review-context?accessProfile=reviewer"), + "zone-a", + ) + .await; + assert_eq!( + status, + StatusCode::OK, + "{}", + String::from_utf8_lossy(&bytes) + ); + let context: Value = serde_json::from_slice(&bytes).unwrap(); + assert_eq!( + context["context"]["fields"]["household"][0]["input"], + json!({"householdSize":6}), + "{context}" + ); + + let service = VerifiedRequestClaims::authenticated_with_actor_kind( + "sub", + "review-service", + BTreeSet::from(["proposal:review".into()]), + Some("registry-administration".into()), + BTreeMap::from([( + "jurisdiction".into(), + VerifiedClaimValue::direct_string("zone-a").unwrap(), + )]), + registry_platform_oidc::ActorKind::Service, + ) + .unwrap(); + let (status, _, refused) = request_as( + &fixture, + service, + "GET", + &format!("{path}/review-context?accessProfile=any-kind-reviewer"), + None, + None, + Value::Null, + ) + .await; + assert_ne!(status, StatusCode::OK, "{refused}"); + assert!( + !refused.to_string().contains("householdSize"), + "a service received a form value" + ); + fixture.finish().await; +} diff --git a/crates/registry-breg/tests/support/webhook_retention_logs.rs b/crates/registry-breg/tests/support/webhook_retention_logs.rs index d06ca1c8bb..d0e5699291 100644 --- a/crates/registry-breg/tests/support/webhook_retention_logs.rs +++ b/crates/registry-breg/tests/support/webhook_retention_logs.rs @@ -180,9 +180,14 @@ impl Fixture { fn failure(entries: &[Value], removed: u64, reason: &str) { assert_eq!(entries.len(), 1, "one operational failure per tick"); assert_eq!(entries[0]["level"], "ERROR"); + let code = if reason == "lock-timeout" { + "hook.retention.lock_timeout" + } else { + "hook.retention.failed" + }; assert_eq!( entries[0]["fields"], - json!({"message":"hook metadata retention failed", "removed":removed, "reason":reason}) + json!({"message":"hook metadata retention failed", "code":code, "removed":removed, "reason":reason}) ); } diff --git a/crates/registry-bregctl/src/hook_lifecycle.rs b/crates/registry-bregctl/src/hook_lifecycle.rs index aaf96152a9..6445d75c2a 100644 --- a/crates/registry-bregctl/src/hook_lifecycle.rs +++ b/crates/registry-bregctl/src/hook_lifecycle.rs @@ -179,7 +179,7 @@ pub(crate) fn sample( Transition::Cancelled => ("draft", "cancelled", "nobody"), Transition::Applied => ("submitted", "applied", "nobody"), Transition::Rejected => ("submitted", "rejected", "nobody"), - Transition::ReviewReturned | Transition::Asked => { + Transition::ReviewReturned | Transition::Asked | Transition::Messaged => { ("submitted", "submitted", "party") } }; @@ -187,8 +187,12 @@ pub(crate) fn sample( Transition::Rejected | Transition::ReviewReturned | Transition::Asked => "review", _ => "caller", }; + let mut data = json!({"actionId":action.id,"actionRevision":action.definition_revision,"proposalId":SAMPLE_RECORD_ID,"submissionVersion":1,"revision":1,"fromState":from,"state":state,"transition":transition.as_str(),"effectDigest":null,"authorityKind":authority_kind,"systemApplyGrantRevision":null,"turn":turn}); + if transition == Transition::Messaged { + data["messageFrom"] = json!("official"); + } ( - json!({"actionId":action.id,"actionRevision":action.definition_revision,"proposalId":SAMPLE_RECORD_ID,"submissionVersion":1,"revision":1,"fromState":from,"state":state,"transition":transition.as_str(),"effectDigest":null,"authorityKind":authority_kind,"systemApplyGrantRevision":null,"turn":turn}), + data, format!("proposal.{}", transition.as_str()), EventSubject::proposal(format!("/v1/proposals/{SAMPLE_RECORD_ID}"), 1), ) diff --git a/crates/registry-bregctl/src/lib.rs b/crates/registry-bregctl/src/lib.rs index 06059aa2e3..ce93cd8ac6 100644 --- a/crates/registry-bregctl/src/lib.rs +++ b/crates/registry-bregctl/src/lib.rs @@ -10320,7 +10320,7 @@ const EVENTS_EXPLANATION: ExplainFormat = ExplainFormat { kind: "BRegEventsExplanation", }; const LIFECYCLE_EXPLANATION: ExplainFormat = ExplainFormat { - api_version: "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9", + api_version: "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10", kind: "BRegLifecycleExplanation", }; diff --git a/crates/registry-bregctl/tests/explain_contract.rs b/crates/registry-bregctl/tests/explain_contract.rs index df0d67df9e..0c94fbfecb 100644 --- a/crates/registry-bregctl/tests/explain_contract.rs +++ b/crates/registry-bregctl/tests/explain_contract.rs @@ -59,7 +59,7 @@ fn envelope(contract: &str) -> (&'static str, &'static str) { "BRegEventsExplanation", ), "LifecycleExplanation" => ( - "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9", + "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10", "BRegLifecycleExplanation", ), _ => panic!("unknown contract {contract}"), @@ -653,7 +653,7 @@ fn explain_lifecycle_matches_contract() { let report = explain_lifecycle_report(); assert_eq!( report["explanation"]["apiVersion"], - "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9" + "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10" ); let submitted = &report["explanation"]["lifecycles"][0]["states"][1]; assert_eq!(submitted["statuses"].as_array().unwrap().len(), 4); diff --git a/crates/registry-bregctl/tests/wasm_test_lifecycle.rs b/crates/registry-bregctl/tests/wasm_test_lifecycle.rs index 5ab5d9e4c9..749cd47bf7 100644 --- a/crates/registry-bregctl/tests/wasm_test_lifecycle.rs +++ b/crates/registry-bregctl/tests/wasm_test_lifecycle.rs @@ -10,11 +10,13 @@ use std::env; use std::fs; use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; -use std::process::{Command, Output}; +use std::process::{Child, Command, Output, Stdio}; use std::str::FromStr; use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::{SystemTime, UNIX_EPOCH}; +use std::sync::Arc; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use axum::{routing::get, Json, Router}; use registry_breg::postgres::{provision_managed_schemas, SqlIdentifier}; use registry_platform_canonical_json::canonicalize_json; use registry_platform_config::{ @@ -25,6 +27,7 @@ use registry_platform_crypto::PrivateJwk; use registry_platform_testing::{fixtures, jwks_from_private_jwk, MockIdp}; use serde_json::{json, Value}; use tempfile::TempDir; +use tokio::sync::Notify; use tokio::task::JoinHandle; use tokio_postgres::{config::SslMode, Client, Config}; use tokio_postgres_rustls::MakeRustlsConnect; @@ -213,6 +216,297 @@ fn seal_historical_vocabulary(root: &Path) { .unwrap(); } +#[tokio::test] +#[ignore = "requires BREG_TEST_DATABASE_URL and a PostgreSQL administrator"] +async fn public_bregctl_test_times_out_with_a_leased_automatic_application() { + run_blocked_automatic_application(true).await; +} + +#[tokio::test] +#[ignore = "requires BREG_TEST_DATABASE_URL and a PostgreSQL administrator"] +async fn public_bregctl_test_preserves_the_claim_when_shutdown_grace_expires() { + run_blocked_automatic_application(false).await; +} + +async fn run_blocked_automatic_application(release_during_grace: bool) { + let mut database = TestDatabase::create().await; + let idp = MockIdp::start().await; + let project = ProjectFixture::write(&database, &idp, FixtureAudit::File); + fs::write( + project.project_root.join("tests/journeys.yaml"), + WAIT_JOURNEY, + ) + .expect("automatic application journey writes"); + fs::write( + &project.credentials, + format!( + "apiVersion: id.registrystack.org/formats/breg/schema-test-credentials/v1\nkind: BRegSchemaTestCredentials\nbindings:\n{}", + ["start", "submit", "await-application"] + .map(|step| format!(" - {{journeyId: wait-for-application, stepId: {step}, credential: {{type: bearer, tokenRef: secret:file/operator-token}}}}\n")) + .concat() + ), + ) + .expect("automatic application credentials bind"); + // The CLI fetches its initial JWKS after installing the schema and before + // entering the journey. Hold that fetch until PostgreSQL can block Apply. + let (jwks_requested, send_jwks) = (Arc::new(Notify::new()), Arc::new(Notify::new())); + let jwks = jwks_from_private_jwk( + &PrivateJwk::parse(fixtures::ED25519_PRIVATE_JWK).expect("fixture key parses"), + ); + let app = Router::new().route( + "/jwks", + get({ + let (jwks_requested, send_jwks) = (Arc::clone(&jwks_requested), Arc::clone(&send_jwks)); + move || async move { + jwks_requested.notify_one(); + send_jwks.notified().await; + Json(jwks) + } + }), + ); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0") + .await + .expect("fixture JWKS listener binds"); + let jwks_uri = format!("http://{}/jwks", listener.local_addr().unwrap()); + let jwks_server = tokio::spawn(async move { axum::serve(listener, app).await.unwrap() }); + let config = fs::read_to_string(&project.runtime_config).expect("fixture config reads"); + let config = config.replace( + "type: static, documentRef: secret:file/oidc-jwks", + &format!("type: uri, uri: {jwks_uri}"), + ); + let config = if release_during_grace { + config + } else { + config.replace( + "shutdownGraceMilliseconds: 3000", + "shutdownGraceMilliseconds: 500", + ) + }; + fs::write(&project.runtime_config, config) + .expect("fixture config names the gated JWKS endpoint"); + + let mut command = ChildGuard( + Command::new(env!("CARGO_BIN_EXE_bregctl")) + .env_remove("REGISTRY_STACK_POSTURE") + .args([ + "--format", + "json", + "test", + path(&project.project_root), + "--runtime-config", + path(&project.runtime_config), + "--credentials", + path(&project.credentials), + "--output", + path(&project.receipt), + ]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("bregctl test starts in a fresh process"), + ); + tokio::time::timeout(Duration::from_secs(30), jwks_requested.notified()) + .await + .expect("CLI requests the keys after installing the schema"); + let (mut admin, connection) = + connect(&database_url(&database.admin_url, &database.database)).await; + let barrier = admin + .transaction() + .await + .expect("application barrier begins"); + let table: String = barrier + .query_one( + "SELECT oid::regclass::text FROM pg_class WHERE relnamespace='registry_data'::regnamespace + AND relkind='r'", + &[], + ) + .await + .expect("the fixture record table is installed") + .get(0); + barrier + .batch_execute(&format!("LOCK TABLE {table} IN SHARE MODE")) + .await + .expect("the barrier holds the application's insert"); + send_jwks.notify_one(); + let apply_backend = tokio::time::timeout(Duration::from_secs(30), async { + loop { + if command.0.try_wait().expect("CLI status reads").is_some() { + panic!("CLI exited before the leased application reached the barrier"); + } + let blocked = barrier + .query_opt( + "SELECT pid FROM pg_locks + WHERE relation=$1::text::regclass AND mode='RowExclusiveLock' + AND NOT granted AND pg_backend_pid()=ANY(pg_blocking_pids(pid))", + &[&table], + ) + .await + .expect("application barrier status reads"); + if let Some(row) = blocked { + break row.get::<_, i32>(0); + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("Apply reaches the barrier"); + let initial_job = application_job(&barrier).await; + assert_eq!( + (initial_job.state.as_str(), initial_job.attempt_count), + ("applying", 1) + ); + assert!(initial_job.claim_token.is_some() && initial_job.live_lease); + + let (exit, alive_during_cleanup) = if release_during_grace { + // The step began before the insert. Release it after the one-second + // deadline but within the shutdown grace and the worker's own budget. + tokio::time::sleep(Duration::from_millis(1250)).await; + let alive = command.0.try_wait().expect("CLI status reads").is_none(); + barrier + .commit() + .await + .expect("application barrier releases"); + (command.wait_for_exit().await, alive) + } else { + let exit = command.wait_for_exit().await; + barrier + .commit() + .await + .expect("application barrier releases"); + (exit, false) + }; + let report: Value = serde_json::from_reader(command.0.stdout.take().unwrap()) + .expect("refused command reports JSON"); + // Let PostgreSQL finish unwinding any cancelled transaction before + // inspecting the job and its effects from a new statement. + tokio::time::timeout(Duration::from_secs(5), async { + loop { + let connected: bool = admin + .query_one( + "SELECT EXISTS (SELECT 1 FROM pg_stat_activity WHERE pid=$1)", + &[&apply_backend], + ) + .await + .expect("application backend status reads") + .get(0); + if !connected { + break; + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("the application backend disconnects"); + let job = application_job(&admin).await; + let results: i64 = admin + .query_one( + "SELECT count(*) FROM registry_internal.registry_proposal_results", + &[], + ) + .await + .expect("application results read") + .get(0); + let records: i64 = admin + .query_one(&format!("SELECT count(*) FROM {table}"), &[]) + .await + .expect("application records read") + .get(0); + drop(admin); + connection + .await + .expect("disposable PostgreSQL observer stops"); + idp.stop().await; + database.cleanup().await; + jwks_server.abort(); + assert!(jwks_server.await.unwrap_err().is_cancelled()); + + assert_eq!(exit.code(), Some(1)); + assert_eq!(report["diagnostics"][0]["code"], "test.step.failed"); + assert_eq!(report["diagnostics"][0]["path"], "journeys[0].steps[2]"); + assert!(report["diagnostics"][0]["message"] + .as_str() + .unwrap() + .starts_with("fixture.proposal.wait-timed-out")); + assert!(!project.receipt.exists()); + assert_eq!(job.attempt_count, 1); + if release_during_grace { + assert!( + alive_during_cleanup, + "the CLI dropped the worker at the step deadline" + ); + assert_eq!(job.state, "applied"); + assert!(job.claim_token.is_none()); + assert_eq!((results, records), (1, 1)); + } else { + assert_eq!(job.state, "applying"); + assert!( + job.claim_token == initial_job.claim_token, + "claim token changed" + ); + assert_eq!(job.next_attempt_at, initial_job.next_attempt_at); + assert!(job.live_lease); + assert_eq!((results, records), (0, 0)); + } +} + +struct ChildGuard(Child); + +impl ChildGuard { + async fn wait_for_exit(&mut self) -> std::process::ExitStatus { + tokio::time::timeout(Duration::from_secs(3), async { + loop { + if let Some(exit) = self.0.try_wait().expect("CLI status reads") { + break exit; + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("CLI exits after bounded cleanup") + } +} + +impl Drop for ChildGuard { + fn drop(&mut self) { + match self.0.try_wait() { + Ok(Some(_)) => {} + Ok(None) => { + if let Err(error) = self.0.kill().and_then(|()| self.0.wait()) { + eprintln!("could not terminate and reap the disposable CLI: {error}"); + } + } + Err(error) => eprintln!("could not read the disposable CLI status: {error}"), + } + } +} + +struct ApplicationJob { + state: String, + attempt_count: i32, + claim_token: Option, + next_attempt_at: String, + live_lease: bool, +} + +async fn application_job(admin: &impl tokio_postgres::GenericClient) -> ApplicationJob { + let job = admin + .query_one( + "SELECT state, attempt_count, claim_token::text, next_attempt_at::text, + next_attempt_at > clock_timestamp() + FROM registry_internal.registry_proposal_application_jobs", + &[], + ) + .await + .expect("application job reads"); + ApplicationJob { + state: job.get(0), + attempt_count: job.get(1), + claim_token: job.get(2), + next_attempt_at: job.get(3), + live_lease: job.get(4), + } +} + #[derive(Clone, Copy)] enum FixtureAudit { File, @@ -445,6 +739,18 @@ actions: target: {recordType: record} operation: create fields: [code] + file-record: + execution: + mode: proposal + proposal: + review: {type: none} + retention: {mode: retain} + inputs: + - {id: code, type: string, required: true, maximumLength: 32, classification: public} + plan: + type: fixed + effects: + - {id: record, target: {recordType: record}, operation: create, set: {code: {fromInput: code}}} accessProfiles: operator: default: true @@ -459,9 +765,38 @@ accessProfiles: operations: [invoke] targets: [{recordType: record, rowBoundaries: unrestricted}] results: [record] + - {action: file-record, operations: [start], targets: [{recordType: record, rowBoundaries: unrestricted}]} + proposals: + - {action: file-record, party: owner, operations: [get, submit], targets: [{recordType: record, rowBoundaries: unrestricted}]} "# } +const WAIT_JOURNEY: &str = r#"apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: wait-for-application + steps: + - id: start + action: file-record + accessProfile: operator + claims: {principal: wasm-fixture-operator, scopes: ['registry:wasm-fixture:invoke'], purpose: fixture-assurance} + request: {type: proposal, transition: start, input: {code: WAIT-APPLY}} + expect: {outcome: success, status: 201, fields: {state: draft}} + capture: draft + - id: submit + action: file-record + accessProfile: operator + claims: {principal: wasm-fixture-operator, scopes: ['registry:wasm-fixture:invoke'], purpose: fixture-assurance} + request: {type: proposal, transition: submit, proposalCapture: draft, idempotencyKey: submit-record} + expect: {outcome: success, status: 200, fields: {state: submitted}} + - id: await-application + action: file-record + accessProfile: operator + claims: {principal: wasm-fixture-operator, scopes: ['registry:wasm-fixture:invoke'], purpose: fixture-assurance} + request: {type: proposal, transition: get, proposalCapture: draft, waitSeconds: 1} + expect: {outcome: success, status: 200, fields: {state: applied}} +"#; + fn journey_source() -> &'static str { r#"apiVersion: id.registrystack.org/formats/breg/journeys/v1 kind: BRegJourneys @@ -554,8 +889,8 @@ wasmExecution: maximumGuestMemoryBytes: 33554432 operationalTimeouts: httpRequestMilliseconds: 5000 - shutdownGraceMilliseconds: 1000 - recordLockMilliseconds: 2000 + shutdownGraceMilliseconds: 3000 + recordLockMilliseconds: 4000 migrationLockMilliseconds: 2000 migrationStatementMilliseconds: 5000 "#, diff --git a/crates/registry-casework-breg/src/lib.rs b/crates/registry-casework-breg/src/lib.rs index 294914a055..d40dfe5767 100644 --- a/crates/registry-casework-breg/src/lib.rs +++ b/crates/registry-casework-breg/src/lib.rs @@ -454,7 +454,14 @@ impl BregContextProvider { } let display_reference = Some(document.context.reference); Ok(HumanDisplayObservation { + additional_forms: document.context.additional_forms, answers, + messages: document + .context + .messages + .map(serde_json::to_value) + .transpose() + .map_err(|_| ReviewContextError::Invalid)?, identity: identity.clone(), reviewable: document.reviewable, display_reference, diff --git a/crates/registry-casework-breg/tests/context_provider.rs b/crates/registry-casework-breg/tests/context_provider.rs index 3b7ed399c1..a080c83b73 100644 --- a/crates/registry-casework-breg/tests/context_provider.rs +++ b/crates/registry-casework-breg/tests/context_provider.rs @@ -1109,3 +1109,89 @@ async fn human_reads_forward_only_source_token_with_scalar_breg_audience_single_ assert_ne!(auth, "Bearer status-bearer"); } } + +/// The message thread lives in BReg. The displayed task context asks for it +/// beside the answers, under the reviewer's own bearer, and passes it +/// through with its links; preflight reads never ask for it. +#[tokio::test] +async fn display_passes_the_live_message_thread_through_and_preflight_never_requests_it() { + let server = MockServer::start().await; + let export = export(); + let identity = identity(&export); + let provider = provider(&server, export.clone()); + mocks(&server, "reviewer", "human-bearer", true, DIGEST).await; + let messages = json!({ + "count": 1, + "unread": 1, + "lastSentAt": "2026-12-01T10:00:00.000000Z", + "items": [{"id": uuid::Uuid::from_u128(9), "from": "party", "partyRole": "owner", "mine": false, + "sentAt": "2026-12-01T10:00:00.000000Z", "text": "Is a scan enough?"}], + "links": { + "message": {"method": "POST", "path": format!("/v1/proposals/{ID}/messages"), + "operation": "message", "accessProfile": "reviewer", "availability":{"available":true,"observedRevision":2}, "ifMatch": "\"breg-proposal-2\""}, + "markRead": {"method": "POST", "path": format!("/v1/proposals/{ID}/messages/read"), + "operation": "message", "accessProfile": "reviewer", "availability":{"available":true,"observedRevision":2}}, + "list": {"method": "GET", "path": format!("/v1/proposals/{ID}/messages"), + "operation": "message", "accessProfile": "reviewer", "availability":{"available":true,"observedRevision":2}} + } + }); + Mock::given(method("GET")).and(path(format!("/v1/proposals/{ID}/review-context"))).and(query_param("accessProfile","reviewer")).and(|request: &wiremock::Request| request.url.query_pairs().any(|(key, value)| key == "include" && value.split(',').any(|item| item == "messages"))).and(header("authorization","Bearer human-bearer")).respond_with(response(json!({"id":ID,"actionId":"correct-address","actionRevision":DIGEST,"submissionVersion":1,"revision":2,"effectDigest":DIGEST,"subject":{"source":"source","subjectType":"proposal","id":ID,"version":"1","digest":DIGEST},"context":{"reference":"native-proposal","contract":export.contract,"fields":{"reference":"REF-42"},"messages":messages},"reviewable":true}))).with_priority(1).mount(&server).await; + + let preflight = provider + .human_display(HumanDisplayRequest { + include_answers: false, + identity: &identity, + source_profile_id: "reviewer", + credential: EphemeralCredential::new("human-bearer"), + }) + .await; + let display = provider + .human_display(HumanDisplayRequest { + include_answers: true, + identity: &identity, + source_profile_id: "reviewer", + credential: EphemeralCredential::new("human-bearer"), + }) + .await; + + let requests = server.received_requests().await.unwrap(); + let includes = |request: &wiremock::Request| { + request + .url + .query_pairs() + .filter(|(key, _)| key == "include") + .flat_map(|(_, value)| value.split(',').map(str::to_owned).collect::>()) + .collect::>() + }; + let contexts: Vec<_> = requests + .iter() + .filter(|r| r.url.path().ends_with("/review-context")) + .collect(); + assert_eq!(contexts.len(), 2); + assert!( + includes(contexts[0]).is_empty(), + "preflight asked for {}", + contexts[0].url + ); + assert_eq!( + includes(contexts[1]), + ["answers", "messages"] + .into_iter() + .map(str::to_owned) + .collect(), + "the displayed context must ask for the thread beside the answers: {}", + contexts[1].url + ); + assert!(requests + .iter() + .all(|request| request.headers.get("authorization").unwrap() == "Bearer human-bearer")); + + preflight.expect("preflight reads the context without the thread"); + let display = display.expect("the displayed context carries the live thread"); + let observed = serde_json::to_value(&display).unwrap(); + assert_eq!( + observed["messages"], messages, + "the thread passes through unchanged, links included" + ); + assert_eq!(observed["fields"], json!({"reference":"REF-42"})); +} diff --git a/crates/registry-casework-client-node/__test__/ask-limit.test.js b/crates/registry-casework-client-node/__test__/ask-limit.test.js index 59a59e9763..6dae4fae50 100644 --- a/crates/registry-casework-client-node/__test__/ask-limit.test.js +++ b/crates/registry-casework-client-node/__test__/ask-limit.test.js @@ -4,30 +4,27 @@ const http = require('node:http'); const { test } = require('node:test'); const { CaseworkClient } = require('../client'); -test('the ask limit exposes its safe problem detail and is never retried', async () => { +async function assertAskRefusal({ status, type, code, title, detail, wants }) { let attempts = 0; - const detail = 'This review request has reached its limit of 50 asks. Continue the review without opening another ask.'; const server = http.createServer(async (request, response) => { for await (const chunk of request) { assert.ok(chunk.length); } attempts += 1; - response.writeHead(409, { + response.writeHead(status, { 'content-type': 'application/problem+json', traceparent: '00-0123456789abcdef0123456789abcdef-0123456789abcdef-01', }); response.end(JSON.stringify({ - type: 'https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached', - title: 'Review ask limit reached', status: 409, detail, - code: 'review.ask-limit-reached', traceId: '0123456789abcdef0123456789abcdef', + type, title, status, detail, code, traceId: '0123456789abcdef0123456789abcdef', })); }); await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); try { const client = new CaseworkClient({baseUrl: `http://127.0.0.1:${server.address().port}/`}); await assert.rejects( - client.askApplicant('synthetic-token', 'staff', '00000000-0000-4000-8000-000000000001', 2, 'ask-51', {text: 'Why?', wants: []}), + client.askApplicant('synthetic-token', 'staff', '00000000-0000-4000-8000-000000000001', 2, 'ask-refusal', {text: 'Why?', wants}), error => { assert.equal(error.kind, 'problem'); - assert.equal(error.code, 'review.ask-limit-reached'); + assert.equal(error.code, code); assert.equal(error.detail, detail); return true; }, @@ -36,4 +33,26 @@ test('the ask limit exposes its safe problem detail and is never retried', async } finally { await new Promise(resolve => server.close(resolve)); } +} + +test('the ask limit exposes its safe problem detail and is never retried', async () => { + await assertAskRefusal({ + status: 409, + type: 'https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached', + code: 'review.ask-limit-reached', + title: 'Review ask limit reached', + detail: 'This review request has reached its limit of 50 asks. Continue the review without opening another ask.', + wants: [], + }); +}); + +test('an unknown ask form exposes its safe problem detail and is never retried', async () => { + await assertAskRefusal({ + status: 422, + type: 'https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown', + code: 'review.ask-form-unknown', + title: 'Unknown review ask form', + detail: 'The review source does not declare the requested form.', + wants: [{kind: 'form', form: 'unknown'}], + }); }); diff --git a/crates/registry-casework-client-node/client.d.ts b/crates/registry-casework-client-node/client.d.ts index baec2f4f4d..fd5e0a4303 100644 --- a/crates/registry-casework-client-node/client.d.ts +++ b/crates/registry-casework-client-node/client.d.ts @@ -150,6 +150,7 @@ export type KnownCaseworkProblemCode = | 'review.distinct-approver-required' | 'review.ask-already-open' | 'review.ask-answer-time-invalid' + | 'review.ask-form-unknown' | 'review.ask-limit-reached' | 'review.ask-not-offered' | 'review.ask-not-open' @@ -341,7 +342,7 @@ export interface ReviewSourceProjection { binding: SubjectBinding; displayRefere export type ReviewTaskContextData = | { mode: 'submitted'; snapshot: Readonly> } | { mode: 'current-source'; reference: string; bindingStatus: ReviewSourceBindingStatus; projection?: ReviewSourceProjection } -export type ReviewAskWant = { kind: 'answer' } | { kind: 'document' } +export type ReviewAskWant = { kind: 'answer' } | { kind: 'document' } | { kind: 'form'; form: string } export type ReviewAskState = 'open' | 'answered' | 'expired' | 'closed' export interface ReviewTaskAskRequest { text: string; wants: ReadonlyArray } export interface ReviewAsk { @@ -375,6 +376,7 @@ export interface ReviewContextAnswer { text?: string documents: ReadonlyArray answeredAt: string + formEntries?: ReadonlyArray<{id: string; addedAt: string; input?: JsonObject; contractChanged?: boolean}> } export interface ReviewContextAsk { askId: Uuid @@ -397,6 +399,8 @@ export interface ReviewTaskContext { resultConstraints?: JsonObject context: ReviewTaskContextData asks?: ReadonlyArray + additionalForms?: Readonly> + messages?: JsonObject } export type ReviewClockCorrelation = | { scope: 'subject'; source: string; subjectType: string; id: string } diff --git a/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi b/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi index f3cc80045a..bd1c9bfd67 100644 --- a/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi +++ b/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi @@ -358,6 +358,7 @@ KnownCaseworkProblemCode: TypeAlias = Literal[ "request.unsupported-media-type", "review.ask-already-open", "review.ask-answer-time-invalid", + "review.ask-form-unknown", "review.ask-limit-reached", "review.ask-not-offered", "review.ask-not-open", @@ -642,7 +643,10 @@ class ReviewAnswerWant(TypedDict): kind: Literal["answer"] class ReviewDocumentWant(TypedDict): kind: Literal["document"] -ReviewAskWant: TypeAlias = ReviewAnswerWant | ReviewDocumentWant +class ReviewFormWant(TypedDict): + kind: Literal["form"] + form: str +ReviewAskWant: TypeAlias = ReviewAnswerWant | ReviewDocumentWant | ReviewFormWant ReviewAskState: TypeAlias = Literal["open", "answered", "expired", "closed"] class ReviewTaskAskRequest(TypedDict): text: str @@ -677,8 +681,14 @@ class ReviewAnswerDocument(_ReviewAnswerDocumentOptional): byteSize: int class _ReviewContextAnswerOptional(TypedDict, total=False): text: str +class ReviewAnswerFormEntry(TypedDict): + id: str + addedAt: str + input: NotRequired[JsonObject] + contractChanged: NotRequired[bool] class ReviewContextAnswer(_ReviewContextAnswerOptional): documents: list[ReviewAnswerDocument] + formEntries: NotRequired[list[ReviewAnswerFormEntry]] answeredAt: str class _ReviewContextAskOptional(TypedDict, total=False): dueAt: str @@ -702,6 +712,8 @@ class ReviewTaskContext(_ReviewTaskContextOptional): policy: PolicyBinding policyClosure: ReviewPolicyClosure context: ReviewTaskContextData + additionalForms: NotRequired[dict[str, str]] + messages: NotRequired[JsonObject] class ReviewSubjectClockCorrelation(TypedDict): scope: Literal["subject"] source: str diff --git a/crates/registry-casework-client-py/tests/python/test_ask_limit.py b/crates/registry-casework-client-py/tests/python/test_ask_limit.py index 56c96f9bf1..c5a7133a75 100644 --- a/crates/registry-casework-client-py/tests/python/test_ask_limit.py +++ b/crates/registry-casework-client-py/tests/python/test_ask_limit.py @@ -1,4 +1,4 @@ -"""The request ask limit is a known, non-retryable problem.""" +"""Ask refusals are known, non-retryable problems.""" import json import threading import unittest @@ -12,20 +12,39 @@ class AskLimitTests(unittest.TestCase): def test_the_ask_limit_preserves_its_detail_without_retrying(self): + self.assert_ask_refusal( + 409, + "https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached", + "review.ask-limit-reached", + "Review ask limit reached", + "This review request has reached its limit of 50 asks. Continue the review without opening another ask.", + [], + ) + + def test_an_unknown_ask_form_preserves_its_detail_without_retrying(self): + self.assert_ask_refusal( + 422, + "https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown", + "review.ask-form-unknown", + "Unknown review ask form", + "The review source does not declare the requested form.", + [{"kind": "form", "form": "unknown"}], + ) + + def assert_ask_refusal(self, status, problem_type, code, title, detail, wants): attempts = [] - detail = "This review request has reached its limit of 50 asks. Continue the review without opening another ask." class Handler(BaseHTTPRequestHandler): def do_POST(self): self.rfile.read(int(self.headers["content-length"])) attempts.append(self.path) body = json.dumps({ - "type": "https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached", - "title": "Review ask limit reached", "status": 409, - "detail": detail, "code": "review.ask-limit-reached", + "type": problem_type, + "title": title, "status": status, + "detail": detail, "code": code, "traceId": "0123456789abcdef0123456789abcdef", }).encode() - self.send_response(409) + self.send_response(status) self.send_header("content-type", "application/problem+json") self.send_header("traceparent", "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01") self.send_header("content-length", str(len(body))) @@ -41,9 +60,9 @@ def log_message(self, *_): try: client = CaseworkClient(f"http://127.0.0.1:{server.server_port}/") with self.assertRaises(CaseworkClientError) as caught: - client.ask_applicant("synthetic-token", "staff", "00000000-0000-4000-8000-000000000001", 2, "ask-51", {"text": "Why?", "wants": []}) + client.ask_applicant("synthetic-token", "staff", "00000000-0000-4000-8000-000000000001", 2, "ask-refusal", {"text": "Why?", "wants": wants}) self.assertEqual(caught.exception.kind, "problem") - self.assertEqual(caught.exception.code, "review.ask-limit-reached") + self.assertEqual(caught.exception.code, code) self.assertEqual(caught.exception.detail, detail) self.assertEqual(len(attempts), 1) finally: diff --git a/crates/registry-casework-client/src/error.rs b/crates/registry-casework-client/src/error.rs index 487b9686f8..efa5a17934 100644 --- a/crates/registry-casework-client/src/error.rs +++ b/crates/registry-casework-client/src/error.rs @@ -71,6 +71,7 @@ pub enum CaseworkProblemCode { RequestUnsupportedMediaType, ReviewAskAlreadyOpen, ReviewAskAnswerTimeInvalid, + ReviewAskFormUnknown, ReviewAskLimitReached, ReviewAskNotOffered, ReviewAskNotOpen, @@ -101,7 +102,7 @@ impl CaseworkProblemCode { /// /// `Unknown` is absent: it carries whatever a newer Casework service /// answered, so it names no registered code. - pub const ALL: [Self; 46] = [ + pub const ALL: [Self; 47] = [ Self::AbsenceCoverCycle, Self::AbsenceInvalidPeriod, Self::AbsenceOverlap, @@ -127,6 +128,7 @@ impl CaseworkProblemCode { Self::RequestUnsupportedMediaType, Self::ReviewAskAlreadyOpen, Self::ReviewAskAnswerTimeInvalid, + Self::ReviewAskFormUnknown, Self::ReviewAskLimitReached, Self::ReviewAskNotOffered, Self::ReviewAskNotOpen, @@ -182,6 +184,7 @@ impl CaseworkProblemCode { Self::ReviewAskAlreadyOpen => "review.ask-already-open", Self::ReviewAskLimitReached => "review.ask-limit-reached", Self::ReviewAskAnswerTimeInvalid => "review.ask-answer-time-invalid", + Self::ReviewAskFormUnknown => "review.ask-form-unknown", Self::ReviewAskNotOffered => "review.ask-not-offered", Self::ReviewAskNotOpen => "review.ask-not-open", Self::ReviewAskProducerUnsupported => "review.ask-producer-unsupported", @@ -234,6 +237,7 @@ impl CaseworkProblemCode { "review.ask-already-open" => Self::ReviewAskAlreadyOpen, "review.ask-limit-reached" => Self::ReviewAskLimitReached, "review.ask-answer-time-invalid" => Self::ReviewAskAnswerTimeInvalid, + "review.ask-form-unknown" => Self::ReviewAskFormUnknown, "review.ask-not-offered" => Self::ReviewAskNotOffered, "review.ask-not-open" => Self::ReviewAskNotOpen, "review.ask-producer-unsupported" => Self::ReviewAskProducerUnsupported, @@ -324,6 +328,7 @@ impl CaseworkProblemCode { Self::RequestUnsupportedMediaType => 415, Self::RequestUnprocessable | Self::ReviewAskAnswerTimeInvalid + | Self::ReviewAskFormUnknown | Self::ReviewInitiatorRequired => 422, Self::ReviewQueryTooBroad => 422, Self::PreconditionRequired => 428, @@ -433,6 +438,10 @@ impl CaseworkProblemCode { "Review ask answer time invalid", "Report the time the applicant's answer was committed: not before the ask was made and no more than five minutes ahead of Casework's clock.", ), + Self::ReviewAskFormUnknown => ( + "Unknown review ask form", + "The review source does not declare the requested form.", + ), Self::ReviewAskNotOffered => ( "Review ask not offered", "The active stage of this review policy does not let a reviewer ask the applicant.", @@ -1035,6 +1044,22 @@ mod tests { assert_eq!(code.unwrap().expected_text(),Some(("Review ask limit reached","This review request has reached its limit of 50 asks. Continue the review without opening another ask."))); } + #[test] + fn unknown_ask_form_has_an_exact_recovery_contract() { + let value = "review.ask-form-unknown"; + let code = CaseworkProblemCode::parse(value); + assert!(CaseworkProblemCode::ALL.contains(&code)); + assert_eq!(code.code(), value); + assert_eq!(code.expected_status(), Some(422)); + assert_eq!( + code.expected_text(), + Some(( + "Unknown review ask form", + "The review source does not declare the requested form.", + )) + ); + } + #[test] fn review_lifecycle_problems_have_exact_recovery_contracts() { for (value, expected, status, title, detail) in [ diff --git a/crates/registry-casework-client/src/wire.rs b/crates/registry-casework-client/src/wire.rs index 2dac3d19c7..a7b8e9b820 100644 --- a/crates/registry-casework-client/src/wire.rs +++ b/crates/registry-casework-client/src/wire.rs @@ -790,6 +790,7 @@ response_wire!(ReviewTaskWire => registry_casework_core::ReviewTask { enum ReviewAskWantWire { Answer {}, Document {}, + Form { form: String }, } #[derive(Deserialize, Serialize)] @@ -853,12 +854,25 @@ struct ReviewAnswerDocumentWire { download: Option>, } +#[derive(Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct ReviewAnswerFormEntryWire { + id: uuid::Uuid, + added_at: chrono::DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + input: Option>, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + contract_changed: bool, +} + #[derive(Deserialize, Serialize)] #[serde(rename_all = "camelCase")] struct ReviewContextAnswerWire { #[serde(default, skip_serializing_if = "Option::is_none")] text: Option, documents: Vec>, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + form_entries: Vec>, answered_at: chrono::DateTime, } @@ -1254,8 +1268,12 @@ pub(crate) struct ReviewTaskContextWire { #[serde(default)] result_constraints: Option, context: ReviewTaskContextDataWire, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + additional_forms: BTreeMap, #[serde(default, skip_serializing_if = "Vec::is_empty")] asks: Vec>, + #[serde(default, skip_serializing_if = "Option::is_none")] + messages: Option, } impl ClientResponse for registry_casework_core::ReviewTaskContext { diff --git a/crates/registry-casework-core/src/adapter.rs b/crates/registry-casework-core/src/adapter.rs index 76677940b3..b74b3e4948 100644 --- a/crates/registry-casework-core/src/adapter.rs +++ b/crates/registry-casework-core/src/adapter.rs @@ -116,6 +116,12 @@ pub struct HumanDisplayObservation { /// Read live for task-context disclosure, never part of authored display fields. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub answers: BTreeMap, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub additional_forms: BTreeMap, + /// The source's message thread, read live beside the answers and passed + /// through unchanged, links included. Casework stores none of it. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub messages: Option, } /// Status deliberately contains no business fields or display reference. diff --git a/crates/registry-casework-core/src/review.rs b/crates/registry-casework-core/src/review.rs index 14cfcb3019..5aa828b004 100644 --- a/crates/registry-casework-core/src/review.rs +++ b/crates/registry-casework-core/src/review.rs @@ -1526,9 +1526,97 @@ pub struct ReviewTaskContext { #[serde(default, skip_serializing_if = "Option::is_none")] pub result_constraints: Option, pub context: ReviewTaskContextData, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub additional_forms: BTreeMap, /// The asks of the applicant on this request, oldest first. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub asks: Vec, + /// The source's live message thread with the applicant, as the source + /// served it to this reviewer. Casework stores none of it. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "schema", schemars(with = "Option"))] + pub messages: Option, +} + +/// The published shape of a source's message thread. Casework passes the +/// thread through as the source served it; this type only describes it. +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[allow(dead_code)] +struct SourceMessageThread { + count: u16, + unread: u16, + #[schemars(with = "Option>")] + #[serde(default, skip_serializing_if = "Option::is_none")] + last_sent_at: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + items: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + links: Option>, +} + +/// One message as the source serves it: plain text, never markup. +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[allow(dead_code)] +struct SourceMessage { + id: Uuid, + from: SourceMessageSide, + #[serde(default, skip_serializing_if = "Option::is_none")] + party_role: Option, + mine: bool, + #[schemars(with = "chrono::DateTime")] + sent_at: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + text: Option, +} + +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "kebab-case")] +#[allow(dead_code)] +enum SourceMessageSide { + Party, + Official, +} + +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "kebab-case")] +#[allow(dead_code)] +enum SourceMessagePartyRole { + Owner, + Subject, +} + +/// A thread command the reviewer follows with their own source token. +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[allow(dead_code)] +struct SourceMessageLink { + method: String, + path: String, + access_profile: String, + operation: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + if_match: Option, + availability: Option, +} + +#[cfg(feature = "schema")] +#[derive(schemars::JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[allow(dead_code)] +struct SourceMessageAvailability { + available: bool, + observed_revision: u64, + #[serde(default, skip_serializing_if = "Option::is_none")] + reason: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + recovery: Option, } #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] diff --git a/crates/registry-casework-core/src/review_answer.rs b/crates/registry-casework-core/src/review_answer.rs index 77d203ac65..f0e5380dd5 100644 --- a/crates/registry-casework-core/src/review_answer.rs +++ b/crates/registry-casework-core/src/review_answer.rs @@ -11,6 +11,9 @@ pub struct ReviewContextAnswer { pub text: Option, #[cfg_attr(feature = "schema", schemars(length(max = 32)))] pub documents: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + #[cfg_attr(feature = "schema", schemars(length(max = 32)))] + pub form_entries: Vec, pub answered_at: DateTime, } @@ -50,3 +53,15 @@ pub struct ReviewAnswerDownload { pub access_profile: String, pub path: String, } + +#[derive(Clone, Deserialize, Eq, PartialEq, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ReviewAnswerFormEntry { + pub id: uuid::Uuid, + pub added_at: DateTime, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub input: Option>, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub contract_changed: bool, +} diff --git a/crates/registry-casework/src/http.rs b/crates/registry-casework/src/http.rs index 96842b71b8..65c1ccab76 100644 --- a/crates/registry-casework/src/http.rs +++ b/crates/registry-casework/src/http.rs @@ -2124,6 +2124,7 @@ pub enum HttpError { ReviewAskLimitReached, ReviewAskAnswerTimeInvalid, ReviewAskNotOffered, + ReviewAskFormUnknown, ReviewAskNotOpen, ReviewAskProducerUnsupported, ReviewAskTaskInactive, @@ -2205,6 +2206,7 @@ impl From for HttpError { ReviewRuntimeError::ReviewAskLimitReached => Self::ReviewAskLimitReached, ReviewRuntimeError::ReviewAskAnswerTimeInvalid => Self::ReviewAskAnswerTimeInvalid, ReviewRuntimeError::ReviewAskNotOffered => Self::ReviewAskNotOffered, + ReviewRuntimeError::ReviewAskFormUnknown => Self::ReviewAskFormUnknown, ReviewRuntimeError::ReviewAskNotOpen => Self::ReviewAskNotOpen, ReviewRuntimeError::ReviewAskProducerUnsupported => Self::ReviewAskProducerUnsupported, ReviewRuntimeError::ReviewAskTaskInactive => Self::ReviewAskTaskInactive, @@ -2313,6 +2315,7 @@ impl HttpError { | Self::ReviewAskLimitReached | Self::ReviewAskAnswerTimeInvalid | Self::ReviewAskNotOffered + | Self::ReviewAskFormUnknown | Self::ReviewAskNotOpen | Self::ReviewAskProducerUnsupported | Self::ReviewAskTaskInactive @@ -2392,6 +2395,7 @@ impl HttpError { Self::ReviewAskLimitReached => ProblemCode::ReviewAskLimitReached, Self::ReviewAskAnswerTimeInvalid => ProblemCode::ReviewAskAnswerTimeInvalid, Self::ReviewAskNotOffered => ProblemCode::ReviewAskNotOffered, + Self::ReviewAskFormUnknown => ProblemCode::ReviewAskFormUnknown, Self::ReviewAskNotOpen => ProblemCode::ReviewAskNotOpen, Self::ReviewAskProducerUnsupported => ProblemCode::ReviewAskProducerUnsupported, Self::ReviewAskTaskInactive => ProblemCode::ReviewAskTaskInactive, diff --git a/crates/registry-casework/src/http/source_credentials.rs b/crates/registry-casework/src/http/source_credentials.rs index 9d9f53931a..0aeb7f2ab6 100644 --- a/crates/registry-casework/src/http/source_credentials.rs +++ b/crates/registry-casework/src/http/source_credentials.rs @@ -553,6 +553,8 @@ mod tests { .unwrap() .push(request.credential.expose().to_owned()); Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/src/problem.rs b/crates/registry-casework/src/problem.rs index f7a21d5f89..c45fdae2c6 100644 --- a/crates/registry-casework/src/problem.rs +++ b/crates/registry-casework/src/problem.rs @@ -34,6 +34,7 @@ pub enum ProblemCode { ReviewAskAnswerTimeInvalid, ReviewAskLimitReached, ReviewAskNotOffered, + ReviewAskFormUnknown, ReviewAskNotOpen, ReviewAskProducerUnsupported, ReviewAskTaskInactive, @@ -81,6 +82,7 @@ impl ProblemCode { Self::RequestUnsupportedMediaType, Self::ReviewAskAlreadyOpen, Self::ReviewAskAnswerTimeInvalid, + Self::ReviewAskFormUnknown, Self::ReviewAskLimitReached, Self::ReviewAskNotOffered, Self::ReviewAskNotOpen, @@ -132,6 +134,7 @@ impl ProblemCode { Self::ReviewAskLimitReached => "review.ask-limit-reached", Self::ReviewAskAnswerTimeInvalid => "review.ask-answer-time-invalid", Self::ReviewAskNotOffered => "review.ask-not-offered", + Self::ReviewAskFormUnknown => "review.ask-form-unknown", Self::ReviewAskNotOpen => registry_casework_core::REVIEW_ASK_NOT_OPEN_PROBLEM, Self::ReviewAskProducerUnsupported => "review.ask-producer-unsupported", Self::ReviewAskTaskInactive => "review.ask-task-inactive", @@ -182,6 +185,7 @@ impl ProblemCode { Self::ReviewAskLimitReached => "Review ask limit reached", Self::ReviewAskAnswerTimeInvalid => "Review ask answer time invalid", Self::ReviewAskNotOffered => "Review ask not offered", + Self::ReviewAskFormUnknown => "Unknown review ask form", Self::ReviewAskNotOpen => "Review ask not open", Self::ReviewAskProducerUnsupported => "Review ask producer unsupported", Self::ReviewAskTaskInactive => "Review ask task inactive", @@ -254,6 +258,7 @@ Self::ReviewAskAlreadyOpen=>"Wait for the open ask on this request to be answere Self::ReviewAskLimitReached=>"This review request has reached its limit of 50 asks. Continue the review without opening another ask.", Self::ReviewAskAnswerTimeInvalid=>"Report the time the applicant's answer was committed: not before the ask was made and no more than five minutes ahead of Casework's clock.", Self::ReviewAskNotOffered=>"The active stage of this review policy does not let a reviewer ask the applicant.", +Self::ReviewAskFormUnknown=>"The review source does not declare the requested form.", Self::ReviewAskNotOpen=>"This ask was already answered or closed, or the applicant answered after its due date.", Self::ReviewAskProducerUnsupported=>"The producer of this request does not read asks, so the reviewer cannot ask the applicant.", Self::ReviewAskTaskInactive=>"Ask from a task at the active stage of a request that is still under review.", @@ -324,6 +329,7 @@ Self::ReviewQueryTooBroad=>"Narrow the queue or exact subject query to complete Self::ReviewAskLimitReached => 409, Self::ReviewAskAnswerTimeInvalid => 422, Self::ReviewAskNotOffered => 409, + Self::ReviewAskFormUnknown => 422, Self::ReviewAskNotOpen => 409, Self::ReviewAskProducerUnsupported => 409, Self::ReviewAskTaskInactive => 409, @@ -505,6 +511,7 @@ const ASK_COMMAND: &[ProblemCode] = &[ ProblemCode::ReviewAskAlreadyOpen, ProblemCode::ReviewAskLimitReached, ProblemCode::ReviewAskNotOffered, + ProblemCode::ReviewAskFormUnknown, ProblemCode::ReviewAskProducerUnsupported, ProblemCode::ReviewAskTaskInactive, ProblemCode::SourceVersionMismatch, diff --git a/crates/registry-casework/src/review.rs b/crates/registry-casework/src/review.rs index 300a857a45..d146c7773d 100644 --- a/crates/registry-casework/src/review.rs +++ b/crates/registry-casework/src/review.rs @@ -126,6 +126,8 @@ pub enum ReviewRuntimeError { ReviewAskLimitReached, #[error("the answer time precedes the ask or lies in the future")] ReviewAskAnswerTimeInvalid, + #[error("the source does not declare the requested form")] + ReviewAskFormUnknown, #[error("the stage of this task does not offer asks")] ReviewAskNotOffered, #[error("the ask is not open")] @@ -1067,6 +1069,8 @@ impl CaseworkService { }; let mut retained_author_required = false; let mut live_answers = std::collections::BTreeMap::new(); + let mut additional_forms = std::collections::BTreeMap::new(); + let mut live_messages = None; let context = match record.context.as_ref().ok_or(ReviewRuntimeError::Corrupt)? { ReviewContext::Submitted { snapshot } => ReviewTaskContextData::Submitted { snapshot: snapshot.clone(), @@ -1134,6 +1138,8 @@ impl CaseworkService { .map_err(|error| invalid_provider_display(&record.policy, error))?; if delegated.is_none() { live_answers = view.answers; + additional_forms = view.additional_forms; + live_messages = view.messages; } ReviewTaskContextData::CurrentSource { reference: binding.reference.clone(), @@ -1173,7 +1179,9 @@ impl CaseworkService { policy_closure: record.policy, result_constraints: record.result_constraints, context, + additional_forms, asks, + messages: live_messages, }) } @@ -1676,12 +1684,32 @@ impl CaseworkService { disclosure: SourceDisclosure, source_profile_id: Option<&str>, token: &str, + ) -> Result<(), ReviewRuntimeError> { + self.preflight_review_disclosure_with_forms( + record, + disclosure, + source_profile_id, + token, + &[], + ) + .await + } + + async fn preflight_review_disclosure_with_forms( + &self, + record: &ReviewRequestRecord, + disclosure: SourceDisclosure, + source_profile_id: Option<&str>, + token: &str, + requested_forms: &[&str], ) -> Result<(), ReviewRuntimeError> { let require_reviewable = disclosure == SourceDisclosure::Reviewable; match &record.policy.context { ReviewContextPolicy::Submitted => { if source_profile_id.is_some() && self.pending_source.is_none() { Err(ReviewRuntimeError::SourceProfileNotApplicable) + } else if !requested_forms.is_empty() { + Err(ReviewRuntimeError::ReviewAskFormUnknown) } else { Ok(()) } @@ -1723,6 +1751,12 @@ impl CaseworkService { if status.identity != identity || (require_reviewable && !status.reviewable) { return Err(ReviewRuntimeError::NotFound); } + if requested_forms + .iter() + .any(|id| !view.additional_forms.contains_key(*id)) + { + return Err(ReviewRuntimeError::ReviewAskFormUnknown); + } Ok(()) } } diff --git a/crates/registry-casework/src/review/asks.rs b/crates/registry-casework/src/review/asks.rs index 4545b1c2dc..d9dab0448e 100644 --- a/crates/registry-casework/src/review/asks.rs +++ b/crates/registry-casework/src/review/asks.rs @@ -46,8 +46,22 @@ impl CaseworkService { .review_request_for_reviewer_task(actor, task_id) .await?; ensure_review_result_retained(&record)?; - self.preflight_review_record_source(&record, source_profile_id, token) - .await?; + let requested_forms = request + .wants + .iter() + .filter_map(|want| match want { + ReviewAskWant::Form { form } => Some(form.as_str()), + _ => None, + }) + .collect::>(); + self.preflight_review_disclosure_with_forms( + &record, + SourceDisclosure::Reviewable, + source_profile_id, + token, + &requested_forms, + ) + .await?; let producer_reads_asks = self .project .trusted_producers diff --git a/crates/registry-casework/src/review/source_answers.rs b/crates/registry-casework/src/review/source_answers.rs index eb51bece36..22fb874c72 100644 --- a/crates/registry-casework/src/review/source_answers.rs +++ b/crates/registry-casework/src/review/source_answers.rs @@ -27,6 +27,11 @@ pub(super) fn join( .iter() .any(|want| matches!(want, ReviewAskWant::Document {})) && answer.documents.is_empty() + || ask + .wants + .iter() + .any(|want| matches!(want, ReviewAskWant::Form { .. })) + && answer.form_entries.is_empty() { inconsistent += 1; continue; @@ -46,7 +51,13 @@ fn validate(answer: &ReviewContextAnswer) -> Result<(), ReviewRuntimeError> { .text .as_ref() .is_some_and(|text| text.trim().is_empty() || text.len() > 2000 || text.contains('\0')) + || (answer.text.is_none() && answer.documents.is_empty() && answer.form_entries.is_empty()) || answer.documents.len() > 32 + || answer.form_entries.len() > 32 + || answer + .form_entries + .iter() + .any(|entry| entry.id.is_nil() || entry.contract_changed == entry.input.is_some()) || !answer .answered_at .timestamp_subsec_nanos() @@ -130,6 +141,32 @@ mod tests { } } + #[test] + fn a_source_answer_requires_content_even_when_the_ask_has_no_wants() { + let mut asks = vec![ask(), ask(), ask()]; + for ask in &mut asks { + ask.wants.clear(); + } + let mut empty = answer(); + empty.text = None; + let mut document_only = empty.clone(); + document_only.documents = serde_json::from_value(json!([{ + "id":"cited-file", "sha256":"a".repeat(64), + "contentType":"text/plain", "byteSize":1 + }])) + .unwrap(); + let answers = BTreeMap::from([ + (asks[0].ask_id, empty), + (asks[1].ask_id, answer()), + (asks[2].ask_id, document_only), + ]); + + assert_eq!(join(&mut asks, answers, false).unwrap(), 1); + assert!(asks[0].answer.is_none()); + assert!(asks[1].answer.as_ref().unwrap().text.is_some()); + assert_eq!(asks[2].answer.as_ref().unwrap().documents.len(), 1); + } + #[test] fn source_answer_documents_accept_the_breg_media_type_bound() { let mut answer = answer(); diff --git a/crates/registry-casework/src/task_grants/http_tests.rs b/crates/registry-casework/src/task_grants/http_tests.rs index 787e4d2c22..42e7d9dde4 100644 --- a/crates/registry-casework/src/task_grants/http_tests.rs +++ b/crates/registry-casework/src/task_grants/http_tests.rs @@ -51,6 +51,8 @@ impl ReviewContextProvider for Source { _ => {} } Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/src/task_grants/native_exchange_tests.rs b/crates/registry-casework/src/task_grants/native_exchange_tests.rs index 72764f1018..4c01a25402 100644 --- a/crates/registry-casework/src/task_grants/native_exchange_tests.rs +++ b/crates/registry-casework/src/task_grants/native_exchange_tests.rs @@ -64,6 +64,8 @@ impl ReviewContextProvider for Source { request: HumanDisplayRequest<'_>, ) -> Result { Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/tests/review_acceptance_postgres.rs b/crates/registry-casework/tests/review_acceptance_postgres.rs index d11ff73577..55c4cfd3df 100644 --- a/crates/registry-casework/tests/review_acceptance_postgres.rs +++ b/crates/registry-casework/tests/review_acceptance_postgres.rs @@ -120,6 +120,8 @@ impl ReviewContextProvider for SubstituteProvider { identity.subject.version = "successor".into(); } Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity, reviewable: true, diff --git a/crates/registry-casework/tests/review_http.rs b/crates/registry-casework/tests/review_http.rs index 8109055b61..404ecd943b 100644 --- a/crates/registry-casework/tests/review_http.rs +++ b/crates/registry-casework/tests/review_http.rs @@ -1,5 +1,7 @@ #![cfg(feature = "postgres-test")] +#[path = "support/ask_form_http.rs"] +mod ask_form_http; #[path = "support/ask_limit_http.rs"] mod ask_limit_http; @@ -128,6 +130,12 @@ impl ReviewContextProvider for ReviewSource { identity.subject.version = "2".into(); } Ok(HumanDisplayObservation { + additional_forms: if request.identity.subject.id == "form-ask" { + BTreeMap::from([("household-details".into(), "Household details".into())]) + } else { + BTreeMap::new() + }, + messages: None, answers: self .delegated_barrier .as_ref() @@ -6172,6 +6180,8 @@ impl ReviewContextProvider for SeparateHumanSource { return Err(ReviewContextError::Concealed); } Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, @@ -7735,6 +7745,7 @@ async fn delegated_institutional_reads_carry_neither_asks_nor_markers() { barrier.answers.lock().unwrap().insert( asked.ask.ask_id, ReviewContextAnswer { + form_entries: Vec::new(), text: Some("source answer excluded from institutional delegation".into()), documents: vec![], answered_at: asked.ask.asked_at, @@ -7913,6 +7924,8 @@ impl ReviewContextProvider for RecordingSourceProvider { return Err(ReviewContextError::Concealed); } Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: if request.include_answers { self.answers.lock().unwrap().clone() } else { @@ -9579,6 +9592,7 @@ async fn human_source_disclosure_matches_breg_release_refuses_other_subject_and_ answers.lock().unwrap().insert( ask_id, ReviewContextAnswer { + form_entries: Vec::new(), text: Some(answer_sentinel.into()), documents: vec![], answered_at: asked_at, diff --git a/crates/registry-casework/tests/review_postgres.rs b/crates/registry-casework/tests/review_postgres.rs index 898f72a1ff..21e63d17eb 100644 --- a/crates/registry-casework/tests/review_postgres.rs +++ b/crates/registry-casework/tests/review_postgres.rs @@ -90,6 +90,8 @@ impl ReviewContextProvider for ReviewSource { return Err(ReviewContextError::BindingMoved); } Ok(HumanDisplayObservation { + additional_forms: Default::default(), + messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: *self.state.lock().unwrap(), diff --git a/crates/registry-casework/tests/support/ask_form_http.rs b/crates/registry-casework/tests/support/ask_form_http.rs new file mode 100644 index 0000000000..4b7c0b58b8 --- /dev/null +++ b/crates/registry-casework/tests/support/ask_form_http.rs @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: Apache-2.0 +use super::*; + +#[tokio::test] +async fn an_unknown_source_form_is_refused_without_recording_an_ask() { + let idp = MockIdp::start().await; + let mut project = asks_http_project(&idp); + project.review_policies[0].context = ReviewContextPolicy::CurrentSource { + provider: "registry".into(), + contract: context_contract(), + }; + let (app, _, source_revoked, _, _, _, database) = app_with_project(&idp, project).await; + let input = review_request_for_subject("form-ask", "form-ask-ref", &idp.issuer()); + let (created, task) = create_task(&app, &database, &idp, &input).await; + let headers = |revision, key: &str| { + vec![ + ("authorization", format!("Bearer {}", reviewer_token(&idp))), + (SOURCE_PROFILE_HEADER, "reviewer-source".into()), + ( + SOURCE_AUTHORIZATION_HEADER, + format!("Bearer {}", source_token_value(&idp)), + ), + ("if-match", format!("\"{revision}\"")), + ("idempotency-key", key.into()), + ] + }; + let (status, _, body) = http_json( + &app, + "POST", + with_profile(format!("/v1/review-tasks/{task}/claim"), "staff"), + &headers(1, "claim-form-task"), + None, + ) + .await; + assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body)); + + for (concealed, expected_status, expected_code) in [ + ( + false, + StatusCode::UNPROCESSABLE_ENTITY, + "review.ask-form-unknown", + ), + (true, StatusCode::NOT_FOUND, "request.not-found"), + ] { + source_revoked.store(concealed, Ordering::SeqCst); + let (status, _, body) = http_json( + &app, + "POST", + with_profile(format!("/v1/review-tasks/{task}/asks"), "staff"), + &headers( + 2, + if concealed { + "concealed-form" + } else { + "unknown-form" + }, + ), + Some(json!({ + "text":"Please complete the additional form.", + "wants":[{"kind":"form","form":"unknown"}] + })), + ) + .await; + let problem: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!(status, expected_status, "{problem}"); + assert_eq!(problem["code"], expected_code, "{problem}"); + } + + let row = database + .query_one( + "SELECT (SELECT count(*) FROM casework_review_asks WHERE request_id=$1), + (SELECT count(*) FROM casework_review_ask_events WHERE request_id=$1)", + &[&created.request_id], + ) + .await + .unwrap(); + assert_eq!(row.get::<_, i64>(0), 0); + assert_eq!(row.get::<_, i64>(1), 0); + source_revoked.store(false, Ordering::SeqCst); + let (status, _, body) = http_json( + &app, + "POST", + with_profile(format!("/v1/review-tasks/{task}/asks"), "staff"), + &headers(2, "declared-form"), + Some(json!({"text":"Please complete the additional form.", + "wants":[{"kind":"form","form":"household-details"}]})), + ) + .await; + assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body)); + let accepted: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!( + accepted["ask"]["wants"], + json!([{"kind":"form","form":"household-details"}]) + ); + let (status, _, body) = http_json( + &app, + "GET", + with_profile(format!("/v1/review-tasks/{task}/context"), "staff"), + &headers(3, "read-form")[..3], + None, + ) + .await; + assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body)); + let context: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!( + context["additionalForms"], + json!({"household-details":"Household details"}) + ); + idp.stop().await; +} diff --git a/crates/registry-casework/tests/support/source_ask_answers.rs b/crates/registry-casework/tests/support/source_ask_answers.rs index a51b9bfe5b..0ab073f599 100644 --- a/crates/registry-casework/tests/support/source_ask_answers.rs +++ b/crates/registry-casework/tests/support/source_ask_answers.rs @@ -112,11 +112,13 @@ async fn source_answers_join_known_asks_live_without_entering_the_display_schema vec![false], "claim preflight must not request applicant answers" ); + let mut question = ask_request("Why?"); + question.wants.clear(); let asked = service .ask_applicant( &fixture.reviewer_a, task, - ask_request("Why?"), + question, Some("staff"), "human-token", held.revision, @@ -165,26 +167,33 @@ async fn source_answers_join_known_asks_live_without_entering_the_display_schema assert!(!logs.contains("unknown-answer-must-not-appear")); let mut inconsistent = answer.clone(); inconsistent["answeredAt"] = json!(asked.ask.asked_at - chrono::Duration::seconds(1)); - *answers.lock().unwrap() = json!({(asked.ask.ask_id.to_string()):inconsistent}); - let captured = CapturedLogs::default(); - let subscriber = tracing_subscriber::fmt() - .json() - .with_writer(captured.clone()) - .finish(); - let partial = service - .review_task_context(&fixture.reviewer_a, task, Some("staff"), "human-token") - .with_subscriber(subscriber) - .await - .unwrap(); - let partial = serde_json::to_value(partial).unwrap(); - assert_eq!( - partial["context"], value["context"], - "one bad answer must not hide the authored fields" - ); - assert!(partial["asks"][0].get("answer").is_none()); - let logs = String::from_utf8(captured.0.lock().unwrap().clone()).unwrap(); - assert!(logs.contains("\"dropped_answers\":1"), "{logs}"); - assert!(!logs.contains("synthetic-answer-live-only")); + let empty = json!({"documents":[],"answeredAt":asked.ask.asked_at}); + for (case, invalid) in [ + ("predates the ask", inconsistent), + ("has no content", empty), + ] { + *answers.lock().unwrap() = json!({(asked.ask.ask_id.to_string()):invalid}); + let captured = CapturedLogs::default(); + let subscriber = tracing_subscriber::fmt() + .json() + .with_writer(captured.clone()) + .finish(); + let partial = service + .review_task_context(&fixture.reviewer_a, task, Some("staff"), "human-token") + .with_subscriber(subscriber) + .await + .unwrap(); + let partial = serde_json::to_value(partial).unwrap(); + assert_eq!( + partial["context"], value["context"], + "one bad answer must not hide the authored fields" + ); + assert_eq!(partial["asks"][0]["askId"], json!(asked.ask.ask_id)); + assert!(partial["asks"][0].get("answer").is_none(), "{case}"); + let logs = String::from_utf8(captured.0.lock().unwrap().clone()).unwrap(); + assert!(logs.contains("\"dropped_answers\":1"), "{case}: {logs}"); + assert!(!logs.contains("synthetic-answer-live-only")); + } for table in [ "casework_review_requests", "casework_review_tasks", diff --git a/crates/registry-review-client/src/client.rs b/crates/registry-review-client/src/client.rs index afc652b3cb..7669336841 100644 --- a/crates/registry-review-client/src/client.rs +++ b/crates/registry-review-client/src/client.rs @@ -212,6 +212,7 @@ impl ClientResponse for ReviewResultFeedPage { enum ReviewAskWantWire { Answer {}, Document {}, + Form { form: String }, } #[derive(Deserialize, Serialize)] diff --git a/crates/registry-review-client/tests/http_boundary.rs b/crates/registry-review-client/tests/http_boundary.rs index bf17501545..f7df709007 100644 --- a/crates/registry-review-client/tests/http_boundary.rs +++ b/crates/registry-review-client/tests/http_boundary.rs @@ -2708,6 +2708,87 @@ async fn ask_read_refuses_every_mismatched_binding_and_invalid_ask() { server.abort(); } +#[tokio::test] +async fn ask_responses_validate_known_form_wants() { + let (request_id, ask_id) = (Uuid::from_u128(7), Uuid::from_u128(5)); + let binding = expected_binding(request_id); + let token = BearerToken::new("one-call-secret").expect("fixture token"); + for (want, valid) in [ + (json!({"kind":"answer"}), true), + (json!({"kind":"document"}), true), + (json!({"kind":"answer","formId":"extra-details"}), true), + (json!({"kind":"document","formId":"extra-details"}), true), + (json!({"kind":"form","form":"extra-details","futureWantMember":true}), true), + (json!({"kind":"form","formId":"extra-details"}), false), + (json!({"kind":"form","form":"Invalid"}), false), + (json!({"kind":"future-want"}), false), + ] { + let mut read = ask_json(request_id, ask_id); + let mut answered = answered_ask_json(request_id, ask_id); + // Additive fields remain compatible. The known tag and its required + // members still have to describe a valid want. + read["providerMetadata"] = json!({"revision": 1}); + answered["providerMetadata"] = json!({"revision": 1}); + read["wants"] = json!([want]); + answered["wants"] = read["wants"].clone(); + let app = Router::new() + .route( + "/v1/review-requests/{id}/asks/{ask}", + get(move || { + let read = read.clone(); + async move { json_response(StatusCode::OK, read) } + }), + ) + .route( + "/v1/review-requests/{id}/asks/{ask}/answer", + post(move || { + let answered = answered.clone(); + async move { json_response(StatusCode::OK, answered) } + }), + ); + let (client, server) = serve(app).await; + let read = client + .ask(ReviewAuth::new(&token, "producer"), &binding, ask_id) + .await; + let answered = client + .answer_ask( + ReviewAuth::new(&token, "producer"), + "answer-5", + &binding, + ask_id, + &ask_answer(), + ) + .await; + if valid { + assert!( + matches!(read, Ok(ReviewAskResponse::Available(_))), + "{read:?}" + ); + assert!( + matches!(answered, Ok(ReviewAskAnswerResponse::Answered(_))), + "{answered:?}" + ); + } else { + for error in [ + read.expect_err("invalid want"), + answered.expect_err("invalid want"), + ] { + assert!( + matches!( + error, + ReviewClientError::Protocol { + failure: ReviewProtocolFailure::Body, + .. + } + ), + "{error:?}" + ); + } + } + server.abort(); + } +} + /// Every response the ask read and the answer call must refuse for a defined /// refusal status instead of mapping it to a typed outcome. fn refusals_that_are_not_typed_outcomes(status: StatusCode) -> Vec<(&'static str, Response)> { diff --git a/crates/registry-review-protocol/src/lib.rs b/crates/registry-review-protocol/src/lib.rs index 1a1c39c61b..9d41064c30 100644 --- a/crates/registry-review-protocol/src/lib.rs +++ b/crates/registry-review-protocol/src/lib.rs @@ -656,7 +656,7 @@ impl ReviewCancelRequest { } /// What a reviewer's ask requests from the subject's owner. -#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] pub enum ReviewAskWant { @@ -664,6 +664,34 @@ pub enum ReviewAskWant { // on the unit variants of an internally tagged enum. Answer {}, Document {}, + Form { + #[serde(deserialize_with = "deserialize_form_id")] + #[cfg_attr( + feature = "schema", + schemars(regex(pattern = "^[a-z][a-z0-9_-]{0,63}$")) + )] + form: String, + }, +} + +fn deserialize_form_id<'de, D: serde::Deserializer<'de>>( + deserializer: D, +) -> Result { + let form = String::deserialize(deserializer)?; + if valid_form_id(&form) { + Ok(form) + } else { + Err(serde::de::Error::custom("invalid form identifier")) + } +} + +fn valid_form_id(form: &str) -> bool { + let mut bytes = form.bytes(); + form.len() <= 64 + && bytes.next().is_some_and(|byte| byte.is_ascii_lowercase()) + && bytes.all(|byte| { + byte.is_ascii_lowercase() || byte.is_ascii_digit() || matches!(byte, b'-' | b'_') + }) } #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/crates/registry-review-protocol/tests/form_want.rs b/crates/registry-review-protocol/tests/form_want.rs new file mode 100644 index 0000000000..d8c2802d9b --- /dev/null +++ b/crates/registry-review-protocol/tests/form_want.rs @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: Apache-2.0 +use registry_review_protocol::ReviewAskWant; +use serde_json::json; + +#[test] +fn a_form_want_round_trips_the_declared_form_id() { + let wire = json!({"kind":"form","form":"household-details"}); + let want: ReviewAskWant = serde_json::from_value(wire.clone()).expect("decode a form want"); + assert_eq!(serde_json::to_value(want).unwrap(), wire); +} + +#[test] +fn a_form_want_requires_only_its_form_member() { + for invalid in [ + json!({"kind":"form"}), + json!({"kind":"form","formId":"household-details"}), + json!({"kind":"form","form":"household-details","input":{"size":4}}), + json!({"kind":"answer","form":"household-details"}), + json!({"kind":"document","form":"household-details"}), + ] { + assert!( + serde_json::from_value::(invalid.clone()).is_err(), + "accepted {invalid}" + ); + } +} diff --git a/docs/site/src/content/docs/configure/breg-journeys.mdx b/docs/site/src/content/docs/configure/breg-journeys.mdx index 740b78038b..2f58dbd5dc 100644 --- a/docs/site/src/content/docs/configure/breg-journeys.mdx +++ b/docs/site/src/content/docs/configure/breg-journeys.mdx @@ -5,7 +5,7 @@ status: current owner: registry-docs source_repos: - registry-stack -last_reviewed: "2026-10-17" +last_reviewed: "2026-12-02" doc_type: how-to locale: en standards_referenced: @@ -94,6 +94,55 @@ jurisdiction: Keep the success and the refusal; add a step for each invariant your change affects. +### Wait for automatic application + +A Proposal Action with automatic application, such as one with `review: {type: none}`, is applied +by the built-in executor after Submit, so the Submit response still shows the Proposal as +`submitted`. To assert what the Action applied, give a later `get` step `waitSeconds`, from 1 to +60. During the schema test the step runs the built-in executor until it has no due work, reads +the Proposal again, and repeats until the response matches `expect`. A step that still does not +match when the time runs out fails with `fixture.proposal.wait-timed-out`. Steps without +`waitSeconds` never run the executor, so a submitted automatic Proposal stays queued for them. + +`waitSeconds` covers the whole step, including authentication, waiting for the executor, and +reading and checking the response. After a step times out, `bregctl test` can spend up to +`operationalTimeouts.shutdownGraceMilliseconds` giving an in-flight attempt time to finish within +its own worker budget. The command still reports the step timeout if the attempt finishes during +cleanup. If the grace expires, the CLI stops the worker. Any unfinished committed claim keeps its +original attempt count and lease expiry. A worker that later runs against that database uses the +normal lease recovery rules. + +{/* Evidence: crates/registry-breg/src/fixtures.rs; crates/registry-breg/src/postgres/proposal.rs; + crates/registry-bregctl/tests/wasm_test_lifecycle.rs. */} + +`captureResults` on that step maps one of the Action's effect IDs to a record capture, taken from +the application's result links. The effect must be the only one on its Record type. A later step +reads the record through that capture. The default starter registers a contact this way: + +```sh +bregctl init directory +``` + +```yaml title="directory/tests/journeys.yaml" test-excerpt="directory/tests/journeys.yaml" + - id: await-registration + actor: editor + action: register-contact + accessProfile: directory-editor + claims: + principal: synthetic-directory-editor + scopes: [registry:directory:write] + purpose: directory-administration + directClaims: {jurisdiction: zone-a} + request: {type: proposal, transition: get, proposalCapture: registration-draft, waitSeconds: 10} + expect: + outcome: success + status: 200 + fields: {state: applied, applicationStatus: {mode: automatic, state: applied}} + captureResults: {contact: registered-contact} +``` + +### Test a scripted Action Plan + A scripted Action Plan has an offline loop, with input keyed by authored input ID: ```json title="correction-input.json" test-file @@ -135,7 +184,10 @@ A passing run writes a [receipt](../../reference/glossary/#receipt) for that exa inputs. A refused step names the failure; repair it and rerun into a fresh receipt path. {/* Evidence: crates/registry-bregctl/src/lib.rs; crates/registry-bregctl/src/check.rs; - crates/registry-breg/src/fixtures.rs; products/breg/examples/facility/tests/journeys.yaml. */} + crates/registry-breg/src/fixtures.rs; crates/registry-breg/src/fixtures/proposals.rs; + products/breg/examples/facility/tests/journeys.yaml; + products/breg/examples/minimal/tests/journeys.yaml; + crates/registry-breg/tests/postgres_fixture_journeys.rs. */} ## Journey file keys diff --git a/docs/site/src/content/docs/configure/breg-proposals.mdx b/docs/site/src/content/docs/configure/breg-proposals.mdx index 527c26db49..72f4e7e34f 100644 --- a/docs/site/src/content/docs/configure/breg-proposals.mdx +++ b/docs/site/src/content/docs/configure/breg-proposals.mdx @@ -269,7 +269,7 @@ A caller whose principal only happens to equal an ordinary input of an Action wi A profile holds at most one entry for each party of an Action, and an entry without `party` cannot sit beside them. For one Proposal, the owner entry governs a caller who filed it, then the subject entry a caller who is its subject. The governing entry alone decides the operation and the projection, including `readableInputs` and attachments, so a self-filer always sees the owner entry's view. -A subject entry may hold only `get`, `list`, `get-review-status`, `answer`, `add` and `cancel`. +A subject entry may hold only `get`, `list`, `get-review-status`, `answer`, `add`, `message` and `cancel`. The subject cannot change what someone else filed. An operation the subject entry does not hold answers `403 profile.not-authorized` while the subject can still read the Proposal. A subject whose target has left their row boundary, and every other caller refused after a Proposal is found, gets a concealed `404 resource.not-found`. @@ -511,7 +511,7 @@ compiled slot order. Correct that slot and read the Proposal again. Every Proposal document and lifecycle event carries a derived `turn`: -- `party`: the caller who drives the Proposal acts next. A draft, a blocked application that needs corrected input, and a submission whose Review ended without an approval it can use (changes requested, an expired approval, a failed review submission, a provider end) are the party's turn. +- `party`: the caller who drives the Proposal acts next. A draft, a blocked application that needs corrected input, a submission whose Review ended without an approval it can use (changes requested, an expired approval, a failed review submission, a provider end), and an open Proposal with an office message the party has not read are the party's turn. - `official`: a reviewer or applier acts next. Review in progress or being retried, an approved or review-free manual submission awaiting Apply, and an automatic application blocked on a dependency outage are an official's turn. - `nobody`: no one needs to act. The Proposal is `applied`, `cancelled` or `rejected`, or its automatic application is queued or running. @@ -528,7 +528,8 @@ Proposal Get, list items and command responses also serve a derived `status` whe `status` and `turn` come from one pure rule over the lifecycle state, the current submission's review progress and its application status. Nothing stores either value. Lifecycle events carry `turn` but do not carry `status`. An older retained command receipt can replay without `status`. -`bregctl explain lifecycle` lists each state's possible statuses and turns with their conditions in its `v1alpha9` explanation format. +`bregctl explain lifecycle` lists each state's possible statuses and turns with their conditions in its `v1alpha10` explanation format. +An unread office message changes only the turn: the status and every offered command stay as they were. It says whose move the work waits on, not who is authorised to make it: the links still decide what the current caller may do. List Proposals by turn with `GET /v1/proposals?turn=party` (or `official`, `nobody`). There is no `status` query filter. @@ -894,7 +895,7 @@ Each download link uses the reviewer's own authority and carries the exact revie Additions follow Proposal detail retention and share attachment byte verification and cleanup. Revise starts a submission version with no additions. Use the `added` hook transition to observe the value-free `proposal.added` event. -Proposal hooks without a `transitions` filter also receive `added`, `asked` and `answered`. +Proposal hooks without a `transitions` filter also receive `added`, `asked`, `answered` and `messaged`. Configure an explicit transition filter if your receiver cannot accept those events. {/* Evidence: crates/registry-breg/src/contract.rs AdditionSlotSource; @@ -988,6 +989,129 @@ A feed cursor reset checks stored asks before fetching them again, including aft crates/registry-breg/src/review_store/asks/delivery.rs; crates/registry-casework/src/review/source_answers.rs. */} +## Ask for an additional form + +Declare `additionalForms` when a reviewer may need a few structured answers that the original +request did not ask for. +The applicant adds an entry to the current submission while its review is open; the submission +version, the frozen effects and the effect digest stay the same. +An applicant who needs to change the effects revises the submission instead. + +```yaml +execution: + mode: proposal + proposal: + additionalForms: + household-details: + maximumCount: 1 + inputs: + - id: household-size + type: int64 + required: true + classification: restricted +``` + +An Action declares at most 8 forms, each with 1 to 16 inputs typed and validated like Action inputs, +and `maximumCount` from 1 to 32 entries per submission, 8 by default. +Forms need required review. +A form's contract digest covers its input IDs, API names, types, classifications and schema, but +not labels: the input ID carries the meaning, so a label-only change keeps earlier values visible. +A changed contract withholds earlier values and marks those entries `contractChanged`. + +Grant `add` and list the form in `writableForms` to allow entries. +Grant `get` and list it in `readableForms` to serve its entries on the Proposal document. +These grants are independent: a profile that writes a form it cannot read sees the form without +its entries. +Follow `additionalForms..links.add` with `If-Match` and `Idempotency-Key` and a body of +`{"input":{...}}` keyed by each input's API name. +The response carries the updated Proposal, its new ETag and `formEntryId`. +An undeclared form gets `404 proposal.form-undeclared`. An entry after the review is decided or +the submission is revised gets `412 precondition.failed`. See the +[additional forms API reference](../../reference/breg-api/#additional-forms) for the shared byte budget +and count refusals. + +A reviewer can name a form in a Casework ask with a `form` want, and the applicant answers by +citing an uncited entry of the current submission in the answer's `formEntries`. +To show entries in the review context, declare a field of type `additional-form`: + +```yaml +reviewContext: + id: household-review + fields: + household: + type: additional-form + form: household-details +``` + +BReg serves that field only to a person reviewing for themselves. +`bregctl check` refuses the field in the `readableContextFields` of an agent, service or task-grant +profile with `breg.additional-form.context-reader-invalid`, and any other reader who is not a person +reading for themselves is refused the review context. +Form inputs stay out of audit and lifecycle events, and Proposal detail erasure covers the entry, +its citations and the held responses that could replay it. + +{/* Evidence: crates/registry-breg/src/contract.rs AdditionalFormSource; + crates/registry-breg/src/immediate_actions.rs breg.additional-form.context-reader-invalid; + crates/registry-breg/src/api/proposals/forms.rs; + crates/registry-breg/src/mutation/proposal/forms.rs; + crates/registry-breg/tests/support/proposal_additions.rs; + crates/registry-breg/tests/proposal_additional_forms.rs. */} + +## Exchange messages with the office + +Declare `messages` to give each Proposal one thread between its party, the owner or the subject, +and the office. +The thread needs no review and stays with the Proposal across submissions. + +```yaml +execution: + mode: proposal + proposal: + messages: + maximumCount: 200 +``` + +`maximumCount` is 1 to 1000 messages for each side, 200 by default, so neither side can fill the +thread and close it for the other. +Declaring the thread does not change the Action revision, so Proposals in flight get it at +activation. + +Grant `message` on a Proposal grant to read and write the thread. +A message written under a party-bound entry comes `from: party`, under any other grant +`from: official`; readers never learn which officer wrote. +Only a verified person acting for themselves reads or writes, and `bregctl check` refuses `message` +on an agent or service profile. +The thread opens at the first Submit and closes for writes when the Proposal is applied, rejected or +cancelled. + +Follow the promoted links in the Proposal's `messages` member, or in `context.messages` on a review +context read with `include=messages`: + +- `POST /v1/proposals/{proposal_id}/messages` with `If-Match`, `Idempotency-Key` and `{"text":"..."}`. + Text is at most 2,000 UTF-8 bytes that display as written: no control character but a line break + or tab, a carriage return only before a line feed, and no reordering, zero-width or tag character. +- `GET /v1/proposals/{proposal_id}/messages` pages newest first with `after` and `limit`, and carries + the thread's links. +- `POST /v1/proposals/{proposal_id}/messages/read` with `{"through":""}`. + +A write and a mark-read each advance the Proposal revision and ETag, so refetch before the next +command. +A reviewer whose profile holds `message` without `get` receives the review context when it is readable and fits the 3 MiB receipt limit. +BReg returns the thread alone if the Proposal has no current frozen submission, the Action has +changed, or the complete response exceeds that limit. +Use the review-context read to fetch any context you can still access. +A receipt that includes the thread requires current `message` authority for the original thread side on replay. +An office message the party has not read makes it the party's turn without changing the status. +Show message text as plain text, never as markup. +Writes emit `proposal.messaged` with `messageFrom` and no text; marking read emits no event. +Messages follow the Proposal's retention, and erasing a submission clears its message text. + +{/* Evidence: crates/registry-breg/src/contract.rs ProposalMessagesSource; + crates/registry-breg/src/proposal_messages.rs valid_text; + crates/registry-breg/src/api/proposals/messages.rs; + crates/registry-breg/src/mutation/proposal/messages.rs hold_proposal_response, replay_proposal_disclosure; + crates/registry-breg/tests/postgres_proposal_messages.rs. */} + ## Keep a supporting document on the record A Proposal file can stay with the record that the Proposal writes. diff --git a/docs/site/src/content/docs/configure/casework.mdx b/docs/site/src/content/docs/configure/casework.mdx index 066133f9d3..0699603992 100644 --- a/docs/site/src/content/docs/configure/casework.mdx +++ b/docs/site/src/content/docs/configure/casework.mdx @@ -542,7 +542,7 @@ reviewPolicies: The holder sends `POST /v1/review-tasks/{taskId}/asks` with `If-Match`, `Idempotency-Key` and a body of `text` and `wants`. The text is plain, bounded like a public reason, and has no control characters. -`wants` lists what the applicant should give, from `answer` and `document`. +`wants` lists what the applicant should give, from `answer`, `document` and `form`. A `form` want names a form the source declares, as `{"kind":"form","form":""}`; Casework checks it through your own source authorization before it stores the ask and refuses an undeclared form with `422 review.ask-form-unknown`. Casework refuses the ask when the caller does not hold the task, the request is no longer under review, the task is not at the active stage, the stage declares no `asks`, the producer does not read asks, or the request already has an open ask. Each refusal has its own problem code: `review.ask-task-inactive`, `review.ask-not-offered`, `review.ask-producer-unsupported` and `review.ask-already-open`, besides `review.task-not-held` and the usual precondition failure. Each review request allows at most 50 asks across all tasks and stages, including answered, expired and closed asks, and further attempts return `409 review.ask-limit-reached` without changing the request, task or clocks. diff --git a/docs/site/src/content/docs/operate/breg-webhooks.mdx b/docs/site/src/content/docs/operate/breg-webhooks.mdx index 0f759ad9ba..efc92997e0 100644 --- a/docs/site/src/content/docs/operate/breg-webhooks.mdx +++ b/docs/site/src/content/docs/operate/breg-webhooks.mdx @@ -92,7 +92,8 @@ A Proposal lifecycle hook is declared on the Action under `execution.proposal.ho transitions, and uses its own value-free event schema; it is separate from Record field projections. If you omit `transitions`, BReg matches every Proposal transition. -This includes `added`, `asked` and `answered`, with events `proposal.added`, `proposal.asked` and `proposal.answered`. +This includes `added`, `asked`, `answered` and `messaged`, with events `proposal.added`, `proposal.asked`, `proposal.answered` and `proposal.messaged`. +A `proposal.messaged` event carries `messageFrom` (`party` or `official`) and never the message text. Your existing receiver must accept these events when its hook has no transition filter. Set an explicit `transitions` list if your receiver accepts only selected events. diff --git a/docs/site/src/content/docs/reference/breg-api.mdx b/docs/site/src/content/docs/reference/breg-api.mdx index 10ad8f1956..46ffd0b9ef 100644 --- a/docs/site/src/content/docs/reference/breg-api.mdx +++ b/docs/site/src/content/docs/reference/breg-api.mdx @@ -620,7 +620,7 @@ progress. Once its result window has lapsed and no application receipt remains, ### Proposal asks -`POST /v1/proposals/{proposal_id}/asks/{ask_id}/answer` requires the selected profile's `answer` authority, `If-Match`, `Idempotency-Key` and an `application/json` body with optional `text` and `additions` members. +`POST /v1/proposals/{proposal_id}/asks/{ask_id}/answer` requires the selected profile's `answer` authority, `If-Match`, `Idempotency-Key` and an `application/json` body with optional `text`, `additions` and `formEntries` members. The ask's wants determine which members are required. Unknown members are refused. A 200 response carries the updated caller-filtered Proposal and ETag. Serving the optional `asks` member on Proposal reads and command responses requires both `Get` and human-only `Answer` authority on that Proposal. @@ -695,6 +695,58 @@ The [Proposal configuration](../../configure/breg-proposals/#accept-supporting-f crates/registry-breg/src/problem.rs; crates/registry-breg/tests/support/proposal_additions.rs. */} +### Additional forms + +Follow `additionalForms..links.add` during an open review. Send +`POST /v1/proposals/{proposal_id}/additional-forms/{form_id}` with the +`If-Match` and `Idempotency-Key` headers and a JSON `input` object keyed +by each field's `apiName`. Use the selected profile's Action metadata to +render the inputs. + +A successful response carries the updated Proposal, its new ETag and +`formEntryId`. The submission version and frozen effect digest stay the +same. The form's `items` member requires `readableForms`. A changed form +contract withholds earlier input values and marks the entry +`contractChanged`. + +An undeclared form gets `404 proposal.form-undeclared`. Invalid inputs get +`400 request.invalid` with the field path. BReg returns `409 proposal.form-limit-reached` +when an entry would exceed the form's `maximumCount` or the submission's shared form byte budget. +BReg derives the byte budget from the 3 MiB retained response ceiling, with space reserved for +the submitted inputs and lifecycle metadata. It counts the encoded entries across all forms +for that submission, including the fields that wrap each entry. A form mapped to several +review-context fields counts once per mapping in the review projection. + +For an ask with a `form` want, cite a matching uncited entry from the current +submission in the answer's `formEntries` array. +An admitted human reviewer can read the cited values with +`include=answers`. + +{/* Evidence: crates/registry-breg/src/api/proposals/forms.rs; + crates/registry-breg/src/mutation/proposal/forms.rs; + crates/registry-breg/tests/support/proposal_review_asks.rs. */} + +### Proposal messages + +Use the promoted links in `messages` on a Proposal or +`context.messages` on a reviewer response. Render every message's +`text` as plain text. Escape it before placing it in HTML. + +- `POST /v1/proposals/{proposal_id}/messages` sends `{"text":"…"}` with + `If-Match` and `Idempotency-Key`. +- `GET /v1/proposals/{proposal_id}/messages` pages newest first. Pass the + previous response's `nextCursor` as `after` to continue. +- `POST /v1/proposals/{proposal_id}/messages/read` sends + `{"through":""}`. This advances the caller's side of the + thread and takes neither command header. + +A reviewer with `get-review-context` can request `include=messages`. +A full thread gets `409 proposal.message-limit-reached`. + +{/* Evidence: crates/registry-breg/src/api/proposals/messages.rs; + crates/registry-breg/src/proposal_messages.rs; + crates/registry-breg/tests/postgres_proposal_messages.rs. */} + ## Immediate actions An Action with `execution.mode: immediate` runs one atomic plan at `POST /v1/actions/{action}` with diff --git a/docs/site/src/content/docs/security/breg.mdx b/docs/site/src/content/docs/security/breg.mdx index c90a74ae76..e9338ff6b3 100644 --- a/docs/site/src/content/docs/security/breg.mdx +++ b/docs/site/src/content/docs/security/breg.mdx @@ -14,7 +14,7 @@ standards_referenced: [] This page states what the Base Registry Engine (BReg) security invariants assume, what you must do for them to hold, and which limits a deployment accepts. The operator obligations are numbered 1 to 22, and each accepted residual risk carries a stable -identifier from `BREG-RES-01` to `BREG-RES-28`. +identifier from `BREG-RES-01` to `BREG-RES-29`. The invariants themselves, each with its threat, enforcement point, refusal, and negative test, are the rows of the machine-checked BReg security invariant matrix in the registry-stack repository. This page does not repeat those rows; it names them by identifier (`BREG-SEC-NN`). @@ -178,6 +178,55 @@ Audit records a keyed pseudonym in its place (`BREG-SEC-272`). crates/registry-breg/tests/support/proposal_review_asks.rs, matching_an_action_input_does_not_make_a_caller_the_proposal_subject. */} +### Proposal messages + +An Action that declares `messages` gives each Proposal one thread between its party and the office. +Only a caller admitted to `message` on that Proposal reads or writes it: a stranger, or a grant +without `message`, is refused on every thread route (`BREG-SEC-275`, `BREG-SEC-282`). +Office staff whose grant does not reach the Proposal get the same concealed answer as for an +unknown one, however the request is shaped, because every thread route checks visibility first +(`BREG-SEC-289`). +The side a message comes from follows the admitting entry, never the request. +A party-bound entry writes as the party and any other grant as the office, and no reader learns +which officer wrote (`BREG-SEC-276`). +Only a verified person acting for themselves reads or writes, whatever the grant says, and a +`message` grant on an agent or service profile is refused at compilation (`BREG-SEC-277`). +An unread office message makes it the party's turn and changes nothing else: the status and every +offered command stay as they were (`BREG-SEC-278`). +The thread needs no review. +It opens at the first Submit and closes for writes when the Proposal is applied, rejected or +cancelled (`BREG-SEC-279`). +A reviewer whose profile grants `message` without `get` can reply while no review context is readable. +The first page of the thread carries its links, and a write at that point returns the thread alone. +Text is served only to a message holder: on the Proposal document, on the thread page, and on the +single review-context read that asks with `include=messages`. +The batch review-context read carries counts, audit records message IDs and sides, and Casework +passes the thread to the reviewer's task context without storing it (`BREG-SEC-280`). +Each write is bounded in size and characters, by the Action's message count for the writer's side, +by the Proposal ETag and by its idempotency receipt (`BREG-SEC-281`). +Each side has its own `maximumCount`, so neither the applicant nor the office can fill the thread +and close it for the other. +Text that does not display as written is refused: control characters other than a line break or +tab, characters that reorder text, zero-width and tag characters. +A client must show message text as text, never as markup. +A write or a mark-read advances the Proposal revision, and a write records its receipt in the same +transaction. +A receipt containing a thread requires the current message grant and the held items must still +match the visible thread. An authorized replay returns the original response and conditions. +That revision never fences automatic application: the worker's Apply is fenced by its claimed lease, +the submission version and the frozen effect digest, so thread activity cannot hand an approved +request back to the party (`BREG-SEC-288`). +The `proposal.messaged` lifecycle event carries the side and never the text. +Erasing a submission clears its message text and sender pseudonyms, and the held responses from +later rounds that could replay that text. + +{/* Evidence: crates/registry-breg/tests/postgres_proposal_messages.rs; + crates/registry-breg/tests/proposal_messages_compiler.rs; + crates/registry-breg/src/mutation/proposal/messages.rs; + crates/registry-breg/src/proposal_retention.rs; + crates/registry-casework-breg/tests/context_provider.rs, + display_passes_the_live_message_thread_through_and_preflight_never_requests_it. */} + ### Caller authentication BReg matches the bearer token to an entry under `authentication.oidc.issuers`. @@ -572,6 +621,34 @@ Each addition occupies a place for the submission's lifetime because this releas crates/registry-breg/tests/support/proposal_additions_authority.rs; products/breg/contracts/security-invariant-matrix.yaml BREG-SEC-225, BREG-SEC-226, BREG-SEC-227, BREG-SEC-228. */} +### Additional forms during Proposal review + +A form write uses the Proposal's current Add authority and needs the form in the selected grant's +`writableForms`; a stranger is concealed (`BREG-SEC-283`). +BReg validates a bounded entry against its declared form contract under the Proposal lock. +An entry joins only an open review of the current submission: after the decision, or once the party +revises, the add route refuses (`BREG-SEC-285`). +Values leave the store through Get with the form in `readableForms` (`BREG-SEC-284`), whatever kind +of caller holds that grant, or through a review-context field that shows the form. +That field is served only to a person reading for themselves: compilation refuses the field on an +agent, service or task-grant profile (`BREG-SEC-287`), and the context projection refuses every other +reader who is not such a person, such as a service on a profile written for any kind +(`BREG-SEC-286`). +A cited entry belongs to the ask's exact submission and can satisfy one answer. +A changed form contract withholds prior values. + +Erasing a submission clears its form input and actor pseudonyms, citation +references, and held Proposal responses that could replay the entries. +Audit and lifecycle events carry identifiers and transition information. + +{/* Evidence: crates/registry-breg/src/mutation/proposal/forms.rs; + crates/registry-breg/src/mutation/proposal/asks.rs; + crates/registry-breg/src/mutation/proposal/context_projection.rs; + crates/registry-breg/tests/support/proposal_additions.rs; + crates/registry-breg/tests/proposal_additional_forms.rs; + crates/registry-breg/tests/support/proposal_review_asks.rs, + a_form_want_discloses_only_the_cited_entry_in_live_review_context. */} + ### One-call writes An immediate Action that patches an existing Record normally asks the caller for a condition: @@ -1597,6 +1674,20 @@ Each lists the condition, the consequence, the mitigation, and the related matri {/* Evidence: crates/registry-breg/tests/postgres_proposal_subject.rs, submit_names_someone_else_only_under_submits_for_anyone. */} +### `BREG-RES-29`: office staff outside the Casework team can write to the thread + +- Condition: a person holds a profile with `message` on a Proposal Action but is not on the Casework + team that holds the review task. +- Consequence: BReg does not know who holds a task, so that person can write to the applicant + through BReg directly. + They can already read the review context, the answers and the thread the same way. +- Mitigation: grant `message` only on reviewer profiles that the review team's staffing matches, and + review the audited writes. +- Related: `BREG-SEC-275`, `BREG-SEC-276`. + +{/* Evidence: crates/registry-breg/tests/postgres_proposal_messages.rs, + the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found. */} + ## Report a vulnerability Report a suspected vulnerability through the process in diff --git a/docs/site/src/content/docs/security/casework.mdx b/docs/site/src/content/docs/security/casework.mdx index f701594265..5ca0299656 100644 --- a/docs/site/src/content/docs/security/casework.mdx +++ b/docs/site/src/content/docs/security/casework.mdx @@ -70,6 +70,17 @@ grants in [Registry Casework task grants](../../reference/casework-task-grants/) delegated_institutional_reads_carry_neither_asks_nor_markers; crates/registry-casework-breg/tests/context_provider.rs, preflight_omits_answers_and_only_display_opts_in_under_the_same_human_bearer. */} +- Form asks: Casework confirms the form ID through the reviewer's current + source authorization before it stores an ask. It stores the form name + in the want. The reviewer's task context reads cited form values live. + {/* Evidence: crates/registry-casework/src/review/asks.rs, ask_applicant; + crates/registry-casework/tests/support/ask_form_http.rs, + an_unknown_source_form_is_refused_without_recording_an_ask. */} +- Proposal messages: the BReg provider requests the live thread for the + reviewer's task display. Claim, ask and decision preflight omit the + thread. Casework stores no message text. + {/* Evidence: crates/registry-casework-breg/tests/context_provider.rs; + crates/registry-casework/src/review.rs. */} - Private reason versus public reason: every decision names an outcome declared by the pinned policy and offered at the current stage. The reviewer's private reason stays in the accountability record. diff --git a/docs/site/src/data/breg-api.yaml b/docs/site/src/data/breg-api.yaml index ea41c80c01..a422a8b87f 100644 --- a/docs/site/src/data/breg-api.yaml +++ b/docs/site/src/data/breg-api.yaml @@ -91,6 +91,8 @@ - ['`attachment.digest-mismatch`', '422', 'An immediate Action carried a file whose bytes do not hash to the `sha256` the request declared. No effects commit.'] - ['`attachment.slot-write-once`', '409', 'A record attachment slot already holds a file. Record slots are write-once, so the second write is refused and the stored file is unchanged. This covers an immediate Action file and a Proposal file that Apply promotes. No effects commit.'] - ['`attachment.limit-reached`', '409', 'The current submission already holds the additions slot''s `maximumCount` files. BReg accepts no further addition in that submission.'] + - ['`proposal.form-limit-reached`', '409', 'The current submission has reached the entry limit for this form.'] + - ['`proposal.form-undeclared`', '404', 'The visible Proposal Action does not declare this form.'] - ['`attachment.required`', '422', 'Submit found an empty required attachment slot, including a required file rejected by verification. The problem''s `fieldPath` names only `/attachments/`. Upload an accepted file before submitting.'] - ['`attachment.verification-pending`', '409', 'Submit found a file awaiting verification. Refresh the Proposal before submitting. The problem''s `fieldPath` names only `/attachments/`.'] - ['`attachment.verification-rejected`', '422', 'Submit found a rejected file in an optional slot. Replace or remove the file before submitting. The problem''s `fieldPath` names only `/attachments/`.'] @@ -101,6 +103,7 @@ - ['`proposal.review-result-mismatch`', '412', 'The current Review result differs from the retained approval. Apply commits no effects. Reconcile the review result before attempting application again.'] - ['`proposal.subject-not-caller`', '403', 'Submit names someone other than the submitter as the person the Proposal is about, and the submitting grant does not say `submitsFor: anyone`. The draft stays unbound.'] - ['`proposal.subject-changed`', '409', 'A later Submit read a different subject from the Record the Action names than the one bound at the first Submit. Cancel the Proposal and file a new one.'] + - ['`proposal.message-limit-reached`', '409', 'The Proposal''s message thread holds as many messages as its Action allows (`execution.proposal.messages.maximumCount`). The message is not written; the thread stays readable.'] - ['`proposal.submission-expired`', '410', 'The submission''s review result window has lapsed or its detail was erased, and it has no application receipt. The Proposal itself stays readable.'] - ['`mutation.conflict`', '409', 'A constraint or workflow rule refused the write. A storage-pattern failure includes the declared `recordType` and `fieldId`; correct the input before retrying. A 409 does not imply that retrying an unchanged request can succeed.'] - ['`idempotency.key-reused`', '409', 'The caller reused the `Idempotency-Key` with a different request, another write included, or retried a key whose held response a retention erase removed. A byte-identical body also conflicts when the first attempt committed under a different package activation, access profile, or claims.'] diff --git a/docs/site/src/data/breg-events.yaml b/docs/site/src/data/breg-events.yaml index 21e4867fe0..bd9e7a47a0 100644 --- a/docs/site/src/data/breg-events.yaml +++ b/docs/site/src/data/breg-events.yaml @@ -44,7 +44,8 @@ rows: - ['`actionId`, `actionRevision`', 'String and digest', 'Exact governed Action binding.'] - ['`proposalId`, `submissionVersion`, `revision`', 'UUID and positive integers', 'Exact durable work and transition revision.'] - - ['`fromState`, `state`, `transition`', 'Closed strings', 'Native lifecycle transition and its states. `transition` is `started`, `edited`, `submitted`, `revised`, `rebased`, `retried`, `cancelled`, `applied`, `rejected` or `review-returned`; `rejected` ends the Proposal in the terminal `rejected` state.'] + - ['`fromState`, `state`, `transition`', 'Closed strings', 'Native lifecycle transition and its states. `transition` is `started`, `edited`, `submitted`, `revised`, `rebased`, `retried`, `cancelled`, `applied`, `rejected`, `review-returned` or `messaged`; `rejected` ends the Proposal in the terminal `rejected` state.'] + - ['`messageFrom`', '`party` or `official`', 'On `messaged` only: the side the message was written from. The event never carries the text.'] - ['`effectDigest`', 'Digest or null', 'Frozen plan identity when available.'] - ['`authorityKind`', '`caller`, `system` or `review`', 'Authority used for the transition; `review` for a transition a recorded review result caused.'] - ['`systemApplyGrantRevision`', 'Digest or null', 'Restricted system grant binding for automatic application.'] diff --git a/docs/site/src/data/casework-api.yaml b/docs/site/src/data/casework-api.yaml index 745cd1af84..1cb8c33c00 100644 --- a/docs/site/src/data/casework-api.yaml +++ b/docs/site/src/data/casework-api.yaml @@ -27,6 +27,7 @@ - ['`request.unsupported-media-type`', '415', 'Send a JSON request body with Content-Type application/json.'] - ['`review.ask-already-open`', '409', 'Wait for the open ask on this request to be answered or closed before asking again.'] - ['`review.ask-answer-time-invalid`', '422', 'Report the time the applicant''s answer was committed: not before the ask was made and no more than five minutes ahead of Casework''s clock.'] + - ['`review.ask-form-unknown`', '422', 'The review source does not declare the requested form.'] - ['`review.ask-limit-reached`', '409', 'This review request has reached its limit of 50 asks. Continue the review without opening another ask.'] - ['`review.ask-not-offered`', '409', 'The active stage of this review policy does not let a reviewer ask the applicant.'] - ['`review.ask-not-open`', '409', 'This ask was already answered or closed, or the applicant answered after its due date.'] diff --git a/products/breg/CHANGELOG.md b/products/breg/CHANGELOG.md index a032db6ec6..4f368f2951 100644 --- a/products/breg/CHANGELOG.md +++ b/products/breg/CHANGELOG.md @@ -64,8 +64,11 @@ per source file. A sealed source file that mixes the historical and current spellings, or declares both for one key, is refused as `breg.package.integrity-refused`, because no release writes one. + +- An Action can declare named additional forms with `execution.proposal.additionalForms.` (at most 8 forms of 1 to 16 typed inputs, `maximumCount` 1 to 32 entries per submission, default 8). While review is open, a caller whose grant holds `add` and lists the form in `writableForms` adds an entry with `POST /v1/proposals/{proposal_id}/additional-forms/{form_id}`; the submission version and effect digest stay the same. Get with the form in `readableForms` serves its entries. A review-context field of type `additional-form` shows them to a person reviewing for themselves: compilation refuses the field on an agent, service or task-grant profile (`breg.additional-form.context-reader-invalid`), and any other reader who is not a person reading for themselves is refused. A Casework ask can name a form, and the applicant cites its entry in the answer's `formEntries`. New problem codes `404 proposal.form-undeclared` and `409 proposal.form-limit-reached`. Proposal detail erasure covers the entry, citation and held response. +- Proposal message writes emit `proposal.messaged` with `messageFrom` set to `party` or `official`. Hooks without a `transitions` filter also receive this event. Message text stays out of the event, and marking the thread read emits no event. - BREAKING: A Proposal grant names the party it is bound to with `party: owner`, which replaces `ownership: caller`. `bregctl check` refuses the old key with `config.removed-key` and names the replacement. Packages built by an earlier release still load as predecessors with the same meaning. Migration: replace `ownership: caller` with `party: owner` in every `permissions.proposals` entry, then build a successor package. -- A Proposal's subject, the person it is about, follows it when someone else filed it. An Action names the subject's input with `execution.proposal.subject: {input}`, or `{input, field}` to read it from the referenced Record. BReg binds it at the first Submit and refuses a later change (`400 request.invalid`, or `409 proposal.subject-changed` for the field form). A `party: subject` grant admits a verified person whose principal equals the bound value, with `get`, `list`, `get-review-status`, `answer`, `add` and `cancel` only. Submit refuses a subject other than the submitter with `403 proposal.subject-not-caller` unless the grant says `submitsFor: anyone`. The Proposal document carries `partyRole`, List returns both parties' Proposals, and audit records a keyed subject pseudonym on the binding Submit and `partyRole` on later requests. New diagnostics: `breg.proposal.subject-undeclared`, `breg.proposal.subject-input-unknown`, `breg.proposal.subject-input-type`, `breg.proposal.subject-input-optional`, `breg.proposal.subject-field-type`, `breg.proposal.subject-operation-forbidden`, `breg.proposal.submits-for-invalid` and `breg.access.open-subject-principal-not-sub`. Proposals submitted before their Action declared a subject have none until they are rebased and submitted again. +- A Proposal's subject, the person it is about, follows it when someone else filed it. An Action names the subject's input with `execution.proposal.subject: {input}`, or `{input, field}` to read it from the referenced Record. BReg binds it at the first Submit and refuses a later change (`400 request.invalid`, or `409 proposal.subject-changed` for the field form). A `party: subject` grant admits a verified person whose principal equals the bound value, with `get`, `list`, `get-review-status`, `answer`, `add`, `message` and `cancel` only. Submit refuses a subject other than the submitter with `403 proposal.subject-not-caller` unless the grant says `submitsFor: anyone`. The Proposal document carries `partyRole`, List returns both parties' Proposals, and audit records a keyed subject pseudonym on the binding Submit and `partyRole` on later requests. New diagnostics: `breg.proposal.subject-undeclared`, `breg.proposal.subject-input-unknown`, `breg.proposal.subject-input-type`, `breg.proposal.subject-input-optional`, `breg.proposal.subject-field-type`, `breg.proposal.subject-operation-forbidden`, `breg.proposal.submits-for-invalid` and `breg.access.open-subject-principal-not-sub`. Proposals submitted before their Action declared a subject have none until they are rebased and submitted again. - A Record field a Proposal subject is read from is authority. A direct write grant, an immediate Action grant, or a grant for a Proposal Action applied automatically without required review, whose row boundaries let the writer name anyone in that field, is refused with `breg.proposal.subject-field-write`. Unrestricted grants, grants bounded on the field by their own principal claim, and reviewed or manually applied Proposal Actions stay admitted. Erasing a Proposal's detail also erases its stored subject. - BREAKING: the Proposal state store keeps the bound subject's reference in its own column with a partial index, and the managed schema fingerprint changes with them. Migration: build and apply a successor package with this release. Its activation adds the column and index in place and keeps every Proposal, each with no subject until it is submitted again. - `GET /v1/metadata` serves one `proposals.actions` entry for each Proposal grant, with its `party` when the grant is bound to one, and `writableInputs`: the grant's list, every declared input when the grant names none, and an empty list when the grant writes nothing. A Proposal Action's description names `subject: {input}` and the selected profile's `writableInputs`. The Rust, Node and Python clients expose `party`, `writableInputs`, `subjectInput` and the Proposal's `partyRole`. @@ -84,7 +87,13 @@ - Add the organisation stewardship example: stewards manage an organisation's members through two Actions, bounded by a stewardship record that a registrar names and ends through jurisdiction-scoped Actions, which also register facilities and rename organisations. - BREAKING: A grant bounded on a membership source's own rows, by claims or by a membership entry on a field other than the key, can no longer set that source's key or principal, and on an existing row can only set `active` to `false`. This covers Create, Batch, Import, Patch, and Action, Proposal and function-plan writes, refused with `breg.access.membership-source-key-write`. Unrestricted grants and grants bounded on the key are unaffected. Migration: set the key through an Action whose reference input targets the key's Record type under a target grant you scope, as the organisation stewardship example's `name-steward` does, or make the administrator's grant unrestricted. - `tests/journeys.yaml` steps invoke a `concurrency: current-revision` Action without `preconditions`, as its HTTP contract requires. +- A `tests/journeys.yaml` Proposal `get` step may wait for automatic application with `waitSeconds`, from 1 to 60: `bregctl test` runs the built-in application executor and reads the Proposal again until the response matches the step's expectation, and fails the step with `fixture.proposal.wait-timed-out` when the time runs out. Steps without `waitSeconds` never run the executor. A Proposal `get` or `apply` step may also map an effect to a record capture with `captureResults`, taken from the application's result links, when that effect is the Action's only one on its Record type. The `minimal-directory` starter journey waits for its contact registration and reads the contact back. - Observed membership refusals count under `membership` in `breg_request_refusals_total{check}` and in the refusal log. Generic precondition responses retain their existing body in both postures. +- A Proposal can carry one message thread between its party (the owner or the subject) and the office. An Action opens it with `execution.proposal.messages: {maximumCount}` (1 through 1000, default 200, counted for each side), with or without review, and without changing the Action revision, so Proposals in flight get the thread at activation. A grant's `message` operation reads and writes it; a message written under a party-bound entry is `from: party`, under any other grant `from: official`. Only a verified person acting for themselves reads or writes. Routes: `POST /v1/proposals/{proposal_id}/messages` (`If-Match`, `Idempotency-Key`, at most 2,000 UTF-8 bytes of text that displays as written: no control character but a line break or tab, a carriage return only before a line feed, and no reordering, zero-width or tag character), `GET /v1/proposals/{proposal_id}/messages` (newest first, `after` and `limit`, with the thread's links) and `POST /v1/proposals/{proposal_id}/messages/read`. The thread opens at the first Submit and closes for writes when the Proposal is applied, rejected or cancelled. The Proposal document and `GET /v1/proposals/{proposal_id}/review-context?include=messages` carry a `messages` member; list items and the batch review-context read carry its counts only. New problem code `409 proposal.message-limit-reached`, new diagnostics `breg.proposal.message-grant-invalid` and `breg.proposal.message-count-invalid`. +- `tests/journeys.yaml` Proposal steps gain `transition: message`, which writes `text` to the thread under the step's captured condition and an idempotency key, and `transition: read-messages`, which marks the thread read through the newest message the captured document shows. Proposal steps may also expect `status` and `turn`. +- A message write and a mark-read each advance the Proposal revision and ETag, so a client holding an older `If-Match` refetches before its next command. A reviewer whose profile holds the thread but not Get is answered with the thread alone while no review context is readable, between review rounds or after the Action changed. Thread activity never fences automatic application. +- An office message the party has not read makes it the party's turn, so `GET /v1/proposals?turn=party` lists the Proposal, while its `status` and every offered command stay as they were. `bregctl explain lifecycle` lists the new turn condition and advances to `v1alpha10`. +- BREAKING: the Proposal store gains the form entry and ask citation tables, a message table and one read position for each side on the Proposal state row, and the managed schema fingerprint changes with them. Migration: build and apply a successor package with this release; its activation adds them in place. ## 0.49.0 - 2026-12-01 diff --git a/products/breg/contracts/explain/EventsExplanation.schema.json b/products/breg/contracts/explain/EventsExplanation.schema.json index 7519346892..57837d4f67 100644 --- a/products/breg/contracts/explain/EventsExplanation.schema.json +++ b/products/breg/contracts/explain/EventsExplanation.schema.json @@ -61,7 +61,8 @@ "review-returned", "added", "asked", - "answered" + "answered", + "messaged" ] } } diff --git a/products/breg/contracts/explain/LifecycleExplanation.schema.json b/products/breg/contracts/explain/LifecycleExplanation.schema.json index 011fe15223..c757f89e09 100644 --- a/products/breg/contracts/explain/LifecycleExplanation.schema.json +++ b/products/breg/contracts/explain/LifecycleExplanation.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha9.schema.json", + "$id": "https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha10.schema.json", "title": "LifecycleExplanation", "description": "The native engine-owned Proposal lifecycle, pinned independently of project source.", "type": "object", @@ -12,7 +12,7 @@ ], "properties": { "apiVersion": { - "const": "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9" + "const": "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10" }, "kind": { "const": "BRegLifecycleExplanation" @@ -152,16 +152,20 @@ ], "terminal": false, "turns": [ + { + "condition": "An office message on the thread is unread by the party. This changes the turn only, never the status.", + "turn": "party" + }, { "condition": "The submission package is blocked; Review is pending or retrying with an open ask; Review ended without a usable approval; or, after approval or when Review is not required, application is not manual and is blocked without recovery retry.", "turn": "party" }, { - "condition": "The submission package is not blocked, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry.", + "condition": "The submission package is not blocked, no office message is unread by the party, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry.", "turn": "official" }, { - "condition": "The submission package is not blocked, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status.", + "condition": "The submission package is not blocked, no office message is unread by the party, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status.", "turn": "nobody" } ], diff --git a/products/breg/contracts/security-invariant-matrix.yaml b/products/breg/contracts/security-invariant-matrix.yaml index 152baee042..df58c8a076 100644 --- a/products/breg/contracts/security-invariant-matrix.yaml +++ b/products/breg/contracts/security-invariant-matrix.yaml @@ -291,3 +291,18 @@ invariants: - {"id": "BREG-SEC-272", "state": "enforced", "targetWave": "W5", "threat": "Audit records the subject's identifier or its internal reference.", "enforcementPoint": "The binding Submit records only a keyed, database-scoped subject pseudonym; later requests record partyRole.", "refusal": "Never write the identifier or the unkeyed reference to audit.", "negativeId": "BREG-NEG-272", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "audit_names_the_subject_by_pseudonym_and_each_later_request_by_party"}} - {"id": "BREG-SEC-273", "state": "enforced", "targetWave": "W5", "threat": "A writer whose row boundaries let them name anyone sets the Record field a Proposal subject is read from, and so chooses who follows Proposals about that Record.", "enforcementPoint": "Project compilation of direct Record write grants, and of Action grants whose plan sets a field any `subject.field` names with no person deciding: an immediate Action, or a Proposal Action without required review that is applied automatically.", "refusal": "Refuse with breg.proposal.subject-field-write unless the grant is unrestricted or bounded on that field by its own principal claim.", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} - {"id": "BREG-SEC-274", "state": "enforced", "targetWave": "W5", "threat": "A party downloads an attachment its governing entry does not read, through another entry of the same profile.", "enforcementPoint": "The attachment route selects the entry that admitted the caller, party included, and the download transaction rechecks that entry's readable slots.", "refusal": "Conceal with 404 resource.not-found.", "negativeId": "BREG-NEG-274", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "attachment_downloads_follow_the_entry_that_admitted_the_caller"}} + - {"id": "BREG-SEC-275", "state": "enforced", "targetWave": "W5", "threat": "A caller who is neither the Proposal's party nor admitted office staff reads, writes or marks read its message thread, or reads its content.", "enforcementPoint": "Every thread route admits the caller through the Proposal grant that holds message and the party matching of the Proposal; the transaction checks the governing party again.", "refusal": "Conceal write, list and mark-read with 404 resource.not-found; a grant without message is refused by name and its document carries no messages member.", "negativeId": "BREG-NEG-275", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found"}} + - {"id": "BREG-SEC-276", "state": "enforced", "targetWave": "W5", "threat": "A writer chooses the side a message comes from, so a party passes as the office or staff as the applicant, or a reader learns which officer wrote.", "enforcementPoint": "The side is taken from the admitting entry: a party-bound entry writes from: party with its partyRole, any other grant from: official. Items carry mine and never a sender name or pseudonym.", "refusal": "The request carries no side; served items name only from, partyRole, mine, sentAt and text.", "negativeId": "BREG-NEG-276", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-277", "state": "enforced", "targetWave": "W5", "threat": "An agent or a service with a message grant reads, writes or marks read text one person wrote to another.", "enforcementPoint": "Project compilation refuses message on an agent or service profile; on a profile written for any kind, message takes the admission's human test for writes, mark-read, pages and the review-context include.", "refusal": "Refuse compilation with breg.proposal.message-grant-invalid; refuse write, mark-read and list with 403 profile.not-authorized and serve no messages member.", "negativeId": "BREG-NEG-277", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "only_a_person_acting_for_themselves_reads_or_writes_the_thread"}} + - {"id": "BREG-SEC-278", "state": "enforced", "targetWave": "W5", "threat": "An unread message opens or closes a command, or changes the status a party or reviewer acts on.", "enforcementPoint": "The lifecycle rule derives the status from whose move it is without the unread-message condition; the unread office message changes only the served turn.", "refusal": "Serve turn: party while the status and every link's availability stay as they were.", "negativeId": "BREG-NEG-278", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-279", "state": "enforced", "targetWave": "W5", "threat": "A thread is writable before the request is first submitted, or after it ends.", "enforcementPoint": "A write checks inside the Proposal transaction that the thread has opened at a Submit and that the Proposal is draft or submitted.", "refusal": "Refuse a write before the first Submit or on a cancelled Proposal with 412 precondition.failed and on a rejected one with 409 proposal.rejected; the thread stays readable.", "negativeId": "BREG-NEG-279", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_is_closed_before_the_first_submit_and_after_cancel_or_rejection"}} + - {"id": "BREG-SEC-280", "state": "enforced", "targetWave": "W5", "threat": "Message text reaches a reader who did not ask for it, the inbox batch or the audit journal.", "enforcementPoint": "Text is served only by the Proposal document of a message holder, the thread page and the single review-context read with include=messages. The batch read serves counts; audit records message IDs and sides.", "refusal": "Omit context.messages without include=messages, serve counts only in the batch read, and write no text to audit.", "negativeId": "BREG-NEG-280", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-281", "state": "enforced", "targetWave": "W5", "threat": "A writer floods the thread, smuggles control or reordering characters, or overwrites the other side's message through a stale view.", "enforcementPoint": "The write route bounds text to 2,000 UTF-8 bytes of characters that display, with no control, reordering, zero-width or tag character and a carriage return only before a line feed; the store refuses a side past the Action's maximumCount, so neither side can close the thread for the other; the Proposal ETag and idempotency receipt fence each write. A receipt that includes the thread binds its original side and requires current Message authority for that side.", "refusal": "Refuse bad text with 400 request.invalid at /text, a full thread with 409 proposal.message-limit-reached and a stale If-Match with 412 precondition.failed; return the stored response after current disclosure checks or refuse replay when the original thread side cannot be established or admitted.", "negativeId": "BREG-NEG-281", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_refuses_stale_writes_replays_keys_checks_text_and_stops_at_its_limit"}} + - {"id": "BREG-SEC-282", "state": "enforced", "targetWave": "W5", "threat": "A thread route reaches the Proposals of an Action that declares no thread.", "enforcementPoint": "Route admission resolves the Proposal's Action and refuses one without execution.proposal.messages before any grant is chosen.", "refusal": "Conceal every thread route with 404 resource.not-found and serve no messages member.", "negativeId": "BREG-NEG-282", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "an_action_without_messages_serves_no_thread"}} + - {"id": "BREG-SEC-283", "state": "enforced", "targetWave": "W5", "threat": "A profile without writableForms for a form, or a caller who is not the Proposal's party, adds an entry to it.", "enforcementPoint": "The add route checks the selected grant's writableForms after the Proposal is visible to the caller, and the Proposal transaction checks it again under the Proposal lock.", "refusal": "Refuse a form the grant does not write with 403 profile.not-authorized and conceal the Proposal from a stranger with 404 resource.not-found; store no entry.", "negativeId": "BREG-NEG-283", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_need_their_own_write_and_read_grants"}} + - {"id": "BREG-SEC-284", "state": "enforced", "targetWave": "W5", "threat": "A Get holder without readableForms for a form receives its entries' values.", "enforcementPoint": "The Proposal document serves a form's items only when the selected grant holds Get and lists the form in readableForms.", "refusal": "Serve the form's description and add link without items.", "negativeId": "BREG-NEG-284", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_need_their_own_write_and_read_grants"}} + - {"id": "BREG-SEC-285", "state": "enforced", "targetWave": "W5", "threat": "An entry joins a review that is already decided, or a submission the party has revised, so it reaches no reviewer or a different round.", "enforcementPoint": "The add branch of the Proposal transaction requires a submitted Proposal whose current review is pending or retrying, as for supporting files.", "refusal": "Refuse with 412 precondition.failed and store no entry.", "negativeId": "BREG-NEG-285", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_refuse_a_decided_review_and_a_revised_submission"}} + - {"id": "BREG-SEC-286", "state": "enforced", "targetWave": "W5", "threat": "A reader who is not a person acting for themselves receives form values through a review-context field that shows an additional form.", "enforcementPoint": "The context projection serves an additional-form field only to a review-context read whose caller passes the human test: a verified person acting for no one else, under no task grant. Compilation also keeps the field off agent, service and task-grant profiles (BREG-SEC-287).", "refusal": "Refuse the review-context read and serve no form value.", "negativeId": "BREG-NEG-286", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_review_asks.rs", "name": "a_form_context_field_serves_the_human_reviewer_and_refuses_a_non_person_reader"}} + - {"id": "BREG-SEC-287", "state": "enforced", "targetWave": "W5", "threat": "An agent, service or task-grant profile is given a review-context field that shows an additional form.", "enforcementPoint": "Project compilation refuses readableContextFields that include an additional-form field on a profile with actorKind agent or service or with a taskGrant.", "refusal": "Refuse compilation with breg.additional-form.context-reader-invalid.", "negativeId": "BREG-NEG-287", "negativeTest": {"path": "crates/registry-breg/tests/proposal_additional_forms.rs", "name": "an_additional_form_context_field_is_refused_to_profiles_no_person_reads_through"}} + - {"id": "BREG-SEC-288", "state": "enforced", "targetWave": "W5", "threat": "A message or mark-read by the party or the office, landing while the automatic worker applies an approved request, makes the Apply fail and hands the request back to the party.", "enforcementPoint": "The worker's Apply is fenced by its claimed lease, the submission version and the frozen effect digest inside the Apply transaction, not by a Proposal ETag read in an earlier one.", "refusal": "Apply the request; thread activity changes the revision but never what is applied.", "negativeId": "BREG-NEG-288", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "thread_activity_during_automatic_application_does_not_strand_the_request"}} + - {"id": "BREG-SEC-289", "state": "enforced", "targetWave": "W5", "threat": "Office staff whose grant does not reach a Proposal confirm that it exists from how a thread route answers a malformed request.", "enforcementPoint": "Every thread route checks that the Proposal is visible to the admitted caller, under row boundaries and memberships, before it reads any header, query or body.", "refusal": "Conceal a hidden Proposal with 404 resource.not-found exactly as an unknown one.", "negativeId": "BREG-NEG-289", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_unknown_one"}} diff --git a/products/breg/contracts/security-test-traceability.yaml b/products/breg/contracts/security-test-traceability.yaml index a079d77ecd..690ccc0a7c 100644 --- a/products/breg/contracts/security-test-traceability.yaml +++ b/products/breg/contracts/security-test-traceability.yaml @@ -333,3 +333,19 @@ traceability: - {"id": "BREG-SEC-272", "state": "enforced", "negativeId": "BREG-NEG-272", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "audit_names_the_subject_by_pseudonym_and_each_later_request_by_party"}} - {"id": "BREG-SEC-273", "state": "enforced", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} - {"id": "BREG-SEC-274", "state": "enforced", "negativeId": "BREG-NEG-274", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "attachment_downloads_follow_the_entry_that_admitted_the_caller"}} + - {"id": "BREG-SEC-275", "state": "enforced", "negativeId": "BREG-NEG-275", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found"}} + - {"id": "BREG-SEC-276", "state": "enforced", "negativeId": "BREG-NEG-276", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-277", "state": "enforced", "negativeId": "BREG-NEG-277", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "only_a_person_acting_for_themselves_reads_or_writes_the_thread"}} + - {"id": "BREG-SEC-278", "state": "enforced", "negativeId": "BREG-NEG-278", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-279", "state": "enforced", "negativeId": "BREG-NEG-279", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_is_closed_before_the_first_submit_and_after_cancel_or_rejection"}} + - {"id": "BREG-SEC-280", "state": "enforced", "negativeId": "BREG-NEG-280", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-281", "state": "enforced", "negativeId": "BREG-NEG-281", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_refuses_stale_writes_replays_keys_checks_text_and_stops_at_its_limit"}} + # Receipt-side binding and refusal: crates/registry-breg/src/idempotency.rs::proposal_receipt_binding_preserves_the_request_and_recovers_the_original_side and crates/registry-breg/src/mutation/proposal/messages.rs::message_replay_requires_proof_of_the_original_thread_side. + - {"id": "BREG-SEC-282", "state": "enforced", "negativeId": "BREG-NEG-282", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "an_action_without_messages_serves_no_thread"}} + - {"id": "BREG-SEC-283", "state": "enforced", "negativeId": "BREG-NEG-283", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_need_their_own_write_and_read_grants"}} + - {"id": "BREG-SEC-284", "state": "enforced", "negativeId": "BREG-NEG-284", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_need_their_own_write_and_read_grants"}} + - {"id": "BREG-SEC-285", "state": "enforced", "negativeId": "BREG-NEG-285", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_refuse_a_decided_review_and_a_revised_submission"}} + - {"id": "BREG-SEC-286", "state": "enforced", "negativeId": "BREG-NEG-286", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_review_asks.rs", "name": "a_form_context_field_serves_the_human_reviewer_and_refuses_a_non_person_reader"}} + - {"id": "BREG-SEC-287", "state": "enforced", "negativeId": "BREG-NEG-287", "negativeTest": {"path": "crates/registry-breg/tests/proposal_additional_forms.rs", "name": "an_additional_form_context_field_is_refused_to_profiles_no_person_reads_through"}} + - {"id": "BREG-SEC-288", "state": "enforced", "negativeId": "BREG-NEG-288", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "thread_activity_during_automatic_application_does_not_strand_the_request"}} + - {"id": "BREG-SEC-289", "state": "enforced", "negativeId": "BREG-NEG-289", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_unknown_one"}} diff --git a/products/breg/examples/minimal/tests/journeys.yaml b/products/breg/examples/minimal/tests/journeys.yaml index 19c28748ce..85a8828bdd 100644 --- a/products/breg/examples/minimal/tests/journeys.yaml +++ b/products/breg/examples/minimal/tests/journeys.yaml @@ -120,3 +120,32 @@ journeys: directClaims: {jurisdiction: zone-a} request: {type: proposal, transition: submit, proposalCapture: registration-draft, idempotencyKey: submit-registration} expect: {outcome: success, status: 200, fields: {state: submitted}} + - id: await-registration + actor: editor + action: register-contact + accessProfile: directory-editor + claims: + principal: synthetic-directory-editor + scopes: [registry:directory:write] + purpose: directory-administration + directClaims: {jurisdiction: zone-a} + request: {type: proposal, transition: get, proposalCapture: registration-draft, waitSeconds: 10} + expect: + outcome: success + status: 200 + fields: {state: applied, applicationStatus: {mode: automatic, state: applied}} + captureResults: {contact: registered-contact} + - id: read-registered-contact + actor: editor + recordType: contact + accessProfile: directory-editor + claims: + principal: synthetic-directory-editor + scopes: [registry:directory:write] + purpose: directory-administration + directClaims: {jurisdiction: zone-a} + request: {type: get, recordCapture: registered-contact} + expect: + outcome: success + status: 200 + fields: {name: Registered contact, email: registered@example.test, jurisdiction: zone-a} diff --git a/products/breg/scripts/test-postgres.sh b/products/breg/scripts/test-postgres.sh index 3e62cc3bcc..e8cd062cce 100755 --- a/products/breg/scripts/test-postgres.sh +++ b/products/breg/scripts/test-postgres.sh @@ -117,6 +117,7 @@ postgres_targets=( postgres_proposal_human_recovery postgres_reviewed_change_example postgres_proposal_hooks + postgres_proposal_messages postgres_proposal_review_delivery postgres_proposal_guard_failure postgres_proposal_security diff --git a/products/breg/scripts/test_validate_product.py b/products/breg/scripts/test_validate_product.py index 15b9b16689..9b3bbd11be 100644 --- a/products/breg/scripts/test_validate_product.py +++ b/products/breg/scripts/test_validate_product.py @@ -74,7 +74,7 @@ def test_security_range_and_negative_ids_are_closed(self) -> None: ) extension_rows = matrix["invariants"][24:] self.assertEqual( - [f"BREG-NEG-{index:02d}" for index in range(25, 275) if index not in {61, 62}], + [f"BREG-NEG-{index:02d}" for index in range(25, 290) if index not in {61, 62}], [invariant["negativeId"] for invariant in extension_rows], ) for invariant in extension_rows: diff --git a/products/breg/scripts/validate_product.py b/products/breg/scripts/validate_product.py index 78cc3b1525..8b8a0336d9 100644 --- a/products/breg/scripts/validate_product.py +++ b/products/breg/scripts/validate_product.py @@ -31,7 +31,7 @@ CONTRACT_STATES = {"enforced", "partial", "planned"} V1_REQUIREMENT_IDS = tuple(f"BREG-V1-{index:02d}" for index in range(1, 45)) ACCEPTANCE_JOURNEY_IDS = tuple(f"BREG-J{index:02d}" for index in range(1, 25)) -SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 275) if index not in {61, 62}) +SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 290) if index not in {61, 62}) ACCEPTANCE_FIXTURES = { "BREG-J01": ("asset-site-placement", "acceptance/asset-site-placement"), "BREG-J02": ("asset-site-placement", "acceptance/asset-site-placement"), @@ -168,6 +168,7 @@ "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_human_recovery", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_reviewed_change_example", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_hooks", + "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_messages", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_review_delivery", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_guard_failure", "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_proposal_security", diff --git a/products/casework/CHANGELOG.md b/products/casework/CHANGELOG.md index 6c383e7efb..3e5be4d073 100644 --- a/products/casework/CHANGELOG.md +++ b/products/casework/CHANGELOG.md @@ -14,6 +14,9 @@ revision route, replace `id` and `revision` with `holidayId` and `holidayRevision`. Operation names and concrete HTTP URLs stay the same. +- A review ask can want a form: `{"kind":"form","form":""}` asks the applicant for an entry of a form the source declares. Casework confirms the form through the reviewer's own current source authorization before it stores the ask and refuses an undeclared one with `422 review.ask-form-unknown`. The task context lists the forms the source declares under `additionalForms`, so a reviewer can name one. An answer's form entries are read live into the task context and are never stored by Casework. +- The displayed task context carries the source's message thread under `messages`, read live with the reviewer's own token and passed through unchanged, links included. Claim, ask and decision preflight never request it, and Casework stores no message text. + ## 0.49.0 - 2026-12-01 - The generated TypeScript client classifies declared, traced empty 404 and 410 responses as `RegistryError` refusals with an HTTP status. This covers Review Ask reads and answers, Decision Draft reads and Review Result reads. Handle these errors by inspecting `kind` and `status` when `problem` is absent. diff --git a/products/identifiers/contracts/catalog-source.json b/products/identifiers/contracts/catalog-source.json index e09acce1f6..5d0686ef23 100644 --- a/products/identifiers/contracts/catalog-source.json +++ b/products/identifiers/contracts/catalog-source.json @@ -559,7 +559,7 @@ "glob": "products/breg/contracts/explain/LifecycleExplanation.schema.json", "owner": "breg", "status": "active", - "compatibilityLine": "v1alpha9", + "compatibilityLine": "v1alpha10", "description": "Base Registry Engine bregctl explain output JSON Schemas, written by hand and held to bregctl's output by its contract test." }, { diff --git a/products/platform/config-formats.yaml b/products/platform/config-formats.yaml index 0e7e80e36f..94ad66e048 100644 --- a/products/platform/config-formats.yaml +++ b/products/platform/config-formats.yaml @@ -1344,17 +1344,17 @@ formats: audience: generated stability: unpromised current: - apiVersion: id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9 + apiVersion: id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10 kind: BRegLifecycleExplanation checkedBy: file: crates/registry-bregctl/src/lib.rs symbol: LIFECYCLE_EXPLANATION target: - apiVersion: id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9 + apiVersion: id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10 kind: BRegLifecycleExplanation schema: path: products/breg/contracts/explain/LifecycleExplanation.schema.json - id: https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha9.schema.json + id: https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha10.schema.json origin: hand-written differentialTest: crates/registry-bregctl/tests/explain_contract.rs reader: none From 8fdc70b716e317d3a6f72cb284e878c2b3c370dc Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:17:36 +0000 Subject: [PATCH 03/96] feat(casework): mark unread Proposal messages in the review inbox Provisional authored source for the protected v0.52 replay. Signed-off-by: Jeremi Joslin --- crates/registry-breg-client-node/client.d.ts | 2 + .../src/proposal/messages.rs | 3 + crates/registry-breg/src/mutation/proposal.rs | 6 +- .../registry-breg/src/proposal_artifacts.rs | 7 +- .../tests/postgres_proposal_messages.rs | 52 +++--- .../tests/proposal_messages_compiler.rs | 26 +++ crates/registry-casework-breg/src/lib.rs | 10 ++ .../tests/context_provider.rs | 85 ++++++++++ .../__test__/facade.test-d.ts | 1 + .../registry-casework-client-node/client.d.ts | 2 + .../registry_casework_client/__init__.pyi | 1 + .../tests/python/test_typing_contract.py | 2 +- crates/registry-casework-client/src/wire.rs | 1 + crates/registry-casework-core/src/adapter.rs | 5 + crates/registry-casework-core/src/review.rs | 6 + .../registry-casework/src/auth/delegated.rs | 4 +- .../src/http/source_credentials.rs | 1 + crates/registry-casework/src/review.rs | 8 +- crates/registry-casework/src/review/asks.rs | 1 + crates/registry-casework/src/review/inbox.rs | 11 ++ .../registry-casework/src/review/staffing.rs | 1 + .../src/task_grants/http_tests.rs | 1 + .../src/task_grants/native_exchange_tests.rs | 1 + .../tests/review_acceptance_postgres.rs | 1 + crates/registry-casework/tests/review_http.rs | 154 +++++++++++++++++- .../tests/review_postgres.rs | 1 + .../src/content/docs/security/casework.mdx | 10 +- products/breg/CHANGELOG.md | 2 +- .../contracts/security-invariant-matrix.yaml | 2 +- products/casework/CHANGELOG.md | 1 + products/casework/README.md | 7 + 31 files changed, 385 insertions(+), 30 deletions(-) diff --git a/crates/registry-breg-client-node/client.d.ts b/crates/registry-breg-client-node/client.d.ts index 2d44d6a4fc..95b4efadfd 100644 --- a/crates/registry-breg-client-node/client.d.ts +++ b/crates/registry-breg-client-node/client.d.ts @@ -1116,6 +1116,8 @@ export interface BRegProposalMessage { } export interface BRegProposalMessages { readonly count: number; readonly unread: number; readonly lastSentAt?: string; + /** Present on review-context batch summaries that identify the read position. */ + readonly readerSide?: 'party' | 'official'; readonly items?: ReadonlyArray; readonly links?: Readonly>>; } diff --git a/crates/registry-breg-client/src/proposal/messages.rs b/crates/registry-breg-client/src/proposal/messages.rs index 17f3e78dec..3272574f51 100644 --- a/crates/registry-breg-client/src/proposal/messages.rs +++ b/crates/registry-breg-client/src/proposal/messages.rs @@ -32,6 +32,9 @@ pub struct BRegProposalMessage { pub struct BRegProposalMessages { pub count: u16, pub unread: u16, + /// The read position that produced `unread`, supplied by review-context batches. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub reader_side: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub last_sent_at: Option, #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/registry-breg/src/mutation/proposal.rs b/crates/registry-breg/src/mutation/proposal.rs index 103aa259ef..87737f6e35 100644 --- a/crates/registry-breg/src/mutation/proposal.rs +++ b/crates/registry-breg/src/mutation/proposal.rs @@ -4243,10 +4243,14 @@ impl MutationTransaction { self.check_proposal_document(tx, registry, document, thread, false) .await, )? { - if let Some(messages) = self + if let Some(mut messages) = self .proposal_messages_member(tx, action, document, thread, *text) .await? { + if !*text { + let side = crate::proposal_messages::Side::of(thread.party); + messages["readerSide"] = json!(side.as_str()); + } value["context"]["messages"] = messages; } } diff --git a/crates/registry-breg/src/proposal_artifacts.rs b/crates/registry-breg/src/proposal_artifacts.rs index a1c2768069..450b1ad498 100644 --- a/crates/registry-breg/src/proposal_artifacts.rs +++ b/crates/registry-breg/src/proposal_artifacts.rs @@ -654,7 +654,12 @@ fn append_message_openapi( } if path == "/v1/proposals/review-context" { if let Some(properties) = schema.pointer_mut("/properties/items/items/oneOf/0/properties/context/properties/context/properties") { - properties["messages"] = proposal_messages_schema(true); + let mut messages = proposal_messages_schema(true); + messages["properties"]["readerSide"] = json!({ + "enum":["party","official"], + "description":"The reader's side whose read position supplied unread." + }); + properties["messages"] = messages; } } else if let Some(parameter) = operation["parameters"] diff --git a/crates/registry-breg/tests/postgres_proposal_messages.rs b/crates/registry-breg/tests/postgres_proposal_messages.rs index 8919788fb4..2bfaa0a7b8 100644 --- a/crates/registry-breg/tests/postgres_proposal_messages.rs +++ b/crates/registry-breg/tests/postgres_proposal_messages.rs @@ -115,6 +115,10 @@ fn source() -> Value { "permissions":{"proposals":[ {"action":"apply-for-licence","operations":["get-review-context","message"], "readableContextFields":["holder"],"targets":targets()}]}}, + "owner-review": {"principalClaim":"sub","requiredScopes":["licence:self"],"actorKind":"human", + "permissions":{"proposals":[ + {"action":"apply-for-licence","party":"owner","operations":["get-review-context","message"], + "readableContextFields":["holder"],"targets":targets()}]}}, // Written for any actor kind: only the human test keeps a // service with a reviewer's grant out of the thread. "relay": {"principalClaim":"sub","requiredScopes":["licence:relay"], @@ -617,6 +621,7 @@ async fn the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_i let thread = &context["context"]["messages"]; assert_eq!(thread["count"], 1, "{context}"); assert_eq!(thread["unread"], 1, "{context}"); + assert!(thread.get("readerSide").is_none(), "{context}"); assert_eq!(thread["items"][0]["text"], QUESTION); assert_eq!(thread["items"][0]["from"], "party"); assert_eq!(thread["items"][0]["partyRole"], "owner"); @@ -677,6 +682,34 @@ async fn the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_i listed[0] ); + // The inbox batch reports the position that supplied the unread count. + // Neither side has marked the other side's message as read. + for (caller, profile, side) in [ + (reviewer(), "reviewer", "official"), + (citizen(CITIZEN), "owner-review", "party"), + ] { + let (status, _, batch) = request( + &fixture, + caller, + "GET", + &format!("/v1/proposals/review-context?ids={id}&accessProfile={profile}"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::OK, "{batch}"); + let summary = &batch["items"][0]["context"]["context"]["messages"]; + assert_eq!(summary["count"], 2, "{batch}"); + assert_eq!(summary["unread"], 1, "{batch}"); + assert_eq!(summary["readerSide"], side, "{batch}"); + assert!(summary["lastSentAt"].is_string(), "{batch}"); + assert!(summary.get("items").is_none(), "{batch}"); + assert!(summary.get("links").is_none(), "{batch}"); + let served = batch.to_string(); + assert!(!served.contains(QUESTION) && !served.contains(ANSWER)); + } + // Mark-read moves the party's side forward; repeating it changes nothing. let through = answer["id"].as_str().unwrap().to_owned(); for _ in 0..2 { @@ -763,25 +796,6 @@ async fn the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_i assert_eq!(rest["items"][0]["text"], QUESTION); assert!(rest.get("nextCursor").is_none() || rest["nextCursor"].is_null()); - // The batch read the task inbox uses carries counts and never text. - let (status, _, batch) = request( - &fixture, - reviewer(), - "GET", - &format!("/v1/proposals/review-context?ids={id}&accessProfile=reviewer"), - None, - None, - Value::Null, - ) - .await; - assert_eq!(status, StatusCode::OK, "{batch}"); - let summary = &batch["items"][0]["context"]["context"]["messages"]; - assert_eq!(summary["count"], 2, "{batch}"); - assert!(summary["lastSentAt"].is_string(), "{batch}"); - assert!(summary.get("items").is_none(), "{batch}"); - let served = batch.to_string(); - assert!(!served.contains(QUESTION) && !served.contains(ANSWER)); - // Text never reaches audit. let audit = serde_json::to_string(&fixture.audit_capture.entries()).unwrap(); assert!(!audit.contains(QUESTION) && !audit.contains(ANSWER)); diff --git a/crates/registry-breg/tests/proposal_messages_compiler.rs b/crates/registry-breg/tests/proposal_messages_compiler.rs index 33554a0332..3c7493de92 100644 --- a/crates/registry-breg/tests/proposal_messages_compiler.rs +++ b/crates/registry-breg/tests/proposal_messages_compiler.rs @@ -193,10 +193,36 @@ fn message_openapi_describes_the_three_routes_and_their_preconditions() { let mut source = with_messages(model::source(json!([])), json!({})); source.pointer_mut(CLERK_GRANT).unwrap()["operations"] = json!(["get", "edit", "submit", "cancel", "apply", "message"]); + let mut reviewer = source["accessProfiles"]["clerk"].clone(); + reviewer["default"] = json!(false); + reviewer["permissions"]["actions"] = json!([]); + reviewer["permissions"]["records"] = json!([]); + reviewer["permissions"]["proposals"] = json!([{ + "operations": ["get-review-context", "message"], + "readableContextFields": ["value"] + }]); + // Keep the Action and its target grants from the compiler fixture. + let grant = source.pointer(CLERK_GRANT).unwrap(); + reviewer["permissions"]["proposals"][0]["action"] = grant["action"].clone(); + if let Some(targets) = grant.get("targets") { + reviewer["permissions"]["proposals"][0]["targets"] = targets.clone(); + } + source["accessProfiles"]["reviewer"] = reviewer; let registry = compiled(&source); let api: Value = serde_json::from_slice(®istry.artifacts().entries()["generated/openapi.json"].bytes) .unwrap(); + let paths = &api["paths"]; + let batch = &paths["/v1/proposals/review-context"]["get"]["responses"]["200"]["content"] + ["application/json"]["schema"]["properties"]["items"]["items"]["oneOf"][0]["properties"] + ["context"]["properties"]["context"]["properties"]["messages"]; + assert_eq!( + batch["properties"]["readerSide"]["enum"], + json!(["party", "official"]) + ); + assert_eq!(batch["required"], json!(["count", "unread"])); + assert!(batch["properties"].get("items").is_none()); + assert!(batch["properties"].get("links").is_none()); let thread = &api["paths"]["/v1/proposals/{proposal_id}/messages"]; let send = &thread["post"]; assert_eq!(thread["get"]["operationId"], "proposals.list-messages"); diff --git a/crates/registry-casework-breg/src/lib.rs b/crates/registry-casework-breg/src/lib.rs index d40dfe5767..6c1b82ce4b 100644 --- a/crates/registry-casework-breg/src/lib.rs +++ b/crates/registry-casework-breg/src/lib.rs @@ -453,8 +453,17 @@ impl BregContextProvider { } } let display_reference = Some(document.context.reference); + let office_unread_messages = document + .context + .messages + .as_ref() + .filter(|thread| { + thread.reader_side == Some(registry_breg_client::BRegProposalMessageSide::Official) + }) + .and_then(|thread| std::num::NonZeroU32::new(u32::from(thread.unread))); Ok(HumanDisplayObservation { additional_forms: document.context.additional_forms, + office_unread_messages, answers, messages: document .context @@ -576,6 +585,7 @@ impl ReviewContextProvider for BregContextProvider { .map(|result| { result.map(|mut observation| { observation.answers.clear(); + observation.office_unread_messages = None; observation }) }) diff --git a/crates/registry-casework-breg/tests/context_provider.rs b/crates/registry-casework-breg/tests/context_provider.rs index a080c83b73..51a7141f5c 100644 --- a/crates/registry-casework-breg/tests/context_provider.rs +++ b/crates/registry-casework-breg/tests/context_provider.rs @@ -1195,3 +1195,88 @@ async fn display_passes_the_live_message_thread_through_and_preflight_never_requ ); assert_eq!(observed["fields"], json!({"reference":"REF-42"})); } + +#[tokio::test] +async fn inbox_count_uses_office_thread_authority_from_the_admitted_batch_read() { + let server = MockServer::start().await; + let export = export(); + let identity = identity(&export); + let provider = provider(&server, export.clone()); + let cases = [ + ("office-bearer", json!(null), json!("official"), Some(2)), + ("owner-bearer", json!("owner"), json!("party"), None), + // Permissions may change between metadata and the Proposal read. + ("cutover-to-party", json!(null), json!("party"), None), + ( + "cutover-to-office", + json!("owner"), + json!("official"), + Some(2), + ), + ("legacy-bearer", json!(null), json!(null), None), + ]; + for (bearer, metadata_party, reader_side, expected) in cases { + let mut action = json!({ + "actionId": "correct-address", "accessProfile": "reviewer", + "operations": ["get-review-context", "message"], "readableInputs": [] + }); + if !metadata_party.is_null() { + action["party"] = metadata_party; + } + let mut messages = json!({"count": 4, "unread": 2}); + if !reader_side.is_null() { + messages["readerSide"] = reader_side; + } + let auth = format!("Bearer {bearer}"); + Mock::given(method("GET")) + .and(path("/v1/registry")) + .and(query_param("accessProfile", "reviewer")) + .and(header("authorization", auth.as_str())) + .respond_with(response(json!({ + "metadataVersion": "2", "id": "registry", "version": "1", "revision": DIGEST, + "recordTypes": [], "operations": [], + "proposals": {"method": "GET", "path": "/v1/proposals", "accessProfiles": [], + "get": {"method": "GET", "path": "/v1/proposals/{proposal_id}", "accessProfiles": []}, + "actions": [action]} + }))) + .expect(1) + .mount(&server) + .await; + Mock::given(method("GET")) + .and(path("/v1/proposals/review-context")) + .and(query_param("accessProfile", "reviewer")) + .and(query_param("ids", ID)) + .and(header("authorization", auth.as_str())) + .respond_with(response(json!({"items": [{ + "id": ID, "status": "visible", "context": { + "id": ID, "actionId": "correct-address", "actionRevision": DIGEST, + "submissionVersion": 1, "revision": 1, "effectDigest": DIGEST, + "subject": {"source": "source", "subjectType": "proposal", "id": ID, + "version": "1", "digest": DIGEST}, + "context": {"reference": "native-proposal", "contract": export.contract, + "fields": {"reference": "REF-42"}, "messages": messages}, + "reviewable": true + } + }]}))) + .expect(1) + .mount(&server) + .await; + + let mut batch = provider + .human_display_batch( + std::slice::from_ref(&identity), + "reviewer", + EphemeralCredential::new(bearer), + ) + .await; + let observation = serde_json::to_value(batch.pop().unwrap().unwrap()).unwrap(); + assert_eq!( + observation + .get("officeUnreadMessages") + .and_then(Value::as_u64), + expected, + "{bearer}" + ); + } + assert_eq!(server.received_requests().await.unwrap().len(), 10); +} diff --git a/crates/registry-casework-client-node/__test__/facade.test-d.ts b/crates/registry-casework-client-node/__test__/facade.test-d.ts index 59f9d259da..34f498f61c 100644 --- a/crates/registry-casework-client-node/__test__/facade.test-d.ts +++ b/crates/registry-casework-client-node/__test__/facade.test-d.ts @@ -38,6 +38,7 @@ const missingPolicy: ReviewCreateRequest = { subject, requesterReference: 'propo void missingPolicy const query: ReviewStaffingQuery = { queue: 'review', ownership: 'assigned-to-me', subjectSource: subject.source, subjectType: subject.type, subjectId: subject.id, subjectVersion: subject.version, subjectDigest: subject.digest, sort: 'due', limit: 25 } void client.reviewTasks(token, profile, query).then(({ value }) => { const task: ReviewTask | undefined = value.items[0]; void task }) +void client.reviewTasks(token, profile, query).then(({ value }) => { const unread: number | undefined = value.items[0]?.unreadMessages; void unread }) void client.nextReviewTask(token, profile, query).then(({ value }) => { const task: ReviewTask | null = value; void task }) void client.reviewTaskHoldings(token, profile, query) void client.reviewPolicies(token, profile) diff --git a/crates/registry-casework-client-node/client.d.ts b/crates/registry-casework-client-node/client.d.ts index fd5e0a4303..e4bc790537 100644 --- a/crates/registry-casework-client-node/client.d.ts +++ b/crates/registry-casework-client-node/client.d.ts @@ -324,6 +324,8 @@ export interface ReviewTask { decidedByCaller?: boolean decisionReceipt?: ReviewDecisionReceipt marker?: ReviewTaskMarker + /** Party messages on the source thread that no office reader has read, when positive. */ + unreadMessages?: SafeInteger } export interface ReviewTaskPage { items: ReadonlyArray; nextCursor?: Uuid; status: PageStatus } export type SupervisoryReviewTaskState = 'open' | 'held' | 'decided' diff --git a/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi b/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi index bd1c9bfd67..f2a618dc17 100644 --- a/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi +++ b/crates/registry-casework-client-py/python/registry_casework_client/__init__.pyi @@ -591,6 +591,7 @@ class _ReviewTaskOptional(TypedDict, total=False): decidedByCaller: bool decisionReceipt: ReviewDecisionReceipt marker: ReviewTaskMarker + unreadMessages: SafeInteger class ReviewTask(_ReviewTaskOptional): subject: SubjectBinding requesterReference: str diff --git a/crates/registry-casework-client-py/tests/python/test_typing_contract.py b/crates/registry-casework-client-py/tests/python/test_typing_contract.py index 807d941dba..ab1d0cae36 100644 --- a/crates/registry-casework-client-py/tests/python/test_typing_contract.py +++ b/crates/registry-casework-client-py/tests/python/test_typing_contract.py @@ -181,7 +181,7 @@ def test_review_parity_inventory_is_closed_and_bounded(self) -> None: } self.assertEqual( optional_task_fields, - {"decidedByCaller": "bool", "decisionReceipt": "ReviewDecisionReceipt", "deadlineAt": "str | None", "displayReference": "str", "marker": "ReviewTaskMarker", "staffingDiagnostic": "StaffingDiagnostic"}, + {"decidedByCaller": "bool", "decisionReceipt": "ReviewDecisionReceipt", "deadlineAt": "str | None", "displayReference": "str", "marker": "ReviewTaskMarker", "staffingDiagnostic": "StaffingDiagnostic", "unreadMessages": "SafeInteger"}, ) self.assertEqual( ast.unparse(aliases["ReviewTaskOwnership"].value), diff --git a/crates/registry-casework-client/src/wire.rs b/crates/registry-casework-client/src/wire.rs index a7b8e9b820..f689be0f33 100644 --- a/crates/registry-casework-client/src/wire.rs +++ b/crates/registry-casework-client/src/wire.rs @@ -783,6 +783,7 @@ response_wire!(ReviewTaskWire => registry_casework_core::ReviewTask { #[serde(default)] decided_by_caller: Option, #[serde(default)] decision_receipt: Option, #[serde(default, deserialize_with = "deserialize_optional_string_enum")] marker: Option, + #[serde(default)] unread_messages: Option, }); #[derive(Deserialize, Serialize)] diff --git a/crates/registry-casework-core/src/adapter.rs b/crates/registry-casework-core/src/adapter.rs index b74b3e4948..3b684c20df 100644 --- a/crates/registry-casework-core/src/adapter.rs +++ b/crates/registry-casework-core/src/adapter.rs @@ -122,6 +122,11 @@ pub struct HumanDisplayObservation { /// through unchanged, links included. Casework stores none of it. #[serde(default, skip_serializing_if = "Option::is_none")] pub messages: Option, + /// Live party messages past the shared office read position. A provider + /// supplies this only when the caller's display read establishes office + /// thread authority. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub office_unread_messages: Option, } /// Status deliberately contains no business fields or display reference. diff --git a/crates/registry-casework-core/src/review.rs b/crates/registry-casework-core/src/review.rs index 5aa828b004..a18003f078 100644 --- a/crates/registry-casework-core/src/review.rs +++ b/crates/registry-casework-core/src/review.rs @@ -1323,6 +1323,11 @@ pub struct ReviewTask { /// through release and reassignment and clears when the task is decided. #[serde(default, skip_serializing_if = "Option::is_none")] pub marker: Option, + /// Party messages on the source's thread that no office reader has read + /// yet, as the caller's own source read returned it for this list. Present + /// only when positive. Computed for each read and never stored. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub unread_messages: Option, } /// What an ask of the applicant means for the task that made it. @@ -3413,6 +3418,7 @@ mod tests { decided_by_caller: None, decision_receipt: None, marker: None, + unread_messages: None, } } diff --git a/crates/registry-casework/src/auth/delegated.rs b/crates/registry-casework/src/auth/delegated.rs index f30850ccf5..417414ddc5 100644 --- a/crates/registry-casework/src/auth/delegated.rs +++ b/crates/registry-casework/src/auth/delegated.rs @@ -78,9 +78,11 @@ impl crate::CaseworkService { ) .await .map(|mut page| { - // A delegated institutional read carries no ask state. + // A delegated institutional read carries no ask state, and + // no thread state, as its task context carries no thread. for task in &mut page.items { task.marker = None; + task.unread_messages = None; } page }); diff --git a/crates/registry-casework/src/http/source_credentials.rs b/crates/registry-casework/src/http/source_credentials.rs index 0aeb7f2ab6..1f0483a416 100644 --- a/crates/registry-casework/src/http/source_credentials.rs +++ b/crates/registry-casework/src/http/source_credentials.rs @@ -555,6 +555,7 @@ mod tests { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/src/review.rs b/crates/registry-casework/src/review.rs index d146c7773d..8a778a8014 100644 --- a/crates/registry-casework/src/review.rs +++ b/crates/registry-casework/src/review.rs @@ -805,7 +805,7 @@ impl CaseworkService { { // Ownership and queue can change during source I/O. // Recheck both before releasing the current row. - Ok(current) + Ok(mut current) if queue.is_none_or(|queue| current.queue == queue) && (!view.is_own_decisions() || current.decision_receipt.is_some()) @@ -815,6 +815,7 @@ impl CaseworkService { view.ownership(), ) => { + current.unread_messages = observations.unread_messages(&record); items.push(current); disclosed = true; } @@ -3685,6 +3686,7 @@ impl PostgresStore { decided_by_caller: None, decision_receipt: None, marker: task_marker(metadata.get::<_, Option>(4))?, + unread_messages: None, }; let claim_event_id = Uuid::new_v4(); { @@ -4037,6 +4039,7 @@ impl PostgresStore { decided_by_caller: None, decision_receipt: None, marker: task_marker(metadata.get::<_, Option>(4))?, + unread_messages: None, }; insert_review_idempotency( &transaction, @@ -4864,6 +4867,7 @@ impl PostgresStore { decided_by_caller: None, decision_receipt: None, marker: task_marker(metadata.get::<_, Option>(4))?, + unread_messages: None, }; let actor_ref = actor_reference(&actor.principal); let release_event_id = Uuid::new_v4(); @@ -5023,6 +5027,7 @@ impl PostgresStore { decided_by_caller: None, decision_receipt: None, marker: task_marker(metadata.get::<_, Option>(4))?, + unread_messages: None, }; check_task_holder(&task.state, &actor.principal).map_err(map_review_decision_error)?; let mut progress = ReviewProgress::new( @@ -6127,6 +6132,7 @@ fn reviewer_task_from_row( decided_by_caller: None, decision_receipt: None, marker: task_marker(row.get::<_, Option>("ask_marker"))?, + unread_messages: None, }) } diff --git a/crates/registry-casework/src/review/asks.rs b/crates/registry-casework/src/review/asks.rs index d9dab0448e..9df5c8b295 100644 --- a/crates/registry-casework/src/review/asks.rs +++ b/crates/registry-casework/src/review/asks.rs @@ -337,6 +337,7 @@ impl PostgresStore { decided_by_caller: None, decision_receipt: None, marker: task_marker(metadata.get::<_, Option>(4))?, + unread_messages: None, }; let ask = ReviewAsk { ask_id, diff --git a/crates/registry-casework/src/review/inbox.rs b/crates/registry-casework/src/review/inbox.rs index 02a0b73ce5..697ffe1750 100644 --- a/crates/registry-casework/src/review/inbox.rs +++ b/crates/registry-casework/src/review/inbox.rs @@ -281,6 +281,17 @@ impl InboxObservations { } Ok(view.display_reference.clone()) } + + /// Read only the office count attested by the provider, after `display` + /// has admitted the record. + pub(super) fn unread_messages(&self, record: &ReviewRequestRecord) -> Option { + self.human + .get(&record.request_id)? + .as_ref() + .ok()? + .office_unread_messages + .map(std::num::NonZeroU32::get) + } } impl PostgresStore { diff --git a/crates/registry-casework/src/review/staffing.rs b/crates/registry-casework/src/review/staffing.rs index 5674f909ca..63a9d6a7f0 100644 --- a/crates/registry-casework/src/review/staffing.rs +++ b/crates/registry-casework/src/review/staffing.rs @@ -256,6 +256,7 @@ impl CaseworkService { continue; } row.display_reference = display_reference; + row.unread_messages = observations.unread_messages(record); if query .reference .as_ref() diff --git a/crates/registry-casework/src/task_grants/http_tests.rs b/crates/registry-casework/src/task_grants/http_tests.rs index 42e7d9dde4..2c0b9badeb 100644 --- a/crates/registry-casework/src/task_grants/http_tests.rs +++ b/crates/registry-casework/src/task_grants/http_tests.rs @@ -53,6 +53,7 @@ impl ReviewContextProvider for Source { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/src/task_grants/native_exchange_tests.rs b/crates/registry-casework/src/task_grants/native_exchange_tests.rs index 4c01a25402..9ab0e6acb1 100644 --- a/crates/registry-casework/src/task_grants/native_exchange_tests.rs +++ b/crates/registry-casework/src/task_grants/native_exchange_tests.rs @@ -66,6 +66,7 @@ impl ReviewContextProvider for Source { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, diff --git a/crates/registry-casework/tests/review_acceptance_postgres.rs b/crates/registry-casework/tests/review_acceptance_postgres.rs index 55c4cfd3df..11f316b15f 100644 --- a/crates/registry-casework/tests/review_acceptance_postgres.rs +++ b/crates/registry-casework/tests/review_acceptance_postgres.rs @@ -122,6 +122,7 @@ impl ReviewContextProvider for SubstituteProvider { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity, reviewable: true, diff --git a/crates/registry-casework/tests/review_http.rs b/crates/registry-casework/tests/review_http.rs index 404ecd943b..1d5ac95d4f 100644 --- a/crates/registry-casework/tests/review_http.rs +++ b/crates/registry-casework/tests/review_http.rs @@ -82,6 +82,10 @@ impl InboxLogs { } } +/// Thread summary and reader authority by subject ID. Each test uses its own +/// subject IDs, so parallel tests do not share entries. +static SOURCE_THREADS: Mutex> = Mutex::new(BTreeMap::new()); + #[derive(Clone)] struct ReviewSource { revoked: Arc, @@ -129,13 +133,23 @@ impl ReviewContextProvider for ReviewSource { if self.changed.load(Ordering::SeqCst) { identity.subject.version = "2".into(); } + let thread = SOURCE_THREADS + .lock() + .unwrap() + .get(&request.identity.subject.id) + .copied(); Ok(HumanDisplayObservation { additional_forms: if request.identity.subject.id == "form-ask" { BTreeMap::from([("household-details".into(), "Household details".into())]) } else { BTreeMap::new() }, - messages: None, + messages: thread.map(|(unread, _)| { + json!({"count": 4, "unread": unread, "lastSentAt": "2026-12-01T09:00:00Z"}) + }), + office_unread_messages: thread + .filter(|(_, office)| *office) + .and_then(|(unread, _)| std::num::NonZeroU32::new(unread)), answers: self .delegated_barrier .as_ref() @@ -2971,6 +2985,121 @@ async fn mixed_context_inbox_lists_submitted_and_source_tasks_together() { idp.stop().await; } +async fn list_inbox(app: &axum::Router, idp: &MockIdp) -> Vec { + let listed = app + .clone() + .oneshot( + Request::builder() + .uri(with_profile("/v1/review-tasks", "staff")) + .header("authorization", format!("Bearer {}", reviewer_token(idp))) + .header(SOURCE_PROFILE_HEADER, "reviewer-source") + .header( + SOURCE_AUTHORIZATION_HEADER, + format!("Bearer {}", source_token_value(idp)), + ) + .body(Body::empty()) + .expect("inbox task page request"), + ) + .await + .expect("inbox task page response"); + assert_eq!(listed.status(), StatusCode::OK); + let page: Value = serde_json::from_slice( + &to_bytes(listed.into_body(), 64 * 1024) + .await + .expect("bounded inbox task page"), + ) + .expect("inbox task page JSON"); + page["items"].as_array().expect("inbox items").clone() +} + +#[tokio::test] +async fn the_inbox_marks_a_task_whose_source_thread_has_unread_party_messages() { + let idp = MockIdp::start().await; + let (app, _, _, _, _, _) = app(&idp).await; + let suffix = Uuid::new_v4().simple().to_string(); + let unread = format!("thread-unread-{suffix}"); + let read = format!("thread-read-{suffix}"); + let without = format!("no-thread-{suffix}"); + let owner = format!("owner-thread-{suffix}"); + { + let mut threads = SOURCE_THREADS.lock().unwrap(); + threads.insert(unread.clone(), (2, true)); + threads.insert(read.clone(), (0, true)); + // This count is the owner's unread office messages. + threads.insert(owner.clone(), (3, false)); + } + let mut requests = BTreeMap::new(); + for subject in [&unread, &read, &without, &owner] { + let mut request = create_http_request( + &review_request_for_subject(subject, &format!("ref-{subject}"), &idp.issuer()), + Some(&token(&idp)), + ); + request.headers_mut().insert( + "idempotency-key", + format!("create-{subject}") + .parse() + .expect("idempotency key"), + ); + let created = app + .clone() + .oneshot(request) + .await + .expect("create a source-context review"); + assert_eq!(created.status(), StatusCode::CREATED); + let created: ReviewRequestAccepted = serde_json::from_slice( + &to_bytes(created.into_body(), 32 * 1024) + .await + .expect("bounded create response"), + ) + .expect("create JSON"); + requests.insert(created.request_id.to_string(), subject.clone()); + } + let unread_markers = |items: &[Value]| { + items + .iter() + .filter_map(|item| { + let subject = requests.get(item["requestId"].as_str()?)?; + Some((subject.clone(), item.get("unreadMessages").cloned())) + }) + .collect::>() + }; + + let items = list_inbox(&app, &idp).await; + assert_eq!( + unread_markers(&items), + BTreeMap::from([ + (unread.clone(), Some(json!(2))), + (read.clone(), None), + (without.clone(), None), + (owner.clone(), None), + ]), + "only the task whose thread has unread party messages carries the count" + ); + // The marker is the count alone: nothing of the thread's text, author or + // timing reaches the inbox item. + for item in &items { + for member in ["messages", "lastSentAt", "text", "from", "sentBy"] { + assert!(item.get(member).is_none(), "{member} in {item}"); + } + } + + // Reading the thread in the source moves the office's read position. + SOURCE_THREADS + .lock() + .unwrap() + .insert(unread.clone(), (0, true)); + let items = list_inbox(&app, &idp).await; + assert_eq!(unread_markers(&items)[&unread], None); + + { + let mut threads = SOURCE_THREADS.lock().unwrap(); + threads.remove(&unread); + threads.remove(&read); + threads.remove(&owner); + } + idp.stop().await; +} + #[tokio::test] async fn standalone_structured_answer_can_be_claimed_decided_and_polled_over_http() { let idp = MockIdp::start().await; @@ -6182,6 +6311,7 @@ impl ReviewContextProvider for SeparateHumanSource { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: true, @@ -7707,8 +7837,13 @@ async fn delegated_institutional_reads_carry_neither_asks_nor_markers() { let (app, _, _, _, _, _, database) = app_with_project_options(&idp, project, Some(barrier.clone()), true, None, None).await; let (client, server) = native_review_client(app.clone()).await; - let created_request = - review_request_for_subject("ask-delegated", "ask-delegated-ref", &idp.issuer()); + // The subject has a source thread with unread party messages. + let subject = format!("ask-delegated-{}", Uuid::new_v4().simple()); + SOURCE_THREADS + .lock() + .unwrap() + .insert(subject.clone(), (3, true)); + let created_request = review_request_for_subject(&subject, "ask-delegated-ref", &idp.issuer()); let (_, task_id) = create_task(&app, &database, &idp, &created_request).await; let reviewer = human_token(&idp, "reviewer", "staff"); let reviewer_source = source_token(&idp); @@ -7759,6 +7894,14 @@ async fn delegated_institutional_reads_carry_neither_asks_nor_markers() { .value; assert_eq!(own.asks.len(), 1); assert!(own.asks[0].answer.is_some()); + // The reviewer's own list carries the thread's unread count. + let own_list = client + .review_tasks(reviewer_auth(), &ReviewStaffingQuery::default()) + .await + .expect("reviewer list") + .value; + assert_eq!(own_list.items.len(), 1); + assert_eq!(own_list.items[0].unread_messages, Some(3)); barrier.release.notify_one(); let delegated = delegated_staff_read_token(&idp, "reviewer"); @@ -7788,6 +7931,10 @@ async fn delegated_institutional_reads_carry_neither_asks_nor_markers() { .value; assert_eq!(list.items.len(), 1); assert_eq!(list.items[0].marker, None); + // The delegated context carries no thread, so the delegated list carries + // no count of it either. + assert_eq!(list.items[0].unread_messages, None); + SOURCE_THREADS.lock().unwrap().remove(&subject); server.abort(); idp.stop().await; } @@ -7926,6 +8073,7 @@ impl ReviewContextProvider for RecordingSourceProvider { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: if request.include_answers { self.answers.lock().unwrap().clone() } else { diff --git a/crates/registry-casework/tests/review_postgres.rs b/crates/registry-casework/tests/review_postgres.rs index 21e63d17eb..4ee4204b73 100644 --- a/crates/registry-casework/tests/review_postgres.rs +++ b/crates/registry-casework/tests/review_postgres.rs @@ -92,6 +92,7 @@ impl ReviewContextProvider for ReviewSource { Ok(HumanDisplayObservation { additional_forms: Default::default(), messages: None, + office_unread_messages: None, answers: Default::default(), identity: request.identity.clone(), reviewable: *self.state.lock().unwrap(), diff --git a/docs/site/src/content/docs/security/casework.mdx b/docs/site/src/content/docs/security/casework.mdx index 5ca0299656..f33b370fea 100644 --- a/docs/site/src/content/docs/security/casework.mdx +++ b/docs/site/src/content/docs/security/casework.mdx @@ -79,8 +79,16 @@ grants in [Registry Casework task grants](../../reference/casework-task-grants/) - Proposal messages: the BReg provider requests the live thread for the reviewer's task display. Claim, ask and decision preflight omit the thread. Casework stores no message text. + The inbox's `unreadMessages` count shows only what the reviewer's own BReg + review-context read already returns for that list, computed live and never + stored. It is not a new disclosure. Delegated institutional reads carry no + thread and no count. {/* Evidence: crates/registry-casework-breg/tests/context_provider.rs; - crates/registry-casework/src/review.rs. */} + crates/registry-casework/src/review.rs; + crates/registry-casework/src/review/inbox.rs, unread_messages; + crates/registry-casework/tests/review_http.rs, + the_inbox_marks_a_task_whose_source_thread_has_unread_party_messages, + delegated_institutional_reads_carry_neither_asks_nor_markers. */} - Private reason versus public reason: every decision names an outcome declared by the pinned policy and offered at the current stage. The reviewer's private reason stays in the accountability record. diff --git a/products/breg/CHANGELOG.md b/products/breg/CHANGELOG.md index 4f368f2951..7a8d3970f5 100644 --- a/products/breg/CHANGELOG.md +++ b/products/breg/CHANGELOG.md @@ -89,7 +89,7 @@ - `tests/journeys.yaml` steps invoke a `concurrency: current-revision` Action without `preconditions`, as its HTTP contract requires. - A `tests/journeys.yaml` Proposal `get` step may wait for automatic application with `waitSeconds`, from 1 to 60: `bregctl test` runs the built-in application executor and reads the Proposal again until the response matches the step's expectation, and fails the step with `fixture.proposal.wait-timed-out` when the time runs out. Steps without `waitSeconds` never run the executor. A Proposal `get` or `apply` step may also map an effect to a record capture with `captureResults`, taken from the application's result links, when that effect is the Action's only one on its Record type. The `minimal-directory` starter journey waits for its contact registration and reads the contact back. - Observed membership refusals count under `membership` in `breg_request_refusals_total{check}` and in the refusal log. Generic precondition responses retain their existing body in both postures. -- A Proposal can carry one message thread between its party (the owner or the subject) and the office. An Action opens it with `execution.proposal.messages: {maximumCount}` (1 through 1000, default 200, counted for each side), with or without review, and without changing the Action revision, so Proposals in flight get the thread at activation. A grant's `message` operation reads and writes it; a message written under a party-bound entry is `from: party`, under any other grant `from: official`. Only a verified person acting for themselves reads or writes. Routes: `POST /v1/proposals/{proposal_id}/messages` (`If-Match`, `Idempotency-Key`, at most 2,000 UTF-8 bytes of text that displays as written: no control character but a line break or tab, a carriage return only before a line feed, and no reordering, zero-width or tag character), `GET /v1/proposals/{proposal_id}/messages` (newest first, `after` and `limit`, with the thread's links) and `POST /v1/proposals/{proposal_id}/messages/read`. The thread opens at the first Submit and closes for writes when the Proposal is applied, rejected or cancelled. The Proposal document and `GET /v1/proposals/{proposal_id}/review-context?include=messages` carry a `messages` member; list items and the batch review-context read carry its counts only. New problem code `409 proposal.message-limit-reached`, new diagnostics `breg.proposal.message-grant-invalid` and `breg.proposal.message-count-invalid`. +- A Proposal can carry one message thread between its party (the owner or the subject) and the office. An Action opens it with `execution.proposal.messages: {maximumCount}` (1 through 1000, default 200, counted for each side), with or without review, and without changing the Action revision, so Proposals in flight get the thread at activation. A grant's `message` operation reads and writes it; a message written under a party-bound entry is `from: party`, under any other grant `from: official`. Only a verified person acting for themselves reads or writes. Routes: `POST /v1/proposals/{proposal_id}/messages` (`If-Match`, `Idempotency-Key`, at most 2,000 UTF-8 bytes of text that displays as written: no control character but a line break or tab, a carriage return only before a line feed, and no reordering, zero-width or tag character), `GET /v1/proposals/{proposal_id}/messages` (newest first, `after` and `limit`, with the thread's links) and `POST /v1/proposals/{proposal_id}/messages/read`. The thread opens at the first Submit and closes for writes when the Proposal is applied, rejected or cancelled. The Proposal document and `GET /v1/proposals/{proposal_id}/review-context?include=messages` carry a `messages` member; list items carry the thread summary. The batch review-context summary identifies the read position that supplied `unread` with `readerSide: party` or `readerSide: official` from the admitted thread grant. It carries no message text or links. New problem code `409 proposal.message-limit-reached`, new diagnostics `breg.proposal.message-grant-invalid` and `breg.proposal.message-count-invalid`. - `tests/journeys.yaml` Proposal steps gain `transition: message`, which writes `text` to the thread under the step's captured condition and an idempotency key, and `transition: read-messages`, which marks the thread read through the newest message the captured document shows. Proposal steps may also expect `status` and `turn`. - A message write and a mark-read each advance the Proposal revision and ETag, so a client holding an older `If-Match` refetches before its next command. A reviewer whose profile holds the thread but not Get is answered with the thread alone while no review context is readable, between review rounds or after the Action changed. Thread activity never fences automatic application. - An office message the party has not read makes it the party's turn, so `GET /v1/proposals?turn=party` lists the Proposal, while its `status` and every offered command stay as they were. `bregctl explain lifecycle` lists the new turn condition and advances to `v1alpha10`. diff --git a/products/breg/contracts/security-invariant-matrix.yaml b/products/breg/contracts/security-invariant-matrix.yaml index df58c8a076..183b9f5ec5 100644 --- a/products/breg/contracts/security-invariant-matrix.yaml +++ b/products/breg/contracts/security-invariant-matrix.yaml @@ -296,7 +296,7 @@ invariants: - {"id": "BREG-SEC-277", "state": "enforced", "targetWave": "W5", "threat": "An agent or a service with a message grant reads, writes or marks read text one person wrote to another.", "enforcementPoint": "Project compilation refuses message on an agent or service profile; on a profile written for any kind, message takes the admission's human test for writes, mark-read, pages and the review-context include.", "refusal": "Refuse compilation with breg.proposal.message-grant-invalid; refuse write, mark-read and list with 403 profile.not-authorized and serve no messages member.", "negativeId": "BREG-NEG-277", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "only_a_person_acting_for_themselves_reads_or_writes_the_thread"}} - {"id": "BREG-SEC-278", "state": "enforced", "targetWave": "W5", "threat": "An unread message opens or closes a command, or changes the status a party or reviewer acts on.", "enforcementPoint": "The lifecycle rule derives the status from whose move it is without the unread-message condition; the unread office message changes only the served turn.", "refusal": "Serve turn: party while the status and every link's availability stay as they were.", "negativeId": "BREG-NEG-278", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} - {"id": "BREG-SEC-279", "state": "enforced", "targetWave": "W5", "threat": "A thread is writable before the request is first submitted, or after it ends.", "enforcementPoint": "A write checks inside the Proposal transaction that the thread has opened at a Submit and that the Proposal is draft or submitted.", "refusal": "Refuse a write before the first Submit or on a cancelled Proposal with 412 precondition.failed and on a rejected one with 409 proposal.rejected; the thread stays readable.", "negativeId": "BREG-NEG-279", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_is_closed_before_the_first_submit_and_after_cancel_or_rejection"}} - - {"id": "BREG-SEC-280", "state": "enforced", "targetWave": "W5", "threat": "Message text reaches a reader who did not ask for it, the inbox batch or the audit journal.", "enforcementPoint": "Text is served only by the Proposal document of a message holder, the thread page and the single review-context read with include=messages. The batch read serves counts; audit records message IDs and sides.", "refusal": "Omit context.messages without include=messages, serve counts only in the batch read, and write no text to audit.", "negativeId": "BREG-NEG-280", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} + - {"id": "BREG-SEC-280", "state": "enforced", "targetWave": "W5", "threat": "Message text reaches a reader who did not ask for it, the inbox batch or the audit journal.", "enforcementPoint": "Text is served only by the Proposal document of a message holder, the thread page and the single review-context read with include=messages. The batch serves counts and the reader side from the same admitted thread grant; audit records message IDs and sides.", "refusal": "Omit context.messages on scalar reads without include=messages. Serve no message items or links in the batch read, and write no text to audit.", "negativeId": "BREG-NEG-280", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} - {"id": "BREG-SEC-281", "state": "enforced", "targetWave": "W5", "threat": "A writer floods the thread, smuggles control or reordering characters, or overwrites the other side's message through a stale view.", "enforcementPoint": "The write route bounds text to 2,000 UTF-8 bytes of characters that display, with no control, reordering, zero-width or tag character and a carriage return only before a line feed; the store refuses a side past the Action's maximumCount, so neither side can close the thread for the other; the Proposal ETag and idempotency receipt fence each write. A receipt that includes the thread binds its original side and requires current Message authority for that side.", "refusal": "Refuse bad text with 400 request.invalid at /text, a full thread with 409 proposal.message-limit-reached and a stale If-Match with 412 precondition.failed; return the stored response after current disclosure checks or refuse replay when the original thread side cannot be established or admitted.", "negativeId": "BREG-NEG-281", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_thread_refuses_stale_writes_replays_keys_checks_text_and_stops_at_its_limit"}} - {"id": "BREG-SEC-282", "state": "enforced", "targetWave": "W5", "threat": "A thread route reaches the Proposals of an Action that declares no thread.", "enforcementPoint": "Route admission resolves the Proposal's Action and refuses one without execution.proposal.messages before any grant is chosen.", "refusal": "Conceal every thread route with 404 resource.not-found and serve no messages member.", "negativeId": "BREG-NEG-282", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "an_action_without_messages_serves_no_thread"}} - {"id": "BREG-SEC-283", "state": "enforced", "targetWave": "W5", "threat": "A profile without writableForms for a form, or a caller who is not the Proposal's party, adds an entry to it.", "enforcementPoint": "The add route checks the selected grant's writableForms after the Proposal is visible to the caller, and the Proposal transaction checks it again under the Proposal lock.", "refusal": "Refuse a form the grant does not write with 403 profile.not-authorized and conceal the Proposal from a stranger with 404 resource.not-found; store no entry.", "negativeId": "BREG-NEG-283", "negativeTest": {"path": "crates/registry-breg/tests/support/proposal_additions.rs", "name": "form_entries_need_their_own_write_and_read_grants"}} diff --git a/products/casework/CHANGELOG.md b/products/casework/CHANGELOG.md index 3e5be4d073..09a78fb949 100644 --- a/products/casework/CHANGELOG.md +++ b/products/casework/CHANGELOG.md @@ -14,6 +14,7 @@ revision route, replace `id` and `revision` with `holidayId` and `holidayRevision`. Operation names and concrete HTTP URLs stay the same. +- The review task list adds `unreadMessages` to a task whose source Proposal thread has party messages no office reader has read. Casework uses the count when the reviewer's own BReg batch display identifies the shared office read position. It clears when the office reads the thread in BReg. The marker is computed for each list response and omitted for zero counts, party-side or unspecified read positions, and delegated institutional reads. - A review ask can want a form: `{"kind":"form","form":""}` asks the applicant for an entry of a form the source declares. Casework confirms the form through the reviewer's own current source authorization before it stores the ask and refuses an undeclared one with `422 review.ask-form-unknown`. The task context lists the forms the source declares under `additionalForms`, so a reviewer can name one. An answer's form entries are read live into the task context and are never stored by Casework. - The displayed task context carries the source's message thread under `messages`, read live with the reviewer's own token and passed through unchanged, links included. Claim, ask and decision preflight never request it, and Casework stores no message text. diff --git a/products/casework/README.md b/products/casework/README.md index 408f2f75fe..d68c2d19ab 100644 --- a/products/casework/README.md +++ b/products/casework/README.md @@ -196,6 +196,13 @@ metadata cannot decode. `source.version-mismatch` names an incompatible peer; `source.version-unavailable` means the peer did not supply a usable version. Neither refusal echoes the peer's header or source data. +The task list's optional `unreadMessages` count is the number of party messages +past the office's shared read position. Casework uses the count only when the +caller's admitted BReg batch display reports `readerSide: official` on that +summary. Party-side summaries, older summaries without a reader side, zero +counts, and delegated institutional reads omit the marker. It is computed on +each list read and is never stored. + ## Approval patterns Create a submitted-snapshot approval project with a shared pattern: From 10817e5113f78a0ce5d8a064682000fb24fc4a7a Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:17:36 +0000 Subject: [PATCH 04/96] fix(breg): name Record types in authoring diagnostic codes Provisional authored source for the protected v0.52 replay. Signed-off-by: Jeremi Joslin --- .../registry-breg/src/authoring_integrity.rs | 4 +- crates/registry-breg/src/compiler.rs | 14 ++-- crates/registry-breg/src/membership.rs | 4 +- .../registry-breg/tests/compiler_contract.rs | 74 +++++++++++++++---- .../tests/membership_authoring.rs | 2 +- .../tests/native_source_conventions.rs | 2 +- products/breg/CHANGELOG.md | 11 +++ 7 files changed, 84 insertions(+), 27 deletions(-) diff --git a/crates/registry-breg/src/authoring_integrity.rs b/crates/registry-breg/src/authoring_integrity.rs index bf270b0b3a..2fab0104ea 100644 --- a/crates/registry-breg/src/authoring_integrity.rs +++ b/crates/registry-breg/src/authoring_integrity.rs @@ -778,7 +778,7 @@ pub(crate) fn project_diagnostics( ), ), ( - "breg.manifest.entity-id-collision", + "breg.manifest.record-type-id-collision", indexed_ids(&format!("{base}/entities"), &projection.entities, |item| { &item.id }), @@ -1061,7 +1061,7 @@ fn add_project_display_warnings( .collect::>(), ), ( - "breg.manifest-entity.duplicate-title", + "breg.manifest-record-type.duplicate-title", "manifest entities", projection .entities diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index 84fc95bbb3..eb25b942b4 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -2032,7 +2032,7 @@ fn validate_cross_file_duplicate_display_labels( &distributions, ), ( - "breg.manifest-entity.duplicate-title", + "breg.manifest-record-type.duplicate-title", "manifest entities", &entities, ), @@ -2660,7 +2660,7 @@ fn validate_manifest_projection( let path = format!("project.recordTypes[{}].primaryDataset", entity.id); let Some(dataset_id) = entity.primary_dataset.as_deref() else { errors.push(Diagnostic::error( - "breg.manifest-projection.entity-primary-dataset-required", + "breg.manifest-projection.record-type-primary-dataset-required", path, "every exposed entity must name one primaryDataset", )); @@ -2671,7 +2671,7 @@ fn validate_manifest_projection( } if !datasets.contains_key(dataset_id) { errors.push(Diagnostic::error( - "breg.manifest-projection.entity-dataset-dangling", + "breg.manifest-projection.record-type-dataset-dangling", path, "entity primaryDataset must reference manifestProjection.datasets[]", )); @@ -2682,7 +2682,7 @@ fn validate_manifest_projection( for (index, dataset) in projection.datasets.iter().enumerate() { if !members.contains_key(dataset.id.as_str()) { errors.push(Diagnostic::error( - "breg.manifest-projection.dataset-entities-empty", + "breg.manifest-projection.dataset-record-types-empty", format!("project.manifestProjection.datasets[{index}]"), "every dataset must contain at least one exposed entity", )); @@ -2829,7 +2829,7 @@ fn validate_manifest_projection( let path = format!("project.manifestProjection.entities[{}]", metadata.id); if !entity_ids.insert(metadata.id.as_str()) { errors.push(Diagnostic::error( - "breg.manifest-projection.entity-duplicate", + "breg.manifest-projection.record-type-duplicate", path, "Registry Manifest entity metadata must be unique", )); @@ -2837,7 +2837,7 @@ fn validate_manifest_projection( } let Some((entity, visible_fields)) = visible.get(metadata.id.as_str()) else { errors.push(Diagnostic::error( - "breg.manifest-projection.entity-not-visible", + "breg.manifest-projection.record-type-not-visible", path, "Registry Manifest metadata may describe only an entity visible through the selected access profile", )); @@ -4468,7 +4468,7 @@ fn validate_entities( nonempty( &entity.primary_dataset, "recordTypes[].primaryDataset", - "breg.manifest-projection.entity-primary-dataset-required", + "breg.manifest-projection.record-type-primary-dataset-required", errors, ); validate_id(&entity.route, "recordTypes[].route", errors); diff --git a/crates/registry-breg/src/membership.rs b/crates/registry-breg/src/membership.rs index 78bd91f00f..f36b822e3c 100644 --- a/crates/registry-breg/src/membership.rs +++ b/crates/registry-breg/src/membership.rs @@ -733,7 +733,7 @@ fn validate_entries<'a>( .map(|declaration| (source, declaration)) }) else { errors.push(Diagnostic::error( - "breg.access.membership-entity-unknown", + "breg.access.membership-record-type-unknown", &site, &format!( "membership must name a Record type with a membership declaration, found {}", @@ -1036,7 +1036,7 @@ pub(crate) fn resolve_entry( }) .ok_or_else(|| { Diagnostic::error( - "breg.access.membership-entity-unknown", + "breg.access.membership-record-type-unknown", location, &format!( "membership must name a Record type with a membership declaration, found {}", diff --git a/crates/registry-breg/tests/compiler_contract.rs b/crates/registry-breg/tests/compiler_contract.rs index 060be3e7f7..088839a2f2 100644 --- a/crates/registry-breg/tests/compiler_contract.rs +++ b/crates/registry-breg/tests/compiler_contract.rs @@ -17,9 +17,9 @@ use registry_breg::contract::{ parse_module_json, parse_module_yaml, parse_project_json, parse_project_yaml, ActionExecutionSource, ActionSource, BatchSource, Classification, ComparisonOperator, ConstraintSource, DerivedFieldSource, DerivedSource, DisplaySource, FieldTypeSource, - ModelDisplaySource, ModuleAssetSource, ModuleLockSource, Operation, PackageIdentitySource, - ReferenceDelete, RegistryModule, ReviewAuthoritySource, UniqueWhenPredicate, - MODULE_API_VERSION, MODULE_KIND, + ManifestProjectionEntitySource, ModelDisplaySource, ModuleAssetSource, ModuleLockSource, + Operation, PackageIdentitySource, ReferenceDelete, RegistryModule, ReviewAuthoritySource, + UniqueWhenPredicate, MODULE_API_VERSION, MODULE_KIND, }; use registry_breg::diagnostics::{CompileFailure, DiagnosticSeverity}; use registry_breg::generated_ddl::DdlStatementKind; @@ -1415,6 +1415,59 @@ fn manifest_projection_excludes_every_protected_resource_from_public_bytes() { } } +#[test] +fn projection_refuses_record_type_metadata_id_collisions() { + let mut source = multi_dataset_value(); + source["manifestProjection"]["entities"] = json!([ + {"id": "person-record"}, + {"id": "person_record"} + ]); + let failure = parse_project_json(&serde_json::to_vec(&source).unwrap()) + .expect_err("lookalike Record type metadata ids are refused"); + assert!( + failure.diagnostics().iter().any(|diagnostic| { + diagnostic.code == "breg.manifest.record-type-id-collision" + && diagnostic.path == "project.manifestProjection.entities[1].id" + }), + "{failure:?}" + ); +} + +#[test] +fn projection_refuses_duplicate_record_type_metadata() { + let mut project = multi_dataset_project(); + let metadata: ManifestProjectionEntitySource = + serde_json::from_value(json!({"id": "person"})).expect("valid projection metadata"); + // This typed input bypasses the document reader's identifier collision check. + project.manifest_projection.as_mut().unwrap().entities = vec![metadata.clone(), metadata]; + assert_compile_diagnostic(project, "breg.manifest-projection.record-type-duplicate"); +} + +#[test] +fn projection_refuses_record_types_in_an_unpublished_dataset() { + let mut project = multi_dataset_project(); + project + .manifest_projection + .as_mut() + .unwrap() + .datasets + .remove(0); + assert_compile_diagnostic( + project, + "breg.manifest-projection.record-type-dataset-dangling", + ); +} + +#[test] +fn projection_refuses_datasets_without_record_types() { + let mut empty_dataset = multi_dataset_project(); + empty_dataset.entities[1].primary_dataset = "people".to_owned(); + assert_compile_diagnostic( + empty_dataset, + "breg.manifest-projection.dataset-record-types-empty", + ); +} + #[test] fn plural_projection_refuses_duplicate_and_dangling_membership() { let mut missing_canonical_iri = multi_dataset_project(); @@ -1452,14 +1505,7 @@ fn plural_projection_refuses_duplicate_and_dangling_membership() { missing.entities[0].primary_dataset.clear(); assert_compile_diagnostic( missing, - "breg.manifest-projection.entity-primary-dataset-required", - ); - - let mut empty_dataset = multi_dataset_project(); - empty_dataset.entities[1].primary_dataset = "people".to_owned(); - assert_compile_diagnostic( - empty_dataset, - "breg.manifest-projection.dataset-entities-empty", + "breg.manifest-projection.record-type-primary-dataset-required", ); let mut duplicate_service = multi_dataset_project(); @@ -1601,7 +1647,7 @@ fn missing_resource_identity_members_have_actionable_authoring_diagnostics() { "project.project.canonicalBaseIri" ))); assert!(project_codes.contains(&( - "breg.manifest-projection.entity-primary-dataset-required", + "breg.manifest-projection.record-type-primary-dataset-required", "recordTypes[id=record].primaryDataset" ))); @@ -1621,7 +1667,7 @@ fn missing_resource_identity_members_have_actionable_authoring_diagnostics() { let module = compile_project(&project, &[module], CompileProfile::Authoring) .expect_err("module entity membership is required for compilation"); assert!(module.diagnostics().iter().any(|diagnostic| { - diagnostic.code == "breg.manifest-projection.entity-primary-dataset-required" + diagnostic.code == "breg.manifest-projection.record-type-primary-dataset-required" && diagnostic.path == "recordTypes[id=record].primaryDataset" })); } @@ -3674,7 +3720,7 @@ fn manifest_projection_metadata_cannot_describe_hidden_entities_or_fields() { assert!(codes.contains("breg.manifest-projection.field-not-visible")); assert!(codes.contains("breg.manifest-projection.field-not-representable")); - assert!(codes.contains("breg.manifest-projection.entity-not-visible")); + assert!(codes.contains("breg.manifest-projection.record-type-not-visible")); } #[test] diff --git a/crates/registry-breg/tests/membership_authoring.rs b/crates/registry-breg/tests/membership_authoring.rs index 37f0b8a3eb..31d7936fb5 100644 --- a/crates/registry-breg/tests/membership_authoring.rs +++ b/crates/registry-breg/tests/membership_authoring.rs @@ -152,7 +152,7 @@ fn an_entry_with_neither_is_refused() { fn a_membership_entry_naming_a_type_without_membership_is_refused() { let mut project = project(); project.pointer_mut(ROWS).unwrap()[0]["membership"] = json!("organization"); - assert_refusal(&project, "breg.access.membership-entity-unknown", + assert_refusal(&project, "breg.access.membership-record-type-unknown", "recordTypes[id=facility].accessProfiles[id=member].rowBoundaries[membership=organization:field=organization]"); } diff --git a/crates/registry-breg/tests/native_source_conventions.rs b/crates/registry-breg/tests/native_source_conventions.rs index 8057fd8d4d..ec66b91022 100644 --- a/crates/registry-breg/tests/native_source_conventions.rs +++ b/crates/registry-breg/tests/native_source_conventions.rs @@ -901,7 +901,7 @@ fn duplicate_presentation_text_warns_in_each_breg_namespace() { "/manifestProjection/distributions/1/title", ), ( - "breg.manifest-entity.duplicate-title", + "breg.manifest-record-type.duplicate-title", "/manifestProjection/entities/1/title", ), ( diff --git a/products/breg/CHANGELOG.md b/products/breg/CHANGELOG.md index 7a8d3970f5..238c3ac4a3 100644 --- a/products/breg/CHANGELOG.md +++ b/products/breg/CHANGELOG.md @@ -2,6 +2,17 @@ ## Unreleased +- BREAKING: BReg authoring diagnostics use Record type codes. Migration: update diagnostic code matchers using these mappings. + + - `breg.manifest.entity-id-collision` → `breg.manifest.record-type-id-collision` + - `breg.manifest-entity.duplicate-title` → `breg.manifest-record-type.duplicate-title` + - `breg.manifest-projection.entity-primary-dataset-required` → `breg.manifest-projection.record-type-primary-dataset-required` + - `breg.manifest-projection.entity-dataset-dangling` → `breg.manifest-projection.record-type-dataset-dangling` + - `breg.manifest-projection.dataset-entities-empty` → `breg.manifest-projection.dataset-record-types-empty` + - `breg.manifest-projection.entity-duplicate` → `breg.manifest-projection.record-type-duplicate` + - `breg.manifest-projection.entity-not-visible` → `breg.manifest-projection.record-type-not-visible` + - `breg.access.membership-entity-unknown` → `breg.access.membership-record-type-unknown` + - BREAKING: Runtime and migration PostgreSQL URLs with `sslmode=require` or `sslmode=verify-full` are refused under a plaintext transport. Set `database.transport` to `verified-tls` to use TLS, or remove `sslmode` from From aa518673fb1d7660221cc903e03aeb20ffcba3bd Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:33:39 +0000 Subject: [PATCH 05/96] test(breg): verify TLS attachment staging cancellation Signed-off-by: Jeremi Joslin --- .../src/postgres/cancellation.rs | 117 ++++++++++++++++++ products/breg/scripts/test-postgres-tls.sh | 2 +- products/breg/scripts/validate_product.py | 4 +- 3 files changed, 120 insertions(+), 3 deletions(-) diff --git a/crates/registry-breg/src/postgres/cancellation.rs b/crates/registry-breg/src/postgres/cancellation.rs index f538c31823..d78d7cdfe7 100644 --- a/crates/registry-breg/src/postgres/cancellation.rs +++ b/crates/registry-breg/src/postgres/cancellation.rs @@ -186,3 +186,120 @@ impl Drop for AttachmentStagingGuard { } } } + +#[cfg(all(test, feature = "postgres-tls-test"))] +mod tests { + use std::{env, fs, future::poll_fn, pin::pin}; + + use futures_core::Stream; + use tokio::time::{sleep, timeout}; + use tokio_postgres::{error::SqlState, SimpleQueryMessage}; + + use super::*; + use crate::postgres::{ConnectionConfig, PoolBounds}; + + const STATEMENT: &str = "SELECT 1 FROM pg_catalog.pg_sleep(30)"; + + async fn tls_backend_pid(client: &Client) -> i32 { + let row = client + .query_one( + "SELECT pid, ssl FROM pg_catalog.pg_stat_ssl WHERE pid = pg_backend_pid()", + &[], + ) + .await + .unwrap_or_else(|_| panic!("read TLS state for this backend")); + assert!(row.get::<_, bool>(1), "the staging backend must use TLS"); + row.get(0) + } + + #[tokio::test] + async fn verified_tls_attachment_staging_cancels_on_drop() { + let url = env::var("BREG_TEST_TLS_DATABASE_URL").expect("TLS fixture URL is required"); + let ca_path = env::var("BREG_TEST_TLS_CA_DER_PATH").expect("TLS fixture CA is required"); + let ca = fs::read(ca_path).unwrap_or_else(|_| panic!("read the TLS fixture CA")); + let connection_bound = Duration::from_secs(3); + let bounds = PoolBounds::new(1, connection_bound, connection_bound, connection_bound) + .expect("valid fixture connection bounds"); + let pool = ConnectionConfig::require_tls_with_custom_ca(&url, &ca, bounds) + .expect("configure verified TLS with the fixture CA") + .build_pool() + .expect("build the fixture pool"); + + timeout(Duration::from_secs(10), async { + let observer = pool + .get() + .await + .unwrap_or_else(|_| panic!("open the observer session")); + let mut staging = pool + .attachment_staging_connection() + .await + .unwrap_or_else(|_| panic!("open staging while the pool is full")); + tls_backend_pid(staging.client()).await; + staging.disarm(); + + let mut staging = pool + .attachment_staging_connection() + .await + .unwrap_or_else(|_| panic!("reacquire staging after disarm")); + let staging_pid = tls_backend_pid(staging.client()).await; + staging + .client() + .batch_execute("SET statement_timeout = 0") + .await + .unwrap_or_else(|_| panic!("disable the fixture's statement timeout")); + // Queue the statement without waiting for a server response. Keep + // its stream to read the result after dropping the guard. + let mut rows = pin!(staging + .client() + .simple_query_raw(STATEMENT) + .await + .unwrap_or_else(|_| panic!("start the test-owned statement"))); + timeout(connection_bound, async { + loop { + let waiting = observer + .query_one( + "SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_stat_activity + WHERE pid = $1 AND state = 'active' AND query = $2 + AND wait_event_type = 'Timeout' AND wait_event = 'PgSleep')", + &[&staging_pid, &STATEMENT], + ) + .await + .unwrap_or_else(|_| panic!("observe the test-owned statement")) + .get::<_, bool>(0); + if waiting { + break; + } + sleep(Duration::from_millis(20)).await; + } + }) + .await + .expect("the test-owned statement must reach its wait before cancellation"); + drop(staging); + let result = match poll_fn(|cx| rows.as_mut().poll_next(cx)).await { + Some(Ok(SimpleQueryMessage::RowDescription(_))) => { + poll_fn(|cx| rows.as_mut().poll_next(cx)).await + } + result => result, + }; + let Some(Err(error)) = result else { + panic!("the test-owned statement must report cancellation"); + }; + assert!( + error.code() == Some(&SqlState::QUERY_CANCELED), + "the server must report SQLSTATE 57014 for the cancelled statement" + ); + + let mut replacement = pool + .attachment_staging_connection() + .await + .unwrap_or_else(|_| panic!("reacquire staging after discard")); + assert!( + tls_backend_pid(replacement.client()).await != staging_pid, + "reacquired staging must use a fresh backend" + ); + replacement.disarm(); + }) + .await + .expect("the staging TLS proof must finish within ten seconds"); + } +} diff --git a/products/breg/scripts/test-postgres-tls.sh b/products/breg/scripts/test-postgres-tls.sh index 7923162dd5..a6bf71147c 100755 --- a/products/breg/scripts/test-postgres-tls.sh +++ b/products/breg/scripts/test-postgres-tls.sh @@ -176,4 +176,4 @@ export CARGO_PROFILE_DEV_DEBUG=0 export CARGO_PROFILE_TEST_DEBUG=0 export RUSTC_WRAPPER= -cargo test --locked -p registry-breg --features postgres-tls-test --test postgres_tls +cargo test --locked -p registry-breg --features postgres-tls-test --lib --test postgres_tls diff --git a/products/breg/scripts/validate_product.py b/products/breg/scripts/validate_product.py index 8b8a0336d9..ce82b32fca 100644 --- a/products/breg/scripts/validate_product.py +++ b/products/breg/scripts/validate_product.py @@ -208,7 +208,7 @@ "cargo test --locked -p registry-breg --features postgres-test,tooling,schema --test postgres_startup", ) POSTGRES_TLS_ENTRYPOINT = PRODUCT_ROOT / "scripts/test-postgres-tls.sh" -POSTGRES_TLS_TEST_COMMAND = "cargo test --locked -p registry-breg --features postgres-tls-test --test postgres_tls" +POSTGRES_TLS_TEST_COMMAND = "cargo test --locked -p registry-breg --features postgres-tls-test --lib --test postgres_tls" CI_WORKFLOW = REPOSITORY_ROOT / ".github/workflows/ci.yml" @@ -683,7 +683,7 @@ def validate_postgres_tls_entrypoint(errors: list[str]) -> None: errors.append("PostgreSQL TLS entrypoint: temporary cleanup must be limited to /tmp") cargo_commands = [line.strip() for line in source.splitlines() if line.lstrip().startswith("cargo ")] if cargo_commands != [POSTGRES_TLS_TEST_COMMAND]: - errors.append("PostgreSQL TLS entrypoint: must run exactly the owned locked postgres_tls command") + errors.append("PostgreSQL TLS entrypoint: must run exactly the locked library and postgres_tls targets") if not CI_WORKFLOW.is_file(): errors.append("PostgreSQL TLS entrypoint: CI workflow is missing") return From 10f67a40cce8d55aab639187710c37f3097f5952 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:17:36 +0000 Subject: [PATCH 06/96] fix(breg): enforce reference target authority on direct writes Provisional authored source for the protected v0.52 replay. Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/access.rs | 94 +++- crates/registry-breg/src/api/context.rs | 121 +++- crates/registry-breg/src/api/ingestion.rs | 479 +++++++++++----- crates/registry-breg/src/api/mod.rs | 112 +++- crates/registry-breg/src/artifacts.rs | 5 + crates/registry-breg/src/compiler.rs | 74 ++- .../src/compiler/disclosure/reach.rs | 11 +- crates/registry-breg/src/contract.rs | 4 + crates/registry-breg/src/fixtures.rs | 1 + crates/registry-breg/src/generated_ddl.rs | 15 +- crates/registry-breg/src/membership.rs | 1 + crates/registry-breg/src/mutation.rs | 42 ++ .../src/mutation/reference_reach.rs | 103 ++++ crates/registry-breg/src/odrl_export.rs | 1 + crates/registry-breg/src/postgres/context.rs | 35 ++ crates/registry-breg/src/postgres/mutation.rs | 109 ++++ crates/registry-breg/src/postgres/read.rs | 99 ++-- crates/registry-breg/tests/consent_access.rs | 49 +- .../registry-breg/tests/disclosure_compile.rs | 37 ++ crates/registry-breg/tests/http_read_only.rs | 1 + .../tests/membership_authoring.rs | 8 + .../tests/postgres_client_relationships.rs | 23 +- .../tests/postgres_consent_examples.rs | 65 +++ .../tests/postgres_hook_changes.rs | 36 +- .../tests/postgres_ingestion_runs.rs | 99 ++++ .../tests/postgres_proposal_security.rs | 6 +- .../tests/postgres_record_timers.rs | 61 +- .../tests/postgres_reference_integrity.rs | 53 +- .../tests/reference_authority_authoring.rs | 343 +++++++++++ .../registry-breg/tests/steward_authoring.rs | 6 +- .../tests/support/membership_targets.rs | 12 +- .../support/membership_write_journeys.rs | 532 ++++++++++++++++++ .../tests/support/membership_write_project.rs | 17 + .../src/consent_module/profiles.yaml | 5 + crates/registry-bregctl/src/lib.rs | 1 + .../content/docs/configure/breg-access.mdx | 67 ++- .../content/docs/configure/breg-consent.mdx | 4 +- docs/site/src/content/docs/configure/breg.mdx | 2 +- .../src/content/docs/reference/breg-api.mdx | 18 +- docs/site/src/content/docs/security/breg.mdx | 48 +- products/breg/CHANGELOG.md | 3 + .../contracts/security-invariant-matrix.yaml | 1 + .../contracts/security-test-traceability.yaml | 1 + .../consent-land-registry/registry.yaml | 8 + .../consent-person-registry/registry.yaml | 4 + .../breg/scripts/test_validate_product.py | 2 +- products/breg/scripts/validate_product.py | 2 +- 47 files changed, 2539 insertions(+), 281 deletions(-) create mode 100644 crates/registry-breg/src/mutation/reference_reach.rs create mode 100644 crates/registry-breg/tests/reference_authority_authoring.rs diff --git a/crates/registry-breg/src/access.rs b/crates/registry-breg/src/access.rs index 97768a6f33..d090730762 100644 --- a/crates/registry-breg/src/access.rs +++ b/crates/registry-breg/src/access.rs @@ -109,6 +109,76 @@ pub(crate) fn validate_access_requirements( } } +/// A direct write that sets a reference field must name a record the same +/// profile can read. Without a `get` or `reference` grant on the target +/// Record type every such write would be refused at run time, so the grant +/// is required here. A `reference` grant serves nothing else, so one that no +/// write of its profile uses is refused too. +pub(crate) fn validate_reference_targets( + entities: &BTreeMap, + errors: &mut Vec, +) { + let mut named = BTreeSet::new(); + for entity in entities.values() { + for grant in &entity.access_profiles { + if !grant.operations.iter().any(|operation| { + matches!( + operation, + Operation::Create | Operation::Patch | Operation::Batch | Operation::Import + ) + }) { + continue; + } + for field_id in &grant.writable_fields { + let Some(crate::contract::FieldTypeSource::Reference { target, .. }) = entity + .fields + .iter() + .find(|field| field.id == *field_id) + .map(|field| &field.field_type) + else { + continue; + }; + // An unknown target has its own diagnostic. + let Some(target) = entities.get(target) else { + continue; + }; + named.insert((target.id.as_str(), grant.id.as_str())); + let readable = target.access_profiles.iter().any(|candidate| { + candidate.id == grant.id + && (candidate.operations.contains(&Operation::Get) + || candidate.operations.contains(&Operation::Reference)) + }); + if !readable { + errors.push(Diagnostic::error( + "breg.access.reference-target-ungranted", + format!( + "recordTypes[id={}].accessProfiles[id={}].writableFields[field={field_id}]", + entity.id, grant.id + ), + "a direct write names a referenced record only if the same profile can read it; grant this profile get, or reference to name records without reading them, on the referenced Record type, bounded to the records it may name", + )); + } + } + } + } + for entity in entities.values() { + for grant in &entity.access_profiles { + if grant.operations.contains(&Operation::Reference) + && !named.contains(&(entity.id.as_str(), grant.id.as_str())) + { + errors.push(Diagnostic::error( + "breg.access.reference-grant-unused", + format!( + "recordTypes[id={}].accessProfiles[id={}].operations", + entity.id, grant.id + ), + "no direct write of this profile names a record of this Record type, so the reference grant admits nothing; remove it, or make the profile's reference field to this Record type writable", + )); + } + } + } +} + pub(crate) fn check_profile( requirements: &AccessRequirementsSource, profile: &AccessProfileSource, @@ -172,10 +242,14 @@ pub(crate) fn access_findings(entities: &BTreeMap) -> Vec< findings.push(Diagnostic::finding("breg.access.profile-unrestricted-collection", format!("{path}.rowBoundaries"), "this profile lists rows without claim-bound or membership restrictions; configured consent and other disclosure checks still apply. Caller filters are not authorization. Review this broad access and restrict the profile to intended callers. Statistical release publishers require unrestricted reads of their dataset dependencies")); } + // A reference grant serves no read: an unrestricted one lets the + // profile's writes name any active record, as every write could + // before writes checked their references. if entity.classification != Classification::Public && profile.row_boundaries.is_empty() && profile.membership_boundaries.is_empty() && !profile.operations.contains(&Operation::List) + && !profile.operations.contains(&Operation::Reference) && !caller_is_bounded { findings.push(Diagnostic::finding("breg.access.profile-unrestricted-rows", format!("{path}.rowBoundaries"), @@ -629,13 +703,16 @@ fn ungated_client_findings(entity: &CompiledEntity, findings: &mut Vec>() .join(", "); for profile in entity.access_profiles.values() { - // A create answers with the row the caller just wrote, and an action - // target only lets the action reference a row, so neither reads an - // existing row without consent. - let reads_existing_rows = profile - .operations - .iter() - .any(|operation| !matches!(operation, Operation::Create | Operation::Invoke)); + // A create answers with the row the caller just wrote, an action + // target only lets the action reference a row, and a reference grant + // only lets a direct write name one, so none reads an existing row + // without consent. + let reads_existing_rows = profile.operations.iter().any(|operation| { + !matches!( + operation, + Operation::Create | Operation::Invoke | Operation::Reference + ) + }); if profile.readable_fields.is_empty() || !reads_existing_rows || !crate::consent::requirements(entity, &profile.id).is_empty() @@ -1052,7 +1129,8 @@ fn row_reach( | Operation::Revisions | Operation::Snapshot | Operation::Invoke - | Operation::Start => "existing_target", + | Operation::Start + | Operation::Reference => "existing_target", }, operation: use_.operation, source: use_.source.clone(), diff --git a/crates/registry-breg/src/api/context.rs b/crates/registry-breg/src/api/context.rs index 56930ef8ee..50c664a1bd 100644 --- a/crates/registry-breg/src/api/context.rs +++ b/crates/registry-breg/src/api/context.rs @@ -411,6 +411,15 @@ impl VerifiedRowBoundary { } } + #[cfg(test)] + pub(crate) fn equals_for_test(field: &str, value: &str) -> Self { + Self::new( + field.to_owned(), + RowBoundaryOperator::Equals, + BTreeSet::from([value.to_owned()]), + ) + } + #[must_use] pub fn field(&self) -> &str { &self.field @@ -462,9 +471,34 @@ pub struct AuthorizedRequestContext { human_identity: Option, recipients: BTreeSet, caller_issuer: Option, + /// The caller's context on each Record type a direct write may reference. + reference_contexts: Vec<(String, AuthorizedRequestContext)>, + /// Proof for the target grants. The reason text is retained only when the + /// written type's own grant calls for it. + reference_reason_validated: bool, } impl AuthorizedRequestContext { + pub(crate) fn with_reference_context( + mut self, + entity_id: &str, + context: AuthorizedRequestContext, + ) -> Self { + self.reference_contexts + .push((entity_id.to_owned(), context)); + self + } + + /// A target whose reason requirement was not met has no usable context. + /// This also covers operations such as Import that do not bind the header. + pub(crate) fn reference_contexts( + &self, + ) -> impl Iterator { + self.reference_contexts.iter().filter(|(_, reference)| { + !reference.requires_access_reason || self.reference_reason_validated + }) + } + pub(crate) fn new( principal: Option, purpose: Option, @@ -485,6 +519,8 @@ impl AuthorizedRequestContext { human_identity: None, recipients: BTreeSet::new(), caller_issuer: None, + reference_contexts: Vec::new(), + reference_reason_validated: false, } } @@ -548,19 +584,39 @@ impl AuthorizedRequestContext { self.bind_access_reason(headers) } - /// Validate only the access reason, for surfaces that never log reads. + /// Bind the reason to the route grant and any reference-target grants. + /// A refusal by the route grant is a request error. A refusal by a target + /// grant leaves that type unavailable if the write tries to reference it. pub(crate) fn bind_access_reason( &mut self, headers: &axum::http::HeaderMap, ) -> Result<(), AccessBindingRefusal> { - if self.requires_access_reason { - self.access_reason = Some( - crate::subject_access_log::access_reason(headers) - .map_err(|()| AccessBindingRefusal::ReasonRequired)?, - ); - } + self.access_reason = self.validate_access_reason(headers)?; Ok(()) } + + /// Validate the reason and admit eligible target contexts. Return reason + /// text only for a route grant that requires it, so callers without + /// subject access logging can discard it before reaching storage. + pub(crate) fn validate_access_reason( + &mut self, + headers: &axum::http::HeaderMap, + ) -> Result, AccessBindingRefusal> { + let target_requires_reason = self + .reference_contexts + .iter() + .any(|(_, reference)| reference.requires_access_reason); + if self.requires_access_reason || target_requires_reason { + let reason = crate::subject_access_log::access_reason(headers); + self.reference_reason_validated = reason.is_ok(); + if self.requires_access_reason { + return reason + .map(Some) + .map_err(|()| AccessBindingRefusal::ReasonRequired); + } + } + Ok(None) + } pub(crate) fn audit_context(&self) -> Option<&crate::audit::RequestAuditContext> { self.audit_context.as_ref() } @@ -760,6 +816,57 @@ fn validate_value(value: String) -> Result { mod tests { use super::*; + #[test] + fn a_reference_context_requires_its_own_access_reason() { + use crate::subject_access_log::ACCESS_REASON_HEADER; + use axum::http::{HeaderMap, HeaderValue}; + + let context = || { + AuthorizedRequestContext::new( + Some("caller".to_owned()), + None, + "writer".to_owned(), + Vec::new(), + ) + }; + let mut write = context() + .with_reference_context("open-target", context()) + .with_reference_context( + "reason-target", + context().with_access_reason_requirement(true), + ); + let reached = |context: &AuthorizedRequestContext| { + context + .reference_contexts() + .map(|(target, _)| target.clone()) + .collect::>() + }; + + // Import carries the admitted context without binding access reasons. + assert_eq!(reached(&write), ["open-target"]); + + let mut headers = HeaderMap::new(); + write.bind_access_reason(&headers).unwrap(); + assert_eq!(reached(&write), ["open-target"]); + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("bad!")); + write.bind_access_reason(&headers).unwrap(); + assert_eq!(reached(&write), ["open-target"]); + + let mut required_write = write.clone().with_access_reason_requirement(true); + assert_eq!( + required_write.bind_access_reason(&headers), + Err(AccessBindingRefusal::ReasonRequired) + ); + + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("cmV2aWV3")); + write.bind_access_reason(&headers).unwrap(); + assert_eq!(reached(&write), ["open-target", "reason-target"]); + assert_eq!(write.access_reason(), None); + required_write.bind_access_reason(&headers).unwrap(); + assert_eq!(reached(&required_write), ["open-target", "reason-target"]); + assert_eq!(required_write.access_reason(), Some("review")); + } + #[test] fn authenticated_context_preserves_identity_values_larger_than_review_protocol_bounds() { let identity = registry_review_client::HumanIdentity { diff --git a/crates/registry-breg/src/api/ingestion.rs b/crates/registry-breg/src/api/ingestion.rs index 2e7557230a..7546df70e3 100644 --- a/crates/registry-breg/src/api/ingestion.rs +++ b/crates/registry-breg/src/api/ingestion.rs @@ -92,6 +92,64 @@ pub(super) fn routes(service: &HttpService) -> Router> { app } +async fn admit_ingestion<'a>( + service: &'a HttpService, + mutations: &crate::postgres::PostgresRecordMutationService, + route: &'a CompiledRoute, + claims: &VerifiedRequestClaims, + options: &QueryOptions, + headers: &HeaderMap, + correlation: &RequestCorrelation, +) -> Result, Response> { + let mut surface = match authorize_route_with_reason(service, route, claims, options) { + Ok(surface) => surface, + Err(RouteAdmissionError::Ambiguous(profiles)) => { + return Err(crate::correlation::ambiguous_access_profile_response( + profiles, + )); + } + Err(RouteAdmissionError::Refused(refusal)) => { + return Err(audited_mutation_admission_refusal( + mutations, + route, + options, + claims, + None, + correlation, + refusal.check, + ) + .await); + } + }; + if let Err(refusal) = + validate_ingestion_access_reason(route.operation, &mut surface.context, headers) + { + return Err(audited_mutation_refusal( + mutations, + route, + &surface.context, + None, + access_binding_refusal(refusal), + correlation, + ) + .await); + } + Ok(surface) +} + +fn validate_ingestion_access_reason( + bulk: Operation, + context: &mut AuthorizedRequestContext, + headers: &HeaderMap, +) -> Result<(), context::AccessBindingRefusal> { + // Import grants cannot require a reason and do not supply one for + // reference probes. Batch validates it without retaining the text. + if bulk == Operation::Batch { + drop(context.validate_access_reason(headers)?); + } + Ok(()) +} + #[allow(clippy::too_many_arguments)] // Axum extractors are the HTTP contract. async fn create_run( State(service): State>, @@ -117,23 +175,19 @@ async fn create_run( ) .await; }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &options) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &options, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &options, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; if headers.contains_key("idempotency-key") { return audited_mutation_refusal( @@ -208,6 +262,7 @@ async fn list_runs( Extension(correlation): Extension, Authenticated(claims): Authenticated, RawQuery(raw_query): RawQuery, + headers: HeaderMap, ) -> Response { let Some(mutations) = &service.mutations else { return concealed(FailedCheck::Visibility); @@ -227,23 +282,19 @@ async fn list_runs( .await; } }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &admission) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &admission, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &admission, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; let query = match parse_list_query(raw_query.as_deref()) { Ok(query) => query, @@ -281,6 +332,7 @@ async fn read_run( Authenticated(claims): Authenticated, RawQuery(raw_query): RawQuery, Path(path): Path>, + headers: HeaderMap, ) -> Response { let Some(mutations) = &service.mutations else { return concealed(FailedCheck::Visibility); @@ -297,23 +349,19 @@ async fn read_run( ) .await; }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &options) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &options, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &options, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; let Some(run_id) = path_run_id(&path) else { return audited_mutation_refusal( @@ -361,23 +409,19 @@ async fn cancel_run( ) .await; }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &options) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &options, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &options, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; if headers.contains_key("idempotency-key") { return audited_mutation_refusal( @@ -477,23 +521,19 @@ async fn submit_chunk( ) .await; }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &options) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &options, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &options, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; // The chunk items are the batch items of the compiled route, so the // entity must carry a batch surface at all. @@ -617,6 +657,7 @@ async fn chunk_receipt( Authenticated(claims): Authenticated, RawQuery(raw_query): RawQuery, Path(path): Path>, + headers: HeaderMap, ) -> Response { let Some(mutations) = &service.mutations else { return concealed(FailedCheck::Visibility); @@ -633,23 +674,19 @@ async fn chunk_receipt( ) .await; }; - let surface = match authorize_route_with_reason(&service, &binding.base, &claims, &options) { + let surface = match admit_ingestion( + &service, + mutations, + &binding.base, + &claims, + &options, + &headers, + &correlation, + ) + .await + { Ok(surface) => surface, - Err(RouteAdmissionError::Ambiguous(profiles)) => { - return crate::correlation::ambiguous_access_profile_response(profiles); - } - Err(RouteAdmissionError::Refused(refusal)) => { - return audited_mutation_admission_refusal( - mutations, - &binding.base, - &options, - &claims, - None, - &correlation, - refusal.check, - ) - .await; - } + Err(response) => return response, }; let Some(run_id) = path_run_id(&path) else { return audited_mutation_refusal( @@ -1112,14 +1149,10 @@ pub(super) fn import_surfaces<'a>( /// caller that holds the batch or import operation under the selected profile /// and answers with a principal, and they never appear in `/v1/registry`. pub(super) fn append_openapi( - service: &HttpService, surfaces: &[AuthorizedSurface<'_>], paths: &mut Map, schemas: &mut Map, ) { - if service.mutations.is_none() { - return; - } let mut advertised = false; for surface in surfaces.iter().filter(|surface| { matches!( @@ -1132,6 +1165,17 @@ pub(super) fn append_openapi( continue; }; let profile = &surface.entity.access_profiles[surface.context.selected_profile()]; + let through_batch = surface.route.operation == Operation::Batch; + let requires_reason = through_batch && profile.require_access_reason; + let parameters = |mut parameters: Vec, supplies_target_reason| { + if through_batch && (requires_reason || supplies_target_reason) { + parameters.push(access_reason_parameter(requires_reason)); + } + parameters + }; + let responses = |status, schema, operation: IngestionApiOperation| { + ingestion_responses(status, schema, operation.problem_codes(), requires_reason) + }; let input_schema_id = crate::artifacts::openapi_input_schema_id(&surface.entity.id, surface.route.operation); // The batch input schema is collected from the visible routes; an @@ -1166,15 +1210,15 @@ pub(super) fn append_openapi( "x-registry-operation": "ingestionCreateRun", "security": [{"bearerAuth": []}], "x-registry-accessProfile": surface.context.selected_profile(), - "parameters": [access_profile_parameter()], + "parameters": parameters(vec![access_profile_parameter()], false), "requestBody": { "required": true, "content": {"application/json": {"schema": create_run_schema()}} }, - "responses": ingestion_responses( + "responses": responses( "201", create_run_answer(), - IngestionApiOperation::CreateRun.problem_codes(), + IngestionApiOperation::CreateRun, ), }), ); @@ -1186,9 +1230,9 @@ pub(super) fn append_openapi( "x-registry-operation": "ingestionListRuns", "security": [{"bearerAuth": []}], "x-registry-accessProfile": surface.context.selected_profile(), - "parameters": [ + "parameters": parameters(vec![ access_profile_parameter(), - { + json!({ "name": "limit", "in": "query", "required": false, @@ -1199,15 +1243,15 @@ pub(super) fn append_openapi( "maximum": crate::ingestion_store::MAX_RUN_PAGE_SIZE, "default": crate::ingestion_store::DEFAULT_RUN_PAGE_SIZE } - }, - { + }), + json!({ "name": "cursor", "in": "query", "required": false, "description": "The keyset cursor: only runs ordered before this run id.", "schema": {"type": "string", "format": "uuid"} - }, - { + }), + json!({ "name": "status", "in": "query", "required": false, @@ -1216,19 +1260,19 @@ pub(super) fn append_openapi( "type": "string", "enum": ["open", "complete", "cancelled", "blocked"] } - }, - { + }), + json!({ "name": "inputDigest", "in": "query", "required": false, "description": "Only runs announced with this input digest.", "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"} - } - ], - "responses": ingestion_responses( + }) + ], false), + "responses": responses( "200", list_runs_answer(), - IngestionApiOperation::ListRuns.problem_codes(), + IngestionApiOperation::ListRuns, ), }), ); @@ -1245,11 +1289,11 @@ pub(super) fn append_openapi( "x-registry-operation": "ingestionReadRun", "security": [{"bearerAuth": []}], "x-registry-accessProfile": surface.context.selected_profile(), - "parameters": [access_profile_parameter(), run_id_parameter()], - "responses": ingestion_responses( + "parameters": parameters(vec![access_profile_parameter(), run_id_parameter()], false), + "responses": responses( "200", run_answer(), - IngestionApiOperation::ReadRun.problem_codes(), + IngestionApiOperation::ReadRun, ), }), ); @@ -1268,7 +1312,7 @@ pub(super) fn append_openapi( "x-registry-accessProfile": surface.context.selected_profile(), "x-registry-maximumItems": batch.maximum_items, "x-registry-maximumBytes": batch.maximum_bytes, - "parameters": [access_profile_parameter(), run_id_parameter()], + "parameters": parameters(vec![access_profile_parameter(), run_id_parameter()], true), "requestBody": { "required": true, "content": { @@ -1282,7 +1326,7 @@ pub(super) fn append_openapi( } } }, - "responses": ingestion_responses( + "responses": responses( "200", json!({ "type": "object", @@ -1295,7 +1339,7 @@ pub(super) fn append_openapi( } } }), - IngestionApiOperation::SubmitChunk.problem_codes(), + IngestionApiOperation::SubmitChunk, ), }), ); @@ -1312,11 +1356,11 @@ pub(super) fn append_openapi( "x-registry-operation": "ingestionCancelRun", "security": [{"bearerAuth": []}], "x-registry-accessProfile": surface.context.selected_profile(), - "parameters": [access_profile_parameter(), run_id_parameter()], - "responses": ingestion_responses( + "parameters": parameters(vec![access_profile_parameter(), run_id_parameter()], false), + "responses": responses( "200", run_answer(), - IngestionApiOperation::CancelRun.problem_codes(), + IngestionApiOperation::CancelRun, ), }), ); @@ -1333,20 +1377,20 @@ pub(super) fn append_openapi( "x-registry-operation": "ingestionChunkReceipt", "security": [{"bearerAuth": []}], "x-registry-accessProfile": surface.context.selected_profile(), - "parameters": [ + "parameters": parameters(vec![ access_profile_parameter(), run_id_parameter(), - { + json!({ "name": "chunk_index", "in": "path", "required": true, "schema": {"type": "integer", "minimum": 0} - } - ], - "responses": ingestion_responses( + }) + ], false), + "responses": responses( "200", json!({"$ref": "#/components/schemas/IngestionChunkReceipt"}), - IngestionApiOperation::ChunkReceipt.problem_codes(), + IngestionApiOperation::ChunkReceipt, ), }), ); @@ -1361,6 +1405,16 @@ pub(super) fn append_openapi( } } +fn access_reason_parameter(required: bool) -> Value { + json!({ + "name": "Registry-Access-Reason", + "in": "header", + "required": required, + "description": "The access reason as unpadded base64url UTF-8. A Batch chunk also needs it to name a reference whose target grant requires a reason.", + "schema": {"type": "string", "minLength": 1, "maxLength": 684, "pattern": "^[A-Za-z0-9_-]+$"} + }) +} + fn access_profile_parameter() -> Value { json!({ "name": "accessProfile", @@ -1419,7 +1473,8 @@ fn list_runs_answer() -> Value { fn ingestion_responses( success_status: &str, success_schema: Value, - problems: &[crate::problem::ProblemCode], + problems: &[ProblemCode], + requires_reason: bool, ) -> Value { let mut responses = Map::from_iter([( success_status.to_owned(), @@ -1441,6 +1496,8 @@ fn ingestion_responses( for status in [400u16, 401, 403, 404, 409, 410, 412, 415, 503] { let codes = problems .iter() + .copied() + .chain(requires_reason.then_some(ProblemCode::RequestAccessReasonRequired)) .filter(|code| code.status() == status) .collect::>(); if codes.is_empty() { @@ -1630,6 +1687,165 @@ fn ingestion_chunk_receipt_schema() -> Value { #[cfg(test)] mod tests { use super::*; + use crate::subject_access_log::ACCESS_REASON_HEADER; + use context::AccessBindingRefusal; + + fn operator_context(requires_reason: bool) -> AuthorizedRequestContext { + AuthorizedRequestContext::new( + Some("operator".to_owned()), + None, + "operator".to_owned(), + vec![], + ) + .with_access_reason_requirement(requires_reason) + } + + #[test] + fn batch_ingestion_requires_a_valid_reason_when_its_grant_does() { + let mut batch = operator_context(true); + let mut headers = HeaderMap::new(); + for value in [None, Some("!")] { + if let Some(value) = value { + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static(value)); + } + assert_eq!( + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers), + Err(AccessBindingRefusal::ReasonRequired) + ); + } + + let valid = HeaderValue::from_static("cmV2aWV3"); + headers.insert(ACCESS_REASON_HEADER, valid.clone()); + headers.append(ACCESS_REASON_HEADER, valid.clone()); + assert_eq!( + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers), + Err(AccessBindingRefusal::ReasonRequired) + ); + headers.insert(ACCESS_REASON_HEADER, valid); + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers).unwrap(); + assert_eq!(batch.access_reason(), None); + } + + #[test] + fn only_batch_ingestion_can_supply_a_targets_required_reason() { + let ordinary = operator_context(false) + .with_reference_context("open", operator_context(false)) + .with_reference_context("restricted", operator_context(true)); + let mut batch = ordinary.clone(); + let targets = |context: &AuthorizedRequestContext| { + context + .reference_contexts() + .map(|(target, _)| target.clone()) + .collect::>() + }; + let mut headers = HeaderMap::new(); + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers).unwrap(); + assert_eq!(targets(&batch), ["open"]); + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("!")); + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers).unwrap(); + assert_eq!(targets(&batch), ["open"]); + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("cmV2aWV3")); + validate_ingestion_access_reason(Operation::Batch, &mut batch, &headers).unwrap(); + assert_eq!(targets(&batch), ["open", "restricted"]); + assert_eq!(batch.access_reason(), None); + + let mut import = ordinary; + validate_ingestion_access_reason(Operation::Import, &mut import, &headers).unwrap(); + assert_eq!(targets(&import), ["open"]); + assert_eq!(import.access_reason(), None); + } + + #[test] + fn ingestion_openapi_publishes_the_selected_grants_reason_precondition() { + for (bulk, operations, requires_reason) in [ + (Operation::Batch, json!(["create", "get", "batch"]), true), + (Operation::Batch, json!(["create", "get", "batch"]), false), + (Operation::Import, json!(["import"]), false), + ] { + let source = json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1", + "kind":"BRegProject", + "project":{"id":"ingestion-contract","version":"1","defaultLanguage":"en","canonicalBaseIri":"https://authoring.example.test"}, + "datasets":{"entries":{}}, + "recordTypes":{"entry":{ + "primaryDataset":"entries","route":"entries","mutationMode":"mutable","classification":"internal", + "batch":{"maximumItems":3,"maximumBytes":4096}, + "fields":[{"id":"label","type":"string","maximumLength":64,"classification":"internal"}] + }}, + "accessProfiles":{"operator":{ + "default":true,"principalClaim":"sub","requiredScopes":["records:write"], + "requireAccessReason":requires_reason, + "permissions":{"records":[{ + "recordType":"entry","operations":operations,"writableFields":["label"], + "rowBoundaries":"unrestricted" + }]} + }} + }); + let project = + crate::contract::parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); + let registry = crate::compiler::compile_project( + &project, + &[], + crate::compiler::CompileProfile::Authoring, + ) + .unwrap(); + let entity = ®istry.entities()["entry"]; + let route = crate::data::ingestion_route(®istry, "entry", "operator").unwrap(); + assert_eq!(route.operation, bulk); + let surface = AuthorizedSurface { + route, + entity, + response_entity: entity, + context: operator_context(requires_reason), + readable_fields: BTreeSet::new(), + read_path: None, + admitted_profiles: vec!["operator".to_owned()], + }; + let mut paths = Map::new(); + append_openapi(&[surface], &mut paths, &mut Map::new()); + let entries: Vec<_> = paths + .values() + .flat_map(|methods| methods.as_object().unwrap().values()) + .collect(); + assert_eq!(entries.len(), IngestionApiOperation::ALL.len()); + for entry in entries { + let is_chunk = entry["x-registry-operation"] == "ingestionSubmitChunk"; + let header = entry["parameters"] + .as_array() + .unwrap() + .iter() + .find(|parameter| parameter["name"] == "Registry-Access-Reason"); + assert_eq!( + header.map(|header| ( + header["in"].as_str().unwrap(), + header["required"].as_bool().unwrap() + )), + (bulk == Operation::Batch && (requires_reason || is_chunk)) + .then_some(("header", requires_reason)) + ); + let problem = &entry["responses"]["400"]["content"]["application/problem+json"] + ["examples"]["request.access-reason-required"]["value"]; + assert_eq!( + problem["code"].as_str(), + requires_reason.then_some("request.access-reason-required") + ); + if requires_reason { + assert_eq!(problem["status"], 400); + assert!(problem.get("fieldPath").is_none()); + } + } + } + } + + #[tokio::test] + async fn an_ingestion_reference_precondition_keeps_its_opaque_problem() { + let response = ingestion_problem(IngestionServiceError::PreconditionFailed); + assert_eq!(response.status(), StatusCode::PRECONDITION_FAILED); + let body = to_bytes(response.into_body(), 4096).await.unwrap(); + let problem: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!(problem["code"], "precondition.failed"); + assert!(problem.get("fieldPath").is_none()); + } #[test] fn ingestion_openapi_401_declares_www_authenticate_bearer() { @@ -1637,6 +1853,7 @@ mod tests { "201", json!({"description": "Created"}), &[ProblemCode::AuthenticationRefused], + false, ); let header = &responses["401"]["headers"]["WWW-Authenticate"]; assert_eq!(header, &crate::artifacts::bearer_challenge_header()); diff --git a/crates/registry-breg/src/api/mod.rs b/crates/registry-breg/src/api/mod.rs index 45edd583b2..0a793c8d39 100644 --- a/crates/registry-breg/src/api/mod.rs +++ b/crates/registry-breg/src/api/mod.rs @@ -643,8 +643,10 @@ async fn openapi( if service.review_completions.is_some() { crate::artifacts::append_review_completion_openapi(&mut paths, &mut schemas); } - ingestion::append_openapi(&service, &visible, &mut paths, &mut schemas); - ingestion::append_openapi(&service, &imports, &mut paths, &mut schemas); + if service.mutations.is_some() { + ingestion::append_openapi(&visible, &mut paths, &mut schemas); + ingestion::append_openapi(&imports, &mut paths, &mut schemas); + } Json(json!({ "openapi": "3.1.0", "info": {"title": service.registry.registry_id(), "version": service.registry.version()}, @@ -3164,6 +3166,14 @@ fn authorize_direct_route_mode<'a>( .with_audit_context(claims) .with_recipients(claims) .with_access_reason_requirement(profile.require_access_reason); + let context = if matches!( + route.operation, + Operation::Create | Operation::Patch | Operation::Batch | Operation::Import + ) { + with_reference_contexts(service, context, claims, entity) + } else { + context + }; Ok(AuthorizedSurface { route, entity, @@ -3247,6 +3257,87 @@ fn authorize_read_path_route_mode<'a>( ) } +/// A direct write names a referenced record only if the caller can read it. +/// Resolve the caller's context on each Record type this one references, as +/// that type's `get` route would, or under the profile's `reference` grant +/// there, so the write can check each record it names. A type the caller +/// cannot read gets no context, and naming one of its records is refused. +fn with_reference_contexts( + service: &HttpService, + mut context: AuthorizedRequestContext, + claims: &VerifiedRequestClaims, + entity: &crate::model::CompiledEntity, +) -> AuthorizedRequestContext { + let targets = entity + .fields + .values() + .filter_map(|field| match &field.field_type { + crate::contract::FieldTypeSource::Reference { target, .. } => Some(target.as_str()), + _ => None, + }) + .collect::>(); + for target in targets { + let reference_grant = service + .registry + .entities() + .get(target) + .and_then(|entity| entity.access_profiles.get(context.selected_profile())) + .filter(|profile| profile.operations.contains(&Operation::Reference)); + let authorized = if let Some(profile) = reference_grant { + reference_grant_context(profile, claims) + } else { + let Some(route) = service.registry.routes().routes.iter().find(|route| { + route.entity_id == target + && route.operation == Operation::Get + && route.method == crate::model::HttpMethod::Get + }) else { + continue; + }; + let mut options = QueryOptions::default(); + options.parsed.access_profile = Some(context.selected_profile().to_owned()); + authorize_direct_route_mode(service, route, claims, &options, false) + .map(|surface| surface.context) + .map_err(drop) + }; + match authorized { + Ok(reference) => context = context.with_reference_context(target, reference), + // Without a context every reference to this type answers as a + // missing record would, so say why without naming any record. + Err(_) => tracing::warn!( + reason = "reference-target-unauthorized", + record_type = target, + access_profile = context.selected_profile(), + "this profile cannot read the referenced Record type under these claims, so a direct write naming one of its records answers as if the record were missing" + ), + } + } + context +} + +/// The caller's context under a `reference` grant, admitted as an explicit +/// selection of its profile on a route would be: the token reaches the +/// profile and carries the claims its row boundaries and task grant need. +/// The grant has no route, so no route lookup or field selection applies. +fn reference_grant_context( + profile: &AccessProfileSource, + claims: &VerifiedRequestClaims, +) -> Result { + if !claims.reaches_profile(&profile.id) { + return Err(()); + } + let row_boundaries = authorize_profile_claims(profile, claims).map_err(drop)?; + Ok(AuthorizedRequestContext::new( + claims.principal().map(str::to_owned), + claims.purpose().map(str::to_owned), + profile.id.clone(), + row_boundaries, + ) + .with_task_grant(task_grant_binding(profile, claims).map_err(drop)?) + .with_audit_context(claims) + .with_recipients(claims) + .with_access_reason_requirement(profile.require_access_reason)) +} + fn access_entry_for_route<'a>( service: &'a HttpService, route: &CompiledRoute, @@ -3283,8 +3374,9 @@ fn read_path_for_route<'a>( fn served_operation(service: &HttpService, route: &CompiledRoute) -> bool { match route.operation { // The ingestion-run surface serves an import grant; the route itself - // is never mounted and never listed as an operation. - Operation::Invoke | Operation::Start | Operation::Import => false, + // is never mounted and never listed as an operation. A reference + // grant has no route. + Operation::Invoke | Operation::Start | Operation::Import | Operation::Reference => false, Operation::Get | Operation::List => true, Operation::Lookup => true, Operation::Create => service.mutations.is_some(), @@ -5448,6 +5540,7 @@ fn operation_name(operation: Operation) -> &'static str { Operation::Snapshot => "snapshot", Operation::Import => "import", Operation::Start => "start", + Operation::Reference => "reference", } } @@ -6891,6 +6984,17 @@ mod refusal_check_tests { use super::*; use registry_platform_authcommon::RefusalNote; + #[tokio::test] + async fn a_direct_reference_conflict_keeps_its_opaque_problem() { + let response = mutation_problem(MutationError::Conflict); + assert_eq!(response.status(), StatusCode::CONFLICT); + assert_eq!(noted(&response), None); + let body = to_bytes(response.into_body(), 4096).await.unwrap(); + let problem: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!(problem["code"], "mutation.conflict"); + assert!(problem.get("fieldPath").is_none()); + } + fn noted(response: &Response) -> Option { response .extensions() diff --git a/crates/registry-breg/src/artifacts.rs b/crates/registry-breg/src/artifacts.rs index ecdbab4f59..4f882a410b 100644 --- a/crates/registry-breg/src/artifacts.rs +++ b/crates/registry-breg/src/artifacts.rs @@ -3333,6 +3333,7 @@ fn operation_response_shape(spec: OpenApiOperationSpec<'_>) -> &'static str { Operation::Import => { unreachable!("import routes are served only by the ingestion-run surface") } + Operation::Reference => unreachable!("a reference grant has no route"), } } @@ -3431,6 +3432,7 @@ fn operation_parameters( Operation::Import => { unreachable!("import routes are served only by the ingestion-run surface") } + Operation::Reference => unreachable!("a reference grant has no route"), } parameters } @@ -3639,6 +3641,7 @@ fn operation_request_body(spec: OpenApiOperationSpec<'_>) -> Option { Operation::Import => { unreachable!("import routes are served only by the ingestion-run surface") } + Operation::Reference => unreachable!("a reference grant has no route"), } } @@ -3891,6 +3894,7 @@ fn operation_responses(spec: OpenApiOperationSpec<'_>) -> Value { Operation::Import => { unreachable!("import routes are served only by the ingestion-run surface") } + Operation::Reference => unreachable!("a reference grant has no route"), Operation::Invoke | Operation::Start => success_response( "Action accepted", StatusResponseHeaders::ActionMutation, @@ -5358,6 +5362,7 @@ pub(crate) fn operation_name(operation: Operation) -> &'static str { Operation::Invoke => "invoke", Operation::Start => "start", Operation::Import => "import", + Operation::Reference => "reference", } } diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index eb25b942b4..6f0e2ecd6a 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -119,9 +119,8 @@ pub const HOOK_BACKOFF_MULTIPLIER: u8 = 2; /// ingestion errors map onto, and the shared admission envelope every /// secured route answers with (the bearer refusal, the authorization /// concealment, and the audit-gated unavailability). The OpenAPI builder -/// publishes exactly these sets, and the ingestion contract test holds the -/// published document to them, so the catalogue cannot drift from what the -/// routes can actually answer. +/// publishes these sets and adds the reason refusal for Batch grants that +/// require it. The ingestion contract tests hold the document to both rules. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum IngestionApiOperation { CreateRun, @@ -157,7 +156,7 @@ impl IngestionApiOperation { } } - /// Every problem response the operation can answer with. + /// The problem responses independent of the selected grant's reason requirement. #[must_use] pub const fn problem_codes(self) -> &'static [crate::problem::ProblemCode] { match self { @@ -340,6 +339,7 @@ pub fn compile_project_with_assets( &mut diagnostics, ); crate::access::validate_access_requirements(&sources, &mut diagnostics); + crate::access::validate_reference_targets(&sources, &mut diagnostics); crate::membership::validate(project, &action_sources, &sources, &mut diagnostics); crate::proposal_subject::validate_field_writes( project, @@ -6060,6 +6060,60 @@ fn reaches<'a>( /// the entity: a batch grant would write the same records outside any import /// authority, leaving the authority bounding nothing. The creator a run is /// scoped to is the principal claim every profile names. +/// Whether a `reference` grant carries only what it may: the operation, the +/// rows it may name (row boundaries and membership entries), and the members +/// its profile sets for every grant. Every member is named, so a member added +/// later must be placed on one side before this compiles. +fn reference_grant_is_bare(access: &AccessProfileSource) -> bool { + let AccessProfileSource { + // Profile members, the same on every grant of the profile. + id: _, + display: _, + default: _, + actor_kind: _, + requester_clients: _, + task_grant: _, + principal_claim: _, + required_scopes: _, + required_purposes: _, + require_access_reason: _, + // The rows a write may name. + row_boundaries: _, + membership_boundaries: _, + operations, + // Everything below serves or shapes a read or a write. + readable_fields, + readable_attachments, + writable_fields, + filterable_fields, + required_filters, + sortable_fields, + spatial_queries, + require_consent, + lookups, + read_paths, + allow_count, + revision_access, + provenance_fields, + allow_data_export, + } = access; + operations.len() == 1 + && readable_fields.is_empty() + && readable_attachments.is_empty() + && writable_fields.is_empty() + && filterable_fields.is_empty() + && required_filters.is_empty() + && sortable_fields.is_empty() + && spatial_queries.is_none() + && require_consent.is_empty() + && lookups.is_empty() + && read_paths.is_empty() + && !allow_count + && !revision_access + && provenance_fields.is_empty() + && !allow_data_export +} + fn validate_import_grant( entity: &EntitySource, access: &AccessProfileSource, @@ -6149,6 +6203,16 @@ fn validate_profiles( if access.operations.contains(&Operation::Import) { validate_import_grant(entity, access, errors); } + if access.operations.contains(&Operation::Reference) && !reference_grant_is_bare(access) { + errors.push(Diagnostic::error( + "breg.access-profile.reference-exclusive", + format!( + "recordTypes[id={}].accessProfiles[id={}].operations", + entity.id, access.id + ), + "a reference grant lets the profile's direct writes name records of this Record type and nothing else: grant no other operation, field, read path, lookup, filter, count, revision, export or spatial access beside it", + )); + } if access.operations.contains(&Operation::Batch) && !access .operations @@ -9435,6 +9499,7 @@ fn route_shape(entity: &CompiledEntity, operation: Operation) -> (HttpMethod, St Operation::Invoke | Operation::Start => { unreachable!("Actions use compiled action metadata") } + Operation::Reference => unreachable!("a reference grant has no route"), } } @@ -9495,6 +9560,7 @@ pub(crate) fn operation_id(operation: Operation) -> &'static str { Operation::Invoke => "invoke", Operation::Start => "start", Operation::Import => "import", + Operation::Reference => "reference", } } diff --git a/crates/registry-breg/src/compiler/disclosure/reach.rs b/crates/registry-breg/src/compiler/disclosure/reach.rs index 7aeb530aaf..20bd2c26b3 100644 --- a/crates/registry-breg/src/compiler/disclosure/reach.rs +++ b/crates/registry-breg/src/compiler/disclosure/reach.rs @@ -586,7 +586,9 @@ fn reads_derived_from( ) } -/// The profile's grant on `source`, when it reads rows. +/// The profile's grant on `source`, when it reads rows. A reference grant +/// holds the row policy only for a write's reach check and reads no field, +/// so derived SQL needs a grant that reads. fn reading_grant<'a>( source: &'a EntitySource, reader: &DerivedReader<'_>, @@ -595,7 +597,12 @@ fn reading_grant<'a>( .access_profiles .iter() .find(|grant| grant.id == reader.request_grant.id) - .filter(|grant| crate::generated_ddl::grant_reads_rows(grant.operations.as_set())) + .filter(|grant| { + crate::generated_ddl::grant_reads_rows(grant.operations.as_set()) + && !grant + .operations + .contains(&crate::contract::Operation::Reference) + }) } fn backticked(values: impl IntoIterator + Ord>) -> String { diff --git a/crates/registry-breg/src/contract.rs b/crates/registry-breg/src/contract.rs index 85fcdb0425..b8e73b38da 100644 --- a/crates/registry-breg/src/contract.rs +++ b/crates/registry-breg/src/contract.rs @@ -5647,6 +5647,10 @@ pub enum Operation { /// for the entity and profile. It declares no item route and no raw batch /// route, and change control does not count it as a direct write. Import, + /// Let the profile's direct writes name records of this Record type, and + /// nothing else. A write naming a record reads it under this grant's row + /// reach; the grant serves no route and reads no field. + Reference, } #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] diff --git a/crates/registry-breg/src/fixtures.rs b/crates/registry-breg/src/fixtures.rs index 4791310536..bca5e40b8c 100644 --- a/crates/registry-breg/src/fixtures.rs +++ b/crates/registry-breg/src/fixtures.rs @@ -6628,6 +6628,7 @@ fn operation_method(operation: Operation) -> HttpMethod { } Operation::Patch => HttpMethod::Patch, Operation::Tombstone => HttpMethod::Delete, + Operation::Reference => unreachable!("a fixture step never names a reference grant"), } } diff --git a/crates/registry-breg/src/generated_ddl.rs b/crates/registry-breg/src/generated_ddl.rs index 5f5e3c631b..7d0633c44c 100644 --- a/crates/registry-breg/src/generated_ddl.rs +++ b/crates/registry-breg/src/generated_ddl.rs @@ -26,6 +26,7 @@ use crate::physical_names::{ const RECORD_ID_COLUMN: &str = "record_id"; const GENERATED_TEXT_COLLATION: &str = "pg_catalog.pg_c_utf8"; +pub(crate) const REFERENCE_PROBE_ENTITY_SETTING: &str = "registry.reference_probe_entity"; pub(crate) const REFERENCE_LIFECYCLE_COLUMN: &str = "record_reference_lifecycle"; /// The schema the generated spatial SQL reads PostGIS from. pub const POSTGIS_EXTENSION_SCHEMA: &str = "registry_spatial_ext"; @@ -1545,6 +1546,7 @@ fn runtime_privileges( | Operation::Batch | Operation::Revisions | Operation::Snapshot + | Operation::Reference ) }) || path_select_entities(entities).contains(&entity.id) || membership_probes @@ -1608,7 +1610,15 @@ fn policies( if !profile_supports_command(&profile.operations, command) { continue; } - let authority = policy_authority_expression(entity, profile); + let mut authority = policy_authority_expression(entity, profile); + if command == PolicyCommand::Select + && profile.operations.contains(&Operation::Reference) + { + authority = format!( + "({authority}) AND current_setting('{REFERENCE_PROBE_ENTITY_SETTING}', true) = {}", + quote_literal(&entity.id), + ); + } let (using_expression, check_expression) = match command { PolicyCommand::Select => ( Some(format!("({authority}) AND (record_lifecycle = 'active')")), @@ -1913,6 +1923,8 @@ fn profile_inserts(operations: &BTreeSet) -> bool { fn profile_supports_command(operations: &BTreeSet, command: PolicyCommand) -> bool { match command { + // A reference grant serves no read route, but a direct write naming a + // record reads it under this policy to check the caller's reach. PolicyCommand::Select => operations.iter().any(|operation| { matches!( operation, @@ -1922,6 +1934,7 @@ fn profile_supports_command(operations: &BTreeSet, command: PolicyCom | Operation::Batch | Operation::Revisions | Operation::Snapshot + | Operation::Reference ) }), PolicyCommand::Insert => profile_inserts(operations), diff --git a/crates/registry-breg/src/membership.rs b/crates/registry-breg/src/membership.rs index f36b822e3c..ea76478a21 100644 --- a/crates/registry-breg/src/membership.rs +++ b/crates/registry-breg/src/membership.rs @@ -73,6 +73,7 @@ pub(crate) fn validate( | Operation::Tombstone | Operation::Batch | Operation::Import + | Operation::Reference ) }) || (!profile.writable_fields.is_empty() && !writes diff --git a/crates/registry-breg/src/mutation.rs b/crates/registry-breg/src/mutation.rs index a8da49bc37..f2bbd8fa78 100644 --- a/crates/registry-breg/src/mutation.rs +++ b/crates/registry-breg/src/mutation.rs @@ -8,6 +8,7 @@ pub(crate) use action::erase_expired_action_evidence; pub(crate) use action::validate_action_attachments; pub(crate) use action::{HookChangeApplication, HookChangeOutcome}; mod membership; +mod reference_reach; pub(crate) use membership::probe_action_memberships; use membership::RecordMembership; mod proposal; @@ -383,6 +384,9 @@ pub struct MutationPlan { /// as a direct write: an operator-opened import authority bounds it. imported_item: bool, external_refresh_enabled: bool, + /// The physical table of each Record type a reference field of this + /// Record type names, for the referenced-record read check. + reference_tables: BTreeMap, } impl MutationPlan { @@ -435,6 +439,22 @@ impl MutationPlan { return Err(MutationError::InvalidRequest); } let event_deliveries = exact_entity_event_deliveries(registry, entity)?; + let reference_tables = entity + .fields + .values() + .filter_map(|field| match &field.field_type { + crate::contract::FieldTypeSource::Reference { target, .. } => Some(target), + _ => None, + }) + .map(|target| { + registry + .entities() + .get(target) + .filter(|target| valid_physical_identifier(&target.physical_table)) + .map(|target| (target.id.clone(), target.physical_table.clone())) + .ok_or(MutationError::InvalidRequest) + }) + .collect::, _>>()?; let temporal_exclusion_constraints = temporal_exclusion_constraints(registry, entity, inventory)?; Ok(Self { @@ -446,6 +466,7 @@ impl MutationPlan { temporal_exclusion_constraints, imported_item: false, external_refresh_enabled: crate::postgres::external_projection::enabled(registry), + reference_tables, }) } @@ -509,6 +530,7 @@ impl MutationPlan { temporal_exclusion_constraints: self.temporal_exclusion_constraints.clone(), imported_item: self.route.operation == Operation::Import, external_refresh_enabled: self.external_refresh_enabled, + reference_tables: self.reference_tables.clone(), }) } } @@ -1344,6 +1366,16 @@ impl MutationTransaction { membership.as_ref(), ) .await?; + // After the row's own authorisation and foreign keys, before commit: + // a refusal here rolls the write back, and the earlier answers keep + // their precedence. + reference_reach::require_readable_references( + transaction.transaction(), + request.plan, + request.claims, + &reference_reach::set_references(&request.plan.entity, &request.body)?, + ) + .await?; stage_record_timer_rows( transaction.transaction(), timer_staging.as_ref(), @@ -1998,6 +2030,16 @@ impl MutationTransaction { membership.as_ref(), ) .await?; + // At this item, as for a single write: a missing or tombstoned + // reference fails at this item's row, so an unreadable one must + // fail here too, before any later item can answer instead. + reference_reach::require_readable_references( + transaction.transaction(), + request.plan, + request.claims, + &reference_reach::set_references(&request.plan.entity, &item_request.body)?, + ) + .await?; if let Some(membership) = &mut membership { membership.record_batch_write(¤t); } diff --git a/crates/registry-breg/src/mutation/reference_reach.rs b/crates/registry-breg/src/mutation/reference_reach.rs new file mode 100644 index 0000000000..63bed4aacc --- /dev/null +++ b/crates/registry-breg/src/mutation/reference_reach.rs @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A direct write that sets a reference field must name a record the caller +//! can read now, as an Action's reference targets must. The check reads the +//! referenced row under the caller's own row security for that Record type, +//! inside the write transaction. A record the caller cannot read answers as a +//! missing one does. + +use super::*; +use crate::contract::FieldTypeSource; +use crate::generated_ddl::REFERENCE_PROBE_ENTITY_SETTING; + +/// The references a body sets: every non-null reference value of a create, +/// and each reference a patch adds or replaces. Unchanged stored references +/// are not rechecked. +pub(super) fn set_references( + entity: &CompiledEntity, + body: &MutationBody, +) -> Result, MutationError> { + let target = |field: &str| match entity.fields.get(field).map(|field| &field.field_type) { + Some(FieldTypeSource::Reference { target, .. }) => Some(target.clone()), + _ => None, + }; + let key = |value: &Value| value.as_str().and_then(|value| Uuid::parse_str(value).ok()); + let mut references = Vec::new(); + match body { + MutationBody::Create(data) => { + for (field, value) in data { + if let (Some(target), Some(id)) = (target(field), key(value)) { + references.push((target, id)); + } + } + } + MutationBody::Patch(operations) => { + for operation in operations { + if let PatchOperation::Add { path, value } + | PatchOperation::Replace { path, value } = operation + { + if let (Some(target), Some(id)) = (target(&patch_field(path)?), key(value)) { + references.push((target, id)); + } + } + } + } + MutationBody::Tombstone => {} + } + Ok(references) +} + +/// Refuse a write naming a record the caller cannot read now. The answer is +/// the one a missing or tombstoned record gets from the reference's foreign +/// key, so the three cannot be told apart. Deduplicate within this item only. +/// Later items must check against the transaction state at their own write. +pub(super) async fn require_readable_references( + transaction: &Transaction<'_>, + plan: &MutationPlan, + claims: &ClaimContext, + references: &[(String, Uuid)], +) -> Result<(), MutationError> { + let mut by_target = BTreeMap::<&str, BTreeSet>::new(); + for (target, id) in references { + by_target.entry(target).or_default().insert(*id); + } + for (target, ids) in by_target { + let table = plan + .reference_tables + .get(target) + .ok_or(MutationError::Unavailable)?; + let Some(boundaries) = claims.reference_row_boundaries(target) else { + return Err(MutationError::Conflict); + }; + let install_context = format!( + "SELECT set_config('registry.row_boundaries', $1, true), + set_config('{REFERENCE_PROBE_ENTITY_SETTING}', $2, true)" + ); + transaction + .execute(&install_context, &[&boundaries, &target]) + .await + .map_err(map_database_error)?; + let ids = ids.into_iter().collect::>(); + let readable = transaction + .query_one( + &format!( + "SELECT count(*) FROM registry_data.{} WHERE record_id = ANY($1)", + quote_identifier(table) + ), + &[&ids], + ) + .await + .map_err(map_database_error)?; + // Close the probe and restore the written Record type's boundaries + // before any further work. A SQL failure aborts the transaction. + transaction + .execute(&install_context, &[&claims.canonical_row_boundaries(), &""]) + .await + .map_err(map_database_error)?; + let readable = readable.try_get::<_, i64>(0).map_err(map_database_error)?; + if usize::try_from(readable).ok() != Some(ids.len()) { + return Err(MutationError::Conflict); + } + } + Ok(()) +} diff --git a/crates/registry-breg/src/odrl_export.rs b/crates/registry-breg/src/odrl_export.rs index cd537817bd..3ab54752e8 100644 --- a/crates/registry-breg/src/odrl_export.rs +++ b/crates/registry-breg/src/odrl_export.rs @@ -389,6 +389,7 @@ fn operation_name(operation: Operation) -> &'static str { Operation::Invoke => "invoke", Operation::Start => "start", Operation::Import => "import", + Operation::Reference => "reference", } } diff --git a/crates/registry-breg/src/postgres/context.rs b/crates/registry-breg/src/postgres/context.rs index 720847b318..c10f77ae80 100644 --- a/crates/registry-breg/src/postgres/context.rs +++ b/crates/registry-breg/src/postgres/context.rs @@ -351,6 +351,9 @@ pub struct ClaimContext { recipients: BTreeSet, write_attribution: Option, caller_issuer: Option, + /// The caller's canonical row boundaries for each Record type a direct + /// write may reference, resolved from the same verified claims. + reference_row_boundaries: BTreeMap, } #[derive(Clone, Debug, Eq, PartialEq)] @@ -446,6 +449,36 @@ impl ClaimContext { &self.recipients } + /// Add the caller's context for a Record type this write may reference. + /// It must be the same caller: principal, profile and purpose match. + pub fn with_reference_context(mut self, reference: &ClaimContext) -> Result { + if reference.principal != self.principal + || reference.access_profile != self.access_profile + || reference.purpose != self.purpose + { + return Err(invalid_context()); + } + self.reference_row_boundaries.insert( + reference.entity_id.clone(), + reference.canonical_row_boundaries.clone(), + ); + Ok(self) + } + + /// The caller's canonical row boundaries on an explicitly admitted + /// reference target, including when it is the written Record type. + #[must_use] + pub fn reference_row_boundaries(&self, entity_id: &str) -> Option<&str> { + self.reference_row_boundaries + .get(entity_id) + .map(String::as_str) + } + + #[must_use] + pub fn canonical_row_boundaries(&self) -> &str { + &self.canonical_row_boundaries + } + pub(crate) fn with_task_grant( mut self, grant: crate::task_grant::TaskGrantBinding, @@ -540,6 +573,7 @@ impl ClaimContext { recipients: BTreeSet::new(), write_attribution: None, caller_issuer: None, + reference_row_boundaries: BTreeMap::new(), }) } @@ -576,6 +610,7 @@ impl ClaimContext { recipients: BTreeSet::new(), write_attribution: None, caller_issuer: None, + reference_row_boundaries: BTreeMap::new(), }) } diff --git a/crates/registry-breg/src/postgres/mutation.rs b/crates/registry-breg/src/postgres/mutation.rs index 8b23538705..255742087c 100644 --- a/crates/registry-breg/src/postgres/mutation.rs +++ b/crates/registry-breg/src/postgres/mutation.rs @@ -2551,6 +2551,20 @@ fn strict_claim_context( None => Ok(claims), }) .map_err(|_| MutationError::InvalidRequest) + .and_then(|claims| { + context + .reference_contexts() + // A target claim that fails this type's compiled boundary makes + // that type unavailable. Only a reference to it is refused. + .filter_map(|(target, reference)| { + strict_claim_context(registry, reference, target).ok() + }) + .try_fold(claims, |claims, reference| { + claims + .with_reference_context(&reference) + .map_err(|_| MutationError::InvalidRequest) + }) + }) } /// The claim context of a direct Create, Patch, Batch or Tombstone, which @@ -2742,6 +2756,101 @@ mod ingestion_context_tests { .expect("the fixture context is exact") } + #[test] + fn a_same_type_probe_requires_an_admitted_target_context() { + use crate::subject_access_log::ACCESS_REASON_HEADER; + use axum::http::{HeaderMap, HeaderValue}; + + let project = parse_project_json(CONTEXT_FIXTURE.as_bytes()).unwrap(); + let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); + let context = AuthorizedRequestContext::new( + Some("agent".to_owned()), + Some("review".to_owned()), + "operator".to_owned(), + vec![VerifiedRowBoundary::equals_for_test("tenant", "tenant-a")], + ) + .with_access_reason_requirement(true); + let mut write = context + .clone() + .with_reference_context("entry", context.clone()); + let check = |context: &AuthorizedRequestContext, expected| { + let claims = strict_claim_context(®istry, context, "entry").unwrap(); + assert!(!claims.row_boundaries().is_empty()); + assert_eq!(claims.reference_row_boundaries("entry"), expected); + }; + + let mut headers = HeaderMap::new(); + assert!(write.bind_access_reason(&headers).is_err()); + check(&write, None); + + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("!")); + assert!(write.bind_access_reason(&headers).is_err()); + check(&write, None); + + headers.insert(ACCESS_REASON_HEADER, HeaderValue::from_static("cmV2aWV3")); + let mut absent_target = context; + absent_target.bind_access_reason(&headers).unwrap(); + check(&absent_target, None); + + write.bind_access_reason(&headers).unwrap(); + let boundaries = fixture_claims(); + check(&write, Some(boundaries.canonical_row_boundaries())); + } + + #[test] + fn an_invalid_target_context_does_not_invalidate_other_record_types() { + let mut project: Value = serde_json::from_str(CONTEXT_FIXTURE).unwrap(); + project["recordTypes"]["source"] = json!({ + "primaryDataset":"test-dataset","route":"sources","mutationMode":"mutable", + "classification":"internal","fields":[ + {"id":"entry","type":"reference","target":"entry","classification":"internal"}, + {"id":"related","type":"reference","target":"related","classification":"internal"} + ] + }); + project["recordTypes"]["related"] = project["recordTypes"]["entry"].clone(); + project["recordTypes"]["related"]["route"] = json!("related"); + project["recordTypes"]["entry"]["fields"][0]["maximumLength"] = json!(4); + project["accessProfiles"]["operator"]["requiredScopes"] = json!(["records:write"]); + project["accessProfiles"]["operator"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .extend([ + json!({"recordType":"source","operations":["create"], + "writableFields":["entry","related"],"rowBoundaries":"unrestricted"}), + json!({"recordType":"related","operations":["reference"], + "rowBoundaries":"unrestricted"}), + ]); + let project = parse_project_json(&serde_json::to_vec(&project).unwrap()).unwrap(); + let registry = compile_project(&project, &[], CompileProfile::Authoring) + .expect("the reference project compiles"); + let context = |row_boundaries| { + AuthorizedRequestContext::new( + Some("agent".to_owned()), + Some("review".to_owned()), + "operator".to_owned(), + row_boundaries, + ) + }; + let entry = |tenant| context(vec![VerifiedRowBoundary::equals_for_test("tenant", tenant)]); + + // The claim has the expected cardinality, but exceeds this type's + // field bound. Validation of the written type must still be strict. + assert!(strict_claim_context(®istry, &entry("area"), "entry").is_ok()); + assert!(matches!( + strict_claim_context(®istry, &entry("tenant-a"), "entry"), + Err(MutationError::InvalidRequest) + )); + + let write = context(Vec::new()) + .with_reference_context("entry", entry("tenant-a")) + .with_reference_context("related", context(Vec::new())); + let claims = strict_claim_context(®istry, &write, "source") + .expect("an unavailable target is local to references to that type"); + assert_eq!(claims.reference_row_boundaries("entry"), None); + assert_eq!(claims.reference_row_boundaries("related"), Some("[]")); + assert_eq!(claims.canonical_row_boundaries(), "[]"); + } + fn grant(id: &str) -> TaskGrantBinding { serde_json::from_value(json!({ "grantId": id, diff --git a/crates/registry-breg/src/postgres/read.rs b/crates/registry-breg/src/postgres/read.rs index 69aee6af38..1865f57aef 100644 --- a/crates/registry-breg/src/postgres/read.rs +++ b/crates/registry-breg/src/postgres/read.rs @@ -462,7 +462,15 @@ impl PostgresRecordReadService { .through_entity .as_ref() .ok_or(ReadServiceError::Unavailable)?; - ReadRelations::relationship(&plan.source_entity, through, &plan.entity, path, root_id)? + ReadRelations::relationship( + &plan.source_entity, + through, + &plan.entity, + path, + root_id, + query, + &selected_fields, + )? } else { ReadRelations::collection(&plan.entity, query, &selected_fields)? }; @@ -2072,13 +2080,13 @@ fn parse_rfc3339_utc(value: &str) -> Result( +fn required_derived_relations<'a>( entity: &'a CompiledEntity, query: Option<&crate::api::CompiledReadQuery>, selected_fields: &[String], @@ -2120,6 +2128,38 @@ fn collect_filter_fields<'a>(filter: &'a ReadFilterExpr, fields: &mut BTreeSet<& } } +fn join_derived_relations( + from_sql: &mut String, + entity: &CompiledEntity, + id_expression: &str, + query: Option<&crate::api::CompiledReadQuery>, + selected_fields: &[String], +) -> Result, ReadServiceError> { + let mut derived_aliases = BTreeMap::new(); + let required_relations = required_derived_relations(entity, query, selected_fields); + for (index, relation) in entity + .derived_relations + .values() + .filter(|relation| required_relations.contains(relation.id.as_str())) + .enumerate() + { + let alias = format!("derived_{index}"); + let view_name = + crate::generated_ddl::derived_view_name(&entity.source_relation.sql_name, &relation.id); + if !valid_physical_identifier(&view_name) { + return Err(ReadServiceError::Unavailable); + } + from_sql.push_str(&format!( + " LEFT JOIN registry_derived.{} AS {alias} + ON {alias}.{} = {id_expression}", + quote_identifier(&view_name), + quote_identifier(&entity.canonical_id.sql_name), + )); + derived_aliases.insert(relation.id.clone(), alias); + } + Ok(derived_aliases) +} + pub(crate) struct ReadRelations { pub(crate) base_alias: &'static str, pub(crate) source_alias: &'static str, @@ -2143,7 +2183,6 @@ impl ReadRelations { { return Err(ReadServiceError::Unavailable); } - let mut derived_aliases = BTreeMap::new(); let id_expression = format!( "{source_alias}.{}", quote_identifier(&entity.canonical_id.sql_name) @@ -2166,29 +2205,13 @@ impl ReadRelations { quote_identifier(&candidate_view), )); } - let required_relations = collection_derived_relations(entity, query, selected_fields); - for (index, relation) in entity - .derived_relations - .values() - .filter(|relation| required_relations.contains(relation.id.as_str())) - .enumerate() - { - let alias = format!("derived_{index}"); - let view_name = crate::generated_ddl::derived_view_name( - &entity.source_relation.sql_name, - &relation.id, - ); - if !valid_physical_identifier(&view_name) { - return Err(ReadServiceError::Unavailable); - } - from_sql.push_str(&format!( - " LEFT JOIN registry_derived.{} AS {alias} - ON {alias}.{} = {id_expression}", - quote_identifier(&view_name), - quote_identifier(&entity.canonical_id.sql_name), - )); - derived_aliases.insert(relation.id.clone(), alias); - } + let derived_aliases = join_derived_relations( + &mut from_sql, + entity, + &id_expression, + query, + selected_fields, + )?; Ok(Self { base_alias, source_alias, @@ -2212,6 +2235,8 @@ impl ReadRelations { target: &CompiledEntity, path: &CompiledReadPath, root_id: &str, + query: Option<&crate::api::CompiledReadQuery>, + selected_fields: &[String], ) -> Result { if !valid_canonical_uuid(root_id) { return Err(ReadServiceError::Unavailable); @@ -2252,24 +2277,8 @@ impl ReadRelations { quote_identifier(&target.source_relation.sql_name), quote_identifier(&target.physical_table), ); - let mut derived_aliases = BTreeMap::new(); - for (index, relation) in target.derived_relations.values().enumerate() { - let alias = format!("derived_{index}"); - let view_name = crate::generated_ddl::derived_view_name( - &target.source_relation.sql_name, - &relation.id, - ); - if !valid_physical_identifier(&view_name) { - return Err(ReadServiceError::Unavailable); - } - from_sql.push_str(&format!( - " LEFT JOIN registry_derived.{} AS {alias} - ON {alias}.{} = {target_id}", - quote_identifier(&view_name), - quote_identifier(&target.canonical_id.sql_name), - )); - derived_aliases.insert(relation.id.clone(), alias); - } + let derived_aliases = + join_derived_relations(&mut from_sql, target, &target_id, query, selected_fields)?; Ok(Self { base_alias, source_alias, diff --git a/crates/registry-breg/tests/consent_access.rs b/crates/registry-breg/tests/consent_access.rs index 8c62320169..7a57c875ed 100644 --- a/crates/registry-breg/tests/consent_access.rs +++ b/crates/registry-breg/tests/consent_access.rs @@ -1548,9 +1548,34 @@ fn a_profile_that_only_writes_or_invokes_on_a_gated_entity_is_not_an_ungated_cli .collect::>() }; // A create response echoes only the row the caller just wrote, so a - // create-only permission reads no existing row without consent. + // create-only permission reads no existing row without consent. Naming a + // person or an enrolment in a write needs a read of it, so the create-only + // steward writes persons, and names neither persons nor enrolments. + let create_only_steward = |project: &mut Value| { + let records = project["accessProfiles"][STEWARD]["permissions"]["records"] + .as_array_mut() + .unwrap(); + records.retain(|permission| permission["recordType"] != "enrolment"); + for permission in records.iter_mut() { + if permission["recordType"] == "person" { + permission["operations"] = json!(["create"]); + } + if permission["recordType"] == "household-member" + || permission["recordType"] == "enrolment-household" + { + permission["operations"] = json!(["get"]); + permission.as_object_mut().unwrap().remove("writableFields"); + } + } + }; let mut create_only = source(); - for permission in create_only["accessProfiles"][STEWARD]["permissions"]["records"] + create_only_steward(&mut create_only); + assert_eq!(findings(&create_only), Vec::::new()); + + // A create-only enrolment names a person, so the steward needs a read of + // persons, which the gated person grant answers only with consent. + let mut create_only_enrolment = source(); + for permission in create_only_enrolment["accessProfiles"][STEWARD]["permissions"]["records"] .as_array_mut() .unwrap() { @@ -1558,7 +1583,16 @@ fn a_profile_that_only_writes_or_invokes_on_a_gated_entity_is_not_an_ungated_cli permission["operations"] = json!(["create"]); } } - assert_eq!(findings(&create_only), Vec::::new()); + let refused = compile(&create_only_enrolment).expect_err("naming a person needs a read of it"); + assert!( + refused.diagnostics().iter().any(|diagnostic| { + diagnostic.code == "breg.access.reference-target-ungranted" + && diagnostic.path + == "recordTypes[id=enrolment].accessProfiles[id=steward].writableFields[field=person]" + }), + "{:?}", + refused.diagnostics() + ); // A patch answers with an existing row, so it still reads without consent. let mut patching = create_only.clone(); @@ -1578,13 +1612,6 @@ fn a_profile_that_only_writes_or_invokes_on_a_gated_entity_is_not_an_ungated_cli // An action target with empty row boundaries on the gated entity only // lets the action reference a row; it reads nothing through the profile. let mut self_issued = self_issued_project(); - for permission in self_issued["accessProfiles"][STEWARD]["permissions"]["records"] - .as_array_mut() - .unwrap() - { - if permission["recordType"] == "person" || permission["recordType"] == "enrolment" { - permission["operations"] = json!(["create"]); - } - } + create_only_steward(&mut self_issued); assert_eq!(findings(&self_issued), Vec::::new()); } diff --git a/crates/registry-breg/tests/disclosure_compile.rs b/crates/registry-breg/tests/disclosure_compile.rs index acda3dfc5c..66ac5d40b3 100644 --- a/crates/registry-breg/tests/disclosure_compile.rs +++ b/crates/registry-breg/tests/disclosure_compile.rs @@ -1361,6 +1361,43 @@ fn a_derived_field_cannot_read_a_record_type_its_reader_cannot_read() { assert!(codes(compile_with_sql(&value, VISIT_SQL)).contains(&UNREADABLE_SOURCE.to_owned())); } +#[test] +fn a_reference_grant_does_not_let_a_derived_field_read_its_record_type() { + // A reference grant only lets the profile's writes name records. It reads + // no field, so a derived field computed over that type still needs a + // grant that reads it. + let with_grant = |operations: Value| { + let mut value = visit_source(); + value["recordTypes"]["person"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"last-visit","type":"reference","target":"visit","classification":"internal"})); + // A writing profile admits only callers with its scope. + value["accessProfiles"][REGISTRAR]["requiredScopes"] = json!(["people:write"]); + let person = person_permission(&mut value, REGISTRAR); + person["operations"] = json!(["get", "list", "patch"]); + person["writableFields"] = json!(["last-visit"]); + let mut grant = json!({"recordType":"visit","operations":operations, + "rowBoundaries":"unrestricted","readableFields":[]}); + if grant["operations"] == json!(["get"]) { + grant["readableFields"] = json!(["person"]); + } + value["accessProfiles"][REGISTRAR]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push(grant); + value + }; + let found = derived_diagnostics(&with_grant(json!(["reference"])), VISIT_SQL); + assert!( + found.iter().any(|(code, path, _)| code == UNREADABLE_SOURCE + && path == "recordTypes[id=visit].accessProfiles[id=registrar].operations"), + "expected {UNREADABLE_SOURCE}, got {found:?}" + ); + // The same project with a grant that reads visits compiles. + assert_compiles_with_sql(&with_grant(json!(["get"])), VISIT_SQL); +} + #[test] fn a_derived_field_may_read_a_record_type_under_the_same_row_boundaries() { let mut unrestricted = visit_source(); diff --git a/crates/registry-breg/tests/http_read_only.rs b/crates/registry-breg/tests/http_read_only.rs index dcca4631c5..eb555471c8 100644 --- a/crates/registry-breg/tests/http_read_only.rs +++ b/crates/registry-breg/tests/http_read_only.rs @@ -4095,6 +4095,7 @@ fn operation_name(operation: Operation) -> &'static str { Operation::Start => "start", Operation::Snapshot => "snapshot", Operation::Import => "import", + Operation::Reference => "reference", } } diff --git a/crates/registry-breg/tests/membership_authoring.rs b/crates/registry-breg/tests/membership_authoring.rs index 31d7936fb5..43dc642aad 100644 --- a/crates/registry-breg/tests/membership_authoring.rs +++ b/crates/registry-breg/tests/membership_authoring.rs @@ -248,6 +248,14 @@ fn production_admits_and_documents_member_bounded_open_writes() { "batch" ]); member["permissions"]["records"][0]["writableFields"] = json!(["organization", "label"]); + // A write names an organisation the member can read: one it belongs to. + member["permissions"]["records"] + .as_array_mut() + .unwrap() + .push( + json!({"recordType":"organization","operations":["get"],"readableFields":["name"], + "rowBoundaries":[{"field":"id","membership":"membership"}]}), + ); project["recordTypes"]["facility"]["tombstone"] = json!(true); project["recordTypes"]["facility"]["batch"] = json!({"maximumItems":4,"maximumBytes":8192}); let registry = compile_production(&project).expect("Production admits the bounded writes"); diff --git a/crates/registry-breg/tests/postgres_client_relationships.rs b/crates/registry-breg/tests/postgres_client_relationships.rs index bb815543e8..02aadff3ee 100644 --- a/crates/registry-breg/tests/postgres_client_relationships.rs +++ b/crates/registry-breg/tests/postgres_client_relationships.rs @@ -12,8 +12,8 @@ mod postgres_harness; use std::collections::{BTreeMap, BTreeSet}; use registry_breg::api::VerifiedRequestClaims; -use registry_breg::compiler::{compile_project, CompileProfile}; -use registry_breg::contract::parse_project_json; +use registry_breg::compiler::{compile_project, compile_project_with_assets, CompileProfile}; +use registry_breg::contract::{parse_project_json, ModuleAssetSource}; use registry_breg_client::{ BRegCreateRequest, BRegDirectWrite, BRegIdempotencyKey, BRegListRequest, BRegProblemCode, BRegRecordFormat, BRegRecordOptions, BRegRelationshipListRequest, @@ -259,7 +259,7 @@ async fn read_path_answers_when_the_profile_has_no_entry_for_its_target_entity() .unwrap(); client .create_record( - &create_binding(&operator.value, "records.membership.create", "operator"), + &create_binding(&writer.value, "records.membership.create", "writer"), &create(json!({ "household": household.value.data.record_id, "person": person.value.data.record_id @@ -374,8 +374,7 @@ const UNGRANTED_TARGET_PROJECT: &str = r#"{"datasets":{"test-dataset": {}}, "recordType":"household","rowBoundaries":"unrestricted","operations":["create","get","list"], "readableFields":["household-code"],"writableFields":["household-code"], "readPaths":[{"path":"people","readableFields":["person-code"]}] - }, - {"recordType":"membership","rowBoundaries":"unrestricted","operations":["create"],"readableFields":["household","person"],"writableFields":["household","person"]} + } ] } }, @@ -383,7 +382,9 @@ const UNGRANTED_TARGET_PROJECT: &str = r#"{"datasets":{"test-dataset": {}}, "requiredScopes":["registry.read"],"requiredPurposes":["case-management"], "permissions":{ "records":[ - {"recordType":"person","rowBoundaries":"unrestricted","operations":["create","get","list"],"readableFields":["person-code"],"writableFields":["person-code"]} + {"recordType":"person","rowBoundaries":"unrestricted","operations":["create","get","list"],"readableFields":["person-code"],"writableFields":["person-code"]}, + {"recordType":"household","rowBoundaries":"unrestricted","operations":["get"],"readableFields":[]}, + {"recordType":"membership","rowBoundaries":"unrestricted","operations":["create"],"readableFields":["household","person"],"writableFields":["household","person"]} ] } }, @@ -452,6 +453,7 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { ] }, "person": {"primaryDataset":"test-dataset","route":"people","mutationMode":"mutable","classification":"restricted", + "derived":[{"id":"population","sql":"population.sql","key":"id","execution":"live","fields":[{"id":"population","type":"int64","classification":"restricted"}]}], "fields":[ {"id":"person-code","type":"string","required":true,"maximumLength":64,"classification":"internal"}, {"id":"sensitive-note","type":"string","required":true,"maximumLength":64,"classification":"restricted"} @@ -478,6 +480,13 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { }"#, ) .expect("relationship SDK project parses"); - compile_project(&project, &[], CompileProfile::Authoring) + // The relationship projection, ordering, and count only need stored + // columns. An unrelated derived relation must not run its cardinality check. + let assets = [ModuleAssetSource { + module: None, + path: "population.sql".to_owned(), + bytes: b"SELECT p.id AS id, 1::bigint AS population FROM registry_source.person p CROSS JOIN registry_source.person AS other".to_vec(), + }]; + compile_project_with_assets(&project, &[], &assets, CompileProfile::Authoring) .expect("relationship SDK project compiles") } diff --git a/crates/registry-breg/tests/postgres_consent_examples.rs b/crates/registry-breg/tests/postgres_consent_examples.rs index 6934c7b9e7..c160b75311 100644 --- a/crates/registry-breg/tests/postgres_consent_examples.rs +++ b/crates/registry-breg/tests/postgres_consent_examples.rs @@ -152,6 +152,71 @@ async fn in_production_an_unknown_and_an_uncovered_subject_get_the_same_refusal_ ); } +/// The link steward names the subject of each link it writes, so its grant +/// on persons lets a write name any active person. That grant serves no +/// read: a GET of an existing person answers as a GET of an unknown one. +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn the_link_steward_names_subjects_it_cannot_read() { + let fixture = RunningFixture::start("consent-person-registry", &[]).await; + let app = fixture.prepared.app(); + let operator = fixture.token(json!({ + "registry_principal": "synthetic-registry-operator", + "registry_actor_kind": "human", + "azp": "person-registry-console", + "scope": "registry:person:operate", + })); + let link_steward = fixture.token(json!({ + "registry_principal": "synthetic-link-steward", + "scope": "consent:person:link", + })); + let person = create( + &app, + "persons", + "person-registry-operator", + &operator, + json!({"personCode": "P-LINKED", "legalName": "Linked Person", "district": "north"}), + ) + .await; + create( + &app, + "person-consent-links", + "person-consent-link-steward", + &link_steward, + json!({"subject": person, "principal": "linked-self", "active": true}), + ) + .await; + let unknown = "7f3c9a52-4f0e-4d8b-9a61-2b5e8c1d0f47"; + let (status, body) = send( + app.clone(), + Method::POST, + "/v1/records/person-consent-links?accessProfile=person-consent-link-steward".to_owned(), + json!({"data": {"subject": unknown, "principal": "unknown-self", "active": true}}), + Some("link-unknown-subject".to_owned()), + link_steward.clone(), + ) + .await; + assert_eq!(status, StatusCode::CONFLICT, "{body}"); + let read = |id: &str| { + send( + app.clone(), + Method::GET, + format!("/v1/records/persons/{id}?accessProfile=person-consent-link-steward"), + Value::Null, + None, + link_steward.clone(), + ) + }; + let (unknown_status, unknown_body) = read(unknown).await; + let (status, body) = read(&person).await; + assert_ne!(status, StatusCode::OK, "{body}"); + assert_eq!( + status, unknown_status, + "linked: {body} unknown: {unknown_body}" + ); + assert_eq!(without_trace(body), without_trace(unknown_body)); + fixture.finish().await; +} + /// Under `posture`, the bodies of a self action for an unknown subject and /// for an existing subject the caller's link does not cover, both 412, after /// checking that the subject the link covers succeeds. diff --git a/crates/registry-breg/tests/postgres_hook_changes.rs b/crates/registry-breg/tests/postgres_hook_changes.rs index b5d3a9b33e..6767e97bab 100644 --- a/crates/registry-breg/tests/postgres_hook_changes.rs +++ b/crates/registry-breg/tests/postgres_hook_changes.rs @@ -718,18 +718,30 @@ fn registry_state_test_identity() -> RegistryStateTestIdentity<'static> { } fn mutation_claims(registry: &CompiledRegistry) -> ClaimContext { - ClaimContext::for_compiled( - registry, - "case", - Some("operator-principal".to_owned()), - "operator", - Some("case-management".to_owned()), - vec![RowBoundaryContext::Equals { - field: "jurisdiction".to_owned(), - value: "zone-a".to_owned(), - }], - ) - .expect("compiled authority context is valid") + let context = |entity_id: &str| { + ClaimContext::for_compiled( + registry, + entity_id, + Some("operator-principal".to_owned()), + "operator", + Some("case-management".to_owned()), + vec![RowBoundaryContext::Equals { + field: "jurisdiction".to_owned(), + value: "zone-a".to_owned(), + }], + ) + .expect("compiled authority context is valid") + }; + let claims = context("case"); + // A case write names a tally only if the operator reads it, under the + // same jurisdiction. + if registry.entities().contains_key("tally") { + claims + .with_reference_context(&context("tally")) + .expect("same caller") + } else { + claims + } } /// One committed case create and the delivery rows it captured. diff --git a/crates/registry-breg/tests/postgres_ingestion_runs.rs b/crates/registry-breg/tests/postgres_ingestion_runs.rs index cb188f06d0..224e4e4faf 100644 --- a/crates/registry-breg/tests/postgres_ingestion_runs.rs +++ b/crates/registry-breg/tests/postgres_ingestion_runs.rs @@ -4294,6 +4294,105 @@ async fn an_outside_boundary_ingestion_item_remains_a_value_free_precondition_re assert_eq!(durable_widget_count(&harness).await, 0); } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn an_unavailable_ingestion_reference_is_a_value_free_precondition_refusal() { + let mut source: Value = serde_json::from_str(&format!("{FIXTURE_HEAD}{FIXTURE_TAIL}")).unwrap(); + source["recordTypes"]["widget"]["fields"] + .as_array_mut() + .unwrap() + .push( + json!({"id":"ledger","type":"reference","target":"ledger","classification":"public"}), + ); + let grants = source["accessProfiles"]["operator"]["permissions"]["records"] + .as_array_mut() + .unwrap(); + grants[0]["writableFields"] + .as_array_mut() + .unwrap() + .push(json!("ledger")); + grants.push(json!({ + "recordType":"ledger","operations":["reference"], + "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + })); + let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); + let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); + let harness = IngestionHarness::from_registry(Arc::new(registry)).await; + let claims = operator_claims(PRINCIPAL, "zone-a"); + let outside = Uuid::new_v4().to_string(); + let inside = Uuid::new_v4().to_string(); + let ledger = &harness.registry.entities()["ledger"]; + harness + .database + .admin + .execute( + &format!( + "INSERT INTO registry_data.\"{}\" (record_id, active_package_revision, \"{}\", \"{}\") + VALUES ($1::text::uuid, $3, 'zone-b', 'ledger-canary'), + ($2::text::uuid, $3, 'zone-a', 'in-reach')", + ledger.physical_table, + ledger.fields["jurisdiction"].physical_name, + ledger.fields["memo"].physical_name, + ), + &[&outside, &inside, &harness.identity.activation_id], + ) + .await + .expect("seed synthetic ledgers inside and outside the run's boundary"); + + let chunk_plan = |target: &str| { + let items = [json!({"operation":"create","data":{ + "jurisdiction":"zone-a","label":"reference-canary","quantity":1,"ledger":target + }})]; + plan_chunks(&items, 3) + }; + for target in [Uuid::new_v4().to_string(), outside] { + let chunks = chunk_plan(&target); + let run_id = harness.create_run(&claims, &chunks).await; + let refused = harness + .post_json( + &format!("/v1/records/widgets/ingestion-runs/{run_id}/chunks"), + &claims, + chunk_body(&chunks, 0), + ) + .await; + assert_eq!(refused.status(), StatusCode::PRECONDITION_FAILED); + let problem = body_json(refused).await; + assert_eq!( + problem + .as_object() + .unwrap() + .keys() + .map(String::as_str) + .collect::>(), + BTreeSet::from(["type", "title", "status", "detail", "code", "traceId"]) + ); + assert_eq!(problem["code"], "precondition.failed"); + assert_eq!(problem["detail"], "The mutation precondition failed."); + for concealed in [target.as_str(), "reference-canary", "ledger-canary"] { + assert!(!problem.to_string().contains(concealed), "{problem}"); + } + let run = harness.read_run(&claims, &run_id).await; + assert_eq!(run["status"], "open"); + assert_eq!(run["nextChunkIndex"], 0); + assert_eq!(run["committedItems"], 0); + assert_eq!(run["lastAttempt"]["outcome"], "refused"); + assert_eq!(durable_widget_count(&harness).await, 0); + } + let chunks = chunk_plan(&inside); + let run_id = harness.create_run(&claims, &chunks).await; + let committed = harness + .post_json( + &format!("/v1/records/widgets/ingestion-runs/{run_id}/chunks"), + &claims, + chunk_body(&chunks, 0), + ) + .await; + assert_eq!(committed.status(), StatusCode::OK); + let committed = body_json(committed).await; + assert_eq!(committed["run"]["committedItems"], 1); + assert_eq!(durable_widget_count(&harness).await, 1); + harness.database.cleanup().await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn listing_runs_filters_by_status_and_input_digest() { let harness = IngestionHarness::create().await; diff --git a/crates/registry-breg/tests/postgres_proposal_security.rs b/crates/registry-breg/tests/postgres_proposal_security.rs index 761fc97e59..5374a27495 100644 --- a/crates/registry-breg/tests/postgres_proposal_security.rs +++ b/crates/registry-breg/tests/postgres_proposal_security.rs @@ -87,7 +87,8 @@ fn source(membership: bool) -> Value { } /// A profile bounded through `membership` cannot also write it, so a -/// separate administrator with the same token keeps the membership rows. +/// separate administrator with the same token keeps the membership rows, and +/// reads the organisations a row may name. fn separate_membership_admin(source: &mut Value) { let records = source["accessProfiles"]["clerk"]["permissions"]["records"] .as_array_mut() @@ -99,7 +100,8 @@ fn separate_membership_admin(source: &mut Value) { let grant = records.remove(position); source["accessProfiles"]["membership-admin"] = json!({ "principalClaim":"registry_principal","requiredScopes":["proposal:manage"], - "requiredPurposes":["registry-administration"],"permissions":{"records":[grant]} + "requiredPurposes":["registry-administration"],"permissions":{"records":[grant, + {"recordType":"organization","operations":["get"],"readableFields":[],"rowBoundaries":"unrestricted"}]} }); } diff --git a/crates/registry-breg/tests/postgres_record_timers.rs b/crates/registry-breg/tests/postgres_record_timers.rs index 34fcfcb4e0..08c8b6e37f 100644 --- a/crates/registry-breg/tests/postgres_record_timers.rs +++ b/crates/registry-breg/tests/postgres_record_timers.rs @@ -2162,6 +2162,11 @@ async fn timer_action_locks_a_same_type_non_anchor_get_target() { .await .expect("same-type guard target is created"); let target_id = response_id(&target); + let claims = harness + .claims + .clone() + .with_reference_context(&harness.claims) + .expect("the editor can read the referenced service within its jurisdiction"); let anchor = harness .coordinator .execute( @@ -2169,7 +2174,7 @@ async fn timer_action_locks_a_same_type_non_anchor_get_target() { MutationRequest { plan: &create_plan, idempotency_key: "create-same-type-get-anchor", - claims: &harness.claims, + claims: &claims, record_id: None, expected_etag: None, body: MutationBody::Create(Map::from_iter([ @@ -6443,6 +6448,34 @@ struct EffectCounts { action_receipts: i64, } +/// The service editor's authority, with its read of approvals: a service +/// write names an approval only if the editor reads it, under the same +/// jurisdiction. +fn service_editor_claims(registry: ®istry_breg::CompiledRegistry) -> ClaimContext { + let context = |entity_id: &str| { + ClaimContext::for_compiled( + registry, + entity_id, + Some("timer-test-operator".to_owned()), + "service-editor", + Some("service-administration".to_owned()), + vec![RowBoundaryContext::Equals { + field: "jurisdiction".to_owned(), + value: "zone-a".to_owned(), + }], + ) + .expect("ordinary mutation authority is compiler-bound") + }; + let claims = context("service"); + if registry.entities().contains_key("approval") { + claims + .with_reference_context(&context("approval")) + .expect("same caller") + } else { + claims + } +} + struct TimerOutcomeHarness { database: TestDatabase, registry: Arc, @@ -6505,18 +6538,7 @@ async fn timer_outcome_harness( INSTANCE_ID, audit, ); - let claims = ClaimContext::for_compiled( - ®istry, - "service", - Some("timer-test-operator".to_owned()), - "service-editor", - Some("service-administration".to_owned()), - vec![RowBoundaryContext::Equals { - field: "jurisdiction".to_owned(), - value: "zone-a".to_owned(), - }], - ) - .expect("ordinary mutation authority is compiler-bound"); + let claims = service_editor_claims(®istry); TimerOutcomeHarness { database, registry, @@ -6862,18 +6884,7 @@ async fn encrypted_timer_harness(label: &'static str, audit_seed: u8) -> TimerOu audit, ) .with_field_encryption(field_encryption); - let claims = ClaimContext::for_compiled( - ®istry, - "service", - Some("timer-test-operator".to_owned()), - "service-editor", - Some("service-administration".to_owned()), - vec![RowBoundaryContext::Equals { - field: "jurisdiction".to_owned(), - value: "zone-a".to_owned(), - }], - ) - .expect("ordinary mutation authority is compiler-bound"); + let claims = service_editor_claims(®istry); TimerOutcomeHarness { database, registry, diff --git a/crates/registry-breg/tests/postgres_reference_integrity.rs b/crates/registry-breg/tests/postgres_reference_integrity.rs index b15a169cd4..92f01f6583 100644 --- a/crates/registry-breg/tests/postgres_reference_integrity.rs +++ b/crates/registry-breg/tests/postgres_reference_integrity.rs @@ -102,11 +102,13 @@ async fn active_references_refuse_tombstones_and_preserve_retained_links() { let source_batch = plan(&fixture, "records.source.batch"); let target_claims = claims(&fixture.registry, "target", "target-operator", "zone-a"); let source_claims = claims(&fixture.registry, "source", "linker", "zone-b"); + // The source writer reads targets so it may name them; it holds no + // write on them. assert!( - !fixture.registry.entities()["target"] - .access_profiles - .contains_key("linker"), - "the source writer has no direct target Record grant" + fixture.registry.entities()["target"].access_profiles["linker"] + .operations + .iter() + .all(|operation| *operation == registry_breg::contract::Operation::Get) ); let mut target_client = fixture.pool.get_for_test().await.expect("target client"); @@ -536,6 +538,10 @@ async fn event_record_references_restrict_tombstone_and_mutable_source_control() ); let subject_claims = claims(&fixture.registry, "subject", "subject-operator", "zone-a"); let recorder_claims = claims(&fixture.registry, "decision", "recorder", "zone-a"); + let recorder_claims = recorder_claims + .clone() + .with_reference_context(&recorder_claims) + .expect("the recorder can name earlier decisions within its jurisdiction"); let journal_claims = claims(&fixture.registry, "journal", "recorder", "zone-a"); let mut client = fixture.pool.get_for_test().await.expect("client"); let subject_fields: BTreeSet = ["jurisdiction", "name"] @@ -857,6 +863,9 @@ fn event_record_registry() -> registry_breg::CompiledRegistry { "readableFields":["jurisdiction","subject","noted-on"], "writableFields":["jurisdiction","subject","noted-on"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + },{ + "recordType":"subject","operations":["get"],"readableFields":["jurisdiction"], + "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] }]} }} }"#, @@ -1137,6 +1146,9 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { "readableFields":["jurisdiction","name","target","alternate"], "writableFields":["jurisdiction","name","target","alternate"], "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + },{ + "recordType":"target","operations":["get"],"readableFields":["name"], + "rowBoundaries":"unrestricted" }]} }} }"#, @@ -1156,7 +1168,7 @@ fn claims( profile: &str, jurisdiction: &str, ) -> ClaimContext { - ClaimContext::for_compiled( + let claims = ClaimContext::for_compiled( registry, entity, Some(PRINCIPAL.to_owned()), @@ -1167,7 +1179,36 @@ fn claims( value: jurisdiction.to_owned(), }], ) - .expect("claim context is compiler-bound") + .expect("claim context is compiler-bound"); + // A write names a record only if the writer reads it: the linker reads + // every target, while the other writers read within their jurisdiction. + let reference = match profile { + "target-operator" => Some(("target", claims.row_boundaries().to_vec())), + "linker" => Some(("target", Vec::new())), + "recorder" => Some(( + "subject", + vec![RowBoundaryContext::Equals { + field: "jurisdiction".to_owned(), + value: jurisdiction.to_owned(), + }], + )), + _ => None, + }; + match reference { + Some((target, boundaries)) => { + let target = ClaimContext::for_compiled( + registry, + target, + Some(PRINCIPAL.to_owned()), + profile, + Some("operations".to_owned()), + boundaries, + ) + .expect("the writer reads the referenced type"); + claims.with_reference_context(&target).expect("same caller") + } + None => claims, + } } async fn create_target( diff --git a/crates/registry-breg/tests/reference_authority_authoring.rs b/crates/registry-breg/tests/reference_authority_authoring.rs new file mode 100644 index 0000000000..7e5d7e3ea2 --- /dev/null +++ b/crates/registry-breg/tests/reference_authority_authoring.rs @@ -0,0 +1,343 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A direct write that sets a reference field must name a record the same +//! profile can read. The compiler refuses a writable reference field whose +//! target Record type the profile holds no `get` grant on, since every such +//! write would be refused at run time. + +use registry_breg::compiler::{compile_project, CompileProfile}; +use registry_breg::diagnostics::CompileFailure; +use registry_breg::{parse_project_yaml, CompiledRegistry}; +use serde_json::{json, Value}; + +const UNGRANTED: &str = "breg.access.reference-target-ungranted"; +const REFERENCE_EXCLUSIVE: &str = "breg.access-profile.reference-exclusive"; +const REFERENCE_UNUSED: &str = "breg.access.reference-grant-unused"; + +fn compile(project: &Value) -> Result { + let source = parse_project_yaml(&serde_json::to_vec_pretty(project).unwrap())?; + compile_project(&source, &[], CompileProfile::Authoring) +} + +/// `source` references `target`. `linker` writes `source`; `target_grant` +/// is its grant on `target`, if any. +fn project(writable: &[&str], target_grant: Option) -> Value { + project_with(&["create", "get", "patch"], writable, target_grant) +} + +/// As `project`, with the operations of the linker's grant on `source`. +fn project_with(operations: &[&str], writable: &[&str], target_grant: Option) -> Value { + let mut records = vec![json!({ + "recordType":"source","operations":operations, + "readableFields":["name","target"],"writableFields":writable, + "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + })]; + if let Some(mut grant) = target_grant { + grant["recordType"] = json!("target"); + if grant.get("readableFields").is_none() { + grant["readableFields"] = json!(["name"]); + } + records.push(grant); + } + json!({ + "apiVersion":"id.registrystack.org/formats/breg/project/v1alpha1","kind":"BRegProject", + "project":{"id":"reference-authority","version":"1","defaultLanguage":"en", + "canonicalBaseIri":"https://reference.example.test"}, + "datasets":{"records":{}}, + "recordTypes":{ + "target":{"primaryDataset":"records","route":"targets","mutationMode":"mutable", + "classification":"internal","fields":[ + {"id":"jurisdiction","type":"string","maximumLength":32,"required":true,"classification":"internal"}, + {"id":"name","type":"string","maximumLength":64,"required":true,"classification":"internal"}]}, + "source":{"primaryDataset":"records","route":"sources","mutationMode":"mutable", + "classification":"internal","batch":{"maximumItems":10,"maximumBytes":65536},"fields":[ + {"id":"jurisdiction","type":"string","maximumLength":32,"required":true,"classification":"internal"}, + {"id":"name","type":"string","maximumLength":64,"required":true,"classification":"internal"}, + {"id":"target","type":"reference","target":"target","classification":"internal"}]} + }, + "accessProfiles":{"linker":{"principalClaim":"principal","requiredScopes":["records:write"], + "permissions":{"records":records}}} + }) +} + +fn assert_refused_at(project: &Value, path: &str) { + assert_refused_with(project, UNGRANTED, path); +} + +fn assert_refused_with(project: &Value, code: &str, path: &str) { + let failure = compile(project).expect_err("the project must be refused"); + assert!( + failure + .diagnostics() + .iter() + .any(|diagnostic| diagnostic.code == code && diagnostic.path == path), + "wanted {code} at {path}: {:?}", + failure.diagnostics() + ); +} + +/// A grant that lets the linker name `target` records and read none. +fn reference_grant(bounds: Value) -> Value { + json!({"operations":["reference"],"readableFields":[],"rowBoundaries":bounds}) +} + +const TARGET_GRANT: &str = "recordTypes[id=target].accessProfiles[id=linker].operations"; + +const AT: &str = "recordTypes[id=source].accessProfiles[id=linker].writableFields[field=target]"; + +#[test] +fn the_reference_select_policy_requires_the_probe_on_its_own_type() { + let registry = compile(&project( + &["jurisdiction", "name", "target"], + Some(reference_grant(json!("unrestricted"))), + )) + .expect("reference-only project compiles"); + let table = registry + .ddl() + .tables + .iter() + .find(|table| table.entity_id == "target") + .unwrap(); + let policy = table + .policies + .iter() + .find(|policy| policy.access_profile == "linker") + .unwrap(); + let predicate = policy + .using_expression + .as_deref() + .expect("reference SELECT predicate"); + assert!( + predicate.contains("current_setting('registry.reference_probe_entity', true) = 'target'"), + "{predicate}" + ); +} + +#[test] +fn a_writable_reference_without_a_get_grant_on_its_target_is_refused() { + assert_refused_at(&project(&["jurisdiction", "name", "target"], None), AT); + // A list-only grant cannot read one record back by its identifier. + assert_refused_at( + &project( + &["jurisdiction", "name", "target"], + Some(json!({"operations":["list"],"rowBoundaries":"unrestricted"})), + ), + AT, + ); +} + +#[test] +fn a_get_grant_on_the_target_admits_the_writable_reference() { + for bounds in [ + json!("unrestricted"), + json!([{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]), + ] { + let project = project( + &["jurisdiction", "name", "target"], + Some(json!({"operations":["get"],"rowBoundaries":bounds})), + ); + if let Err(failure) = compile(&project) { + panic!("{:?}", failure.diagnostics()); + } + } +} + +#[test] +fn a_module_target_grant_keeps_its_own_reason_requirement() { + use registry_breg::contract::{parse_module_yaml, Operation}; + + for (operation, grant) in [ + ( + Operation::Get, + json!({"operations":["get"],"readableFields":["name"]}), + ), + (Operation::Reference, json!({"operations":["reference"]})), + ] { + let mut grant = grant; + grant["principalClaim"] = json!("principal"); + grant["requiredScopes"] = json!(["records:write"]); + grant["rowBoundaries"] = json!("unrestricted"); + grant["requireAccessReason"] = json!(true); + let module = parse_module_yaml( + &serde_json::to_vec(&json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1", + "kind":"BRegModule","id":"target-authority","version":"1", + "extendRecordTypes":{"target":{"accessProfiles":{"linker":grant}}} + })) + .unwrap(), + ) + .unwrap(); + + for operations in [&["create", "get", "patch", "batch"][..], &["import"]] { + let project = project_with(operations, &["jurisdiction", "name", "target"], None); + let source = parse_project_yaml(&serde_json::to_vec(&project).unwrap()).unwrap(); + let registry = compile_project( + &source, + std::slice::from_ref(&module), + CompileProfile::Authoring, + ) + .expect("module and project grants compose by Record type"); + assert!(!registry.entities()["source"].access_profiles["linker"].require_access_reason); + let target = ®istry.entities()["target"].access_profiles["linker"]; + assert!(target.require_access_reason); + assert!(target.operations.contains(&operation)); + if operation == Operation::Reference { + assert!(target.readable_fields.is_empty()); + } + } + } +} + +#[test] +fn a_reference_the_grant_does_not_write_needs_no_target_grant() { + let project = project(&["jurisdiction", "name"], None); + if let Err(failure) = compile(&project) { + panic!("{:?}", failure.diagnostics()); + } +} + +#[test] +fn every_write_operation_needs_the_target_grant() { + // Batch items and Import rows are direct writes as Create and Patch are. + for operations in [ + &["create"][..], + &["patch", "get"], + &["batch", "create", "get"], + &["import"], + ] { + assert_refused_at( + &project_with(operations, &["jurisdiction", "name", "target"], None), + AT, + ); + } +} + +#[test] +fn another_profiles_grant_on_the_target_does_not_count() { + // The read is made under the writing profile's own grant, so a grant held + // by a different profile admits nothing. + let mut project = project(&["jurisdiction", "name", "target"], None); + project["accessProfiles"]["reader"] = json!({ + "principalClaim":"principal","requiredScopes":["records:read"], + "permissions":{"records":[{"recordType":"target","operations":["get"], + "readableFields":["name"],"rowBoundaries":"unrestricted"}]} + }); + assert_refused_at(&project, AT); +} + +#[test] +fn a_reference_to_the_written_type_needs_a_get_grant_on_it() { + // A profile holds one grant per Record type, so naming another `source` + // is read under the same grant that writes it, which must include `get`. + let with_parent = |operations: &[&str]| { + let mut project = project_with(operations, &["jurisdiction", "name", "parent"], None); + project["recordTypes"]["source"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"parent","type":"reference","target":"source","classification":"internal"})); + project["accessProfiles"]["linker"]["permissions"]["records"][0]["readableFields"] = + json!(["name", "parent"]); + project + }; + assert_refused_at( + &with_parent(&["create"]), + "recordTypes[id=source].accessProfiles[id=linker].writableFields[field=parent]", + ); + if let Err(failure) = compile(&with_parent(&["create", "get"])) { + panic!("{:?}", failure.diagnostics()); + } +} + +#[test] +fn a_reference_grant_on_the_target_admits_the_writable_reference() { + for bounds in [ + json!("unrestricted"), + json!([{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}]), + ] { + let project = project( + &["jurisdiction", "name", "target"], + Some(reference_grant(bounds)), + ); + let compiled = compile(&project).unwrap_or_else(|failure| { + panic!("{:?}", failure.diagnostics()); + }); + // The grant serves no read, so it widens no read access: naming any + // active record was possible before writes checked reach at all. + assert!( + !compiled.findings().iter().any(|finding| { + finding.path.starts_with("recordTypes[id=target]") + && finding.code.starts_with("breg.access.profile-unrestricted") + }), + "{:?}", + compiled.findings() + ); + } +} + +#[test] +fn a_reference_grant_grants_nothing_else() { + let unrestricted = json!("unrestricted"); + // Combined with any other operation it would be a read grant by another name. + for operations in [json!(["reference", "get"]), json!(["reference", "list"])] { + let mut grant = reference_grant(unrestricted.clone()); + grant["operations"] = operations; + assert_refused_with( + &project(&["jurisdiction", "name", "target"], Some(grant)), + REFERENCE_EXCLUSIVE, + TARGET_GRANT, + ); + } + // It reads no field, through any member that serves or shapes a read. + for (member, value) in [ + ("readableFields", json!(["name"])), + ("filterableFields", json!(["name"])), + ("sortableFields", json!(["name"])), + ("allowCount", json!(true)), + ("revisionAccess", json!(true)), + ("allowDataExport", json!(true)), + ] { + let mut grant = reference_grant(unrestricted.clone()); + grant[member] = value; + assert_refused_with( + &project(&["jurisdiction", "name", "target"], Some(grant)), + REFERENCE_EXCLUSIVE, + TARGET_GRANT, + ); + } +} + +#[test] +fn a_reference_grant_serves_no_read_path() { + // `target` reaches `item` through `source`. A read path grant would serve + // GET /v1/records/targets/{id}/items under the profile, so a reference + // grant cannot carry one. + let mut project = project( + &["jurisdiction", "name", "target"], + Some(reference_grant(json!("unrestricted"))), + ); + project["recordTypes"]["item"] = json!({"primaryDataset":"records","route":"items", + "mutationMode":"mutable","classification":"internal","fields":[ + {"id":"label","type":"string","maximumLength":64,"classification":"internal"}]}); + project["recordTypes"]["source"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"item","type":"reference","target":"item","classification":"internal"})); + project["recordTypes"]["target"]["readPaths"] = + json!([{"id":"items","through":"source","to":"item","route":"items"}]); + project["accessProfiles"]["linker"]["permissions"]["records"][1]["readPaths"] = + json!([{"path":"items","readableFields":["label"]}]); + assert_refused_with(&project, REFERENCE_EXCLUSIVE, TARGET_GRANT); +} + +#[test] +fn a_reference_grant_no_write_of_the_profile_uses_is_refused() { + // The linker writes no reference to `target`, so the grant admits nothing. + assert_refused_with( + &project( + &["jurisdiction", "name"], + Some(reference_grant(json!("unrestricted"))), + ), + REFERENCE_UNUSED, + TARGET_GRANT, + ); +} diff --git a/crates/registry-breg/tests/steward_authoring.rs b/crates/registry-breg/tests/steward_authoring.rs index 908211de3d..cd21e619a2 100644 --- a/crates/registry-breg/tests/steward_authoring.rs +++ b/crates/registry-breg/tests/steward_authoring.rs @@ -733,9 +733,13 @@ fn with_clerk(grant: Value) -> Value { grant["rowBoundaries"] = json!([{"field":"private-note","claim":"team","operator":"equals"}]); } + // The clerk administers memberships, so it reads every organisation a + // membership may name. project["accessProfiles"][CLERK] = json!({ "principalClaim":"principal","requiredScopes":["records:manage","membership:use"], - "permissions":{"records":[grant]} + "permissions":{"records":[grant, + {"recordType":"organization","operations":["get"],"readableFields":["name"], + "rowBoundaries":"unrestricted"}]} }); project } diff --git a/crates/registry-breg/tests/support/membership_targets.rs b/crates/registry-breg/tests/support/membership_targets.rs index 796be3bd54..2b795c98b2 100644 --- a/crates/registry-breg/tests/support/membership_targets.rs +++ b/crates/registry-breg/tests/support/membership_targets.rs @@ -33,7 +33,17 @@ pub fn immediate(with_steward: bool) -> (CompiledRegistry, CompiledActionInvento source["recordTypes"]["membership"] = fixture["recordTypes"]["membership"].clone(); if with_steward { let mut steward = fixture["accessProfiles"]["steward"].clone(); - steward["permissions"]["records"] = json!([steward["permissions"]["records"][1]]); + // The steward writes memberships and reads every parent one may name + // (the membership key targets `parent` below). + steward["permissions"]["records"] = json!([ + steward["permissions"]["records"][1], + {"recordType":"parent","operations":["get"],"readableFields":[], + "rowBoundaries":"unrestricted"} + ]); + steward["requiredScopes"] + .as_array_mut() + .unwrap() + .push(json!("registry:parent:process")); source["accessProfiles"]["steward"] = steward; } source["recordTypes"]["membership"]["fields"][0]["target"] = json!("parent"); diff --git a/crates/registry-breg/tests/support/membership_write_journeys.rs b/crates/registry-breg/tests/support/membership_write_journeys.rs index 7045d2da26..151d62fb34 100644 --- a/crates/registry-breg/tests/support/membership_write_journeys.rs +++ b/crates/registry-breg/tests/support/membership_write_journeys.rs @@ -4847,6 +4847,9 @@ async fn a_current_member_replays_a_stored_patch_and_a_create_only_create() { "recordType":"facility","operations":["create"], "rowBoundaries":[{"field":"organization","membership":"membership"}], "readableFields":["organization","label"],"writableFields":["organization","label"] + },{ + "recordType":"organization","operations":["get"],"readableFields":["name"], + "rowBoundaries":[{"field":"id","membership":"membership"}] }]} }); let fixture = @@ -4922,3 +4925,532 @@ async fn a_current_member_replays_a_stored_patch_and_a_create_only_create() { assert_eq!(replayed.body, stored.body); fixture.database.cleanup().await; } + +#[tokio::test] +async fn a_direct_write_names_only_records_the_writer_can_read() { + // `related` names another facility. The member reads facilities of its + // own organisations only, so naming one elsewhere answers as naming a + // missing or tombstoned one does. + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let own = fixture + .seed(Some(&fixture.keys.allowed), "own-related") + .await; + let foreign = fixture + .seed(Some(&fixture.keys.foreign), "foreign-related") + .await; + let gone = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":"gone-related"}}), + None, + ) + .await + .success(StatusCode::CREATED); + request( + &fixture.app, + &member, + Method::DELETE, + &record(&gone.record_id()), + MEMBER, + Value::Null, + Some(gone.etag()), + ) + .await + .success(StatusCode::OK); + let create = |label: &str, related: String| { + let app = fixture.app.clone(); + let member = member.clone(); + let body = + json!({"data":{"organization":fixture.keys.allowed,"label":label,"related":related}}); + async move { request(&app, &member, Method::POST, RECORDS, MEMBER, body, None).await } + }; + create("names-own", own.record_id()) + .await + .success(StatusCode::CREATED); + let row = create("patched", own.record_id()) + .await + .success(StatusCode::CREATED); + let before = fixture.durable_state().await; + let unreachable = create("names-foreign", foreign.record_id()).await; + unreachable.problem(StatusCode::CONFLICT, "mutation.conflict"); + unreachable.assert_same_problem(&create("names-missing", Uuid::new_v4().to_string()).await); + unreachable.assert_same_problem(&create("names-tombstoned", gone.record_id()).await); + // A patch that sets the reference is checked the same way, and a Batch + // item is refused with the whole batch. + request( + &fixture.app, + &member, + Method::PATCH, + &record(&row.record_id()), + MEMBER, + patch("related", foreign.record_id().as_str()), + Some(row.etag()), + ) + .await + .assert_same_problem(&unreachable); + request( + &fixture.app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + json!({"items":[ + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"batch-own","related":own.record_id()}}, + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"batch-foreign","related":foreign.record_id()}} + ]}), + None, + ) + .await + .problem(StatusCode::CONFLICT, "mutation.conflict"); + assert_eq!( + fixture.durable_state().await, + before, + "refused writes leave nothing behind" + ); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_batch_answers_an_unreachable_reference_before_its_later_items() { + // Each item's references are checked at that item, as a missing or + // tombstoned reference fails at its own row. A later refusing item then + // cannot tell the three apart. + let fixture = Fixture::create(Duration::from_secs(2)).await; + let member = fixture.member(); + let foreign = fixture + .seed(Some(&fixture.keys.foreign), "foreign-related") + .await; + let own = fixture + .seed(Some(&fixture.keys.allowed), "own-related") + .await; + let gone = request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":"gone-related"}}), + None, + ) + .await + .success(StatusCode::CREATED); + request( + &fixture.app, + &member, + Method::DELETE, + &record(&gone.record_id()), + MEMBER, + Value::Null, + Some(gone.etag()), + ) + .await + .success(StatusCode::OK); + let before = fixture.durable_state().await; + let batch = |probe: String| { + let app = fixture.app.clone(); + let member = member.clone(); + let body = json!({"items":[ + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"probe","related":probe}}, + {"operation":"create","data":{"organization":fixture.keys.foreign,"label":"second-item-refused"}} + ]}); + async move { + request( + &app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + body, + None, + ) + .await + } + }; + let missing = batch(Uuid::new_v4().to_string()).await; + missing.problem(StatusCode::CONFLICT, "mutation.conflict"); + missing.assert_same_problem(&batch(gone.record_id()).await); + missing.assert_same_problem(&batch(foreign.record_id()).await); + // A readable reference passes, so the second item's refusal answers. + batch(own.record_id()) + .await + .problem(StatusCode::FORBIDDEN, "write.outside-boundary"); + assert_eq!(fixture.durable_state().await, before); + fixture.database.cleanup().await; +} + +/// The membership write project with `partner`, a facility reference to an +/// organisation, and organisations the steward may tombstone. The member +/// reads organisations only where it is a member; the claim-bounded writer +/// reads any. +fn partner_project() -> Value { + let mut project = membership_write_project::project(); + project["recordTypes"]["organization"]["tombstone"] = json!(true); + project["recordTypes"]["facility"]["fields"] + .as_array_mut() + .unwrap() + .push(json!({"id":"partner","type":"reference","target":"organization","classification":"internal"})); + for profile in [MEMBER, "claimed"] { + for grant in project["accessProfiles"][profile]["permissions"]["records"] + .as_array_mut() + .unwrap() + { + if grant["recordType"] == "facility" { + for list in ["readableFields", "writableFields"] { + grant[list].as_array_mut().unwrap().push(json!("partner")); + } + } + } + } + for grant in project["accessProfiles"][MEMBERSHIP_WRITER]["permissions"]["records"] + .as_array_mut() + .unwrap() + { + if grant["recordType"] == "organization" { + grant["operations"] + .as_array_mut() + .unwrap() + .push(json!("tombstone")); + } + } + project +} + +#[tokio::test] +async fn a_direct_write_names_only_records_of_another_type_the_writer_can_read() { + let fixture = Fixture::configured( + Duration::from_secs(2), + partner_project(), + Vec::new(), + |service| service, + ) + .await; + let member = fixture.member(); + let steward = fixture.steward(); + let gone = request( + &fixture.app, + &steward, + Method::POST, + "/v1/records/organizations", + MEMBERSHIP_WRITER, + json!({"data":{"name":"gone","owner":MEMBER}}), + None, + ) + .await + .success(StatusCode::CREATED); + request( + &fixture.app, + &steward, + Method::DELETE, + &format!("/v1/records/organizations/{}", gone.record_id()), + MEMBERSHIP_WRITER, + Value::Null, + Some(gone.etag()), + ) + .await + .success(StatusCode::OK); + let create = |label: &str, partner: &str| { + let app = fixture.app.clone(); + let member = member.clone(); + let body = + json!({"data":{"organization":fixture.keys.allowed,"label":label,"partner":partner}}); + async move { request(&app, &member, Method::POST, RECORDS, MEMBER, body, None).await } + }; + create("names-second", &fixture.keys.second) + .await + .success(StatusCode::CREATED); + let row = create("patched", &fixture.keys.allowed) + .await + .success(StatusCode::CREATED); + let before = fixture.durable_state().await; + // The member writes facilities of `allowed` and is no member of `foreign`. + let unreachable = create("names-foreign", &fixture.keys.foreign).await; + unreachable.problem(StatusCode::CONFLICT, "mutation.conflict"); + unreachable.assert_same_problem(&create("names-missing", &Uuid::new_v4().to_string()).await); + unreachable.assert_same_problem(&create("names-tombstoned", &gone.record_id()).await); + request( + &fixture.app, + &member, + Method::PATCH, + &record(&row.record_id()), + MEMBER, + patch("partner", fixture.keys.foreign.as_str()), + Some(row.etag()), + ) + .await + .assert_same_problem(&unreachable); + request( + &fixture.app, + &member, + Method::POST, + &format!("{RECORDS}:batch"), + MEMBER, + json!({"items":[ + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"batch-own","partner":fixture.keys.allowed}}, + {"operation":"create","data":{"organization":fixture.keys.allowed,"label":"batch-foreign","partner":fixture.keys.foreign}} + ]}), + None, + ) + .await + .assert_same_problem(&unreachable); + assert_eq!( + fixture.durable_state().await, + before, + "refused writes leave nothing behind" + ); + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_reference_type_the_caller_cannot_read_answers_as_missing_and_logs_why() { + // The member's organisation read is bounded by a claim its token lacks, so + // it can read no organisation. A write naming one answers as a missing + // record does, and the log names the Record type and profile, never the + // record. + let mut project = partner_project(); + for grant in project["accessProfiles"][MEMBER]["permissions"]["records"] + .as_array_mut() + .unwrap() + { + if grant["recordType"] == "organization" { + grant["rowBoundaries"] = + json!([{"field":"id","claim":"partner_organizations","operator":"in"}]); + } + } + let fixture = Fixture::configured(Duration::from_secs(2), project, Vec::new(), |service| { + service + }) + .await; + let member = fixture.member(); + let logs = Logs::default(); + let subscriber = tracing_subscriber::fmt() + .json() + .with_writer(logs.clone()) + .finish(); + let label = "names-unreadable-type"; + let reply = tracing::instrument::WithSubscriber::with_subscriber( + request( + &fixture.app, + &member, + Method::POST, + RECORDS, + MEMBER, + json!({"data":{"organization":fixture.keys.allowed,"label":label,"partner":fixture.keys.allowed}}), + None, + ), + subscriber, + ) + .await; + reply.problem(StatusCode::CONFLICT, "mutation.conflict"); + let output = String::from_utf8(logs.0.lock().unwrap().clone()).unwrap(); + let line = output + .lines() + .find(|line| line.contains("reference-target-unauthorized")) + .unwrap_or_else(|| panic!("the refusal is logged: {output}")); + assert!(line.contains("\"record_type\":\"organization\""), "{line}"); + assert!(line.contains("\"access_profile\":\"member\""), "{line}"); + for value in [fixture.keys.allowed.as_str(), label] { + assert!( + !output.contains(value), + "the log carries no record values: {output}" + ); + } + fixture.database.cleanup().await; +} + +#[tokio::test] +async fn a_reference_grant_names_records_in_reach_and_reads_none() { + // The member's organisation grant only lets its writes name the + // organisations it is a member of. Its row reach still decides which + // records a write may name, and no GET answers under it. + let mut project = partner_project(); + for grant in project["accessProfiles"][MEMBER]["permissions"]["records"] + .as_array_mut() + .unwrap() + { + if grant["recordType"] == "organization" { + grant["operations"] = json!(["reference"]); + grant["readableFields"] = json!([]); + } + } + let fixture = Fixture::configured(Duration::from_secs(2), project, Vec::new(), |service| { + service + }) + .await; + // The database boundary must also refuse an ordinary read under the + // profile, independently of the GET route's refusal. + let pool = fixture.database.runtime_config.build_pool().unwrap(); + let mut client = pool.get_for_test().await.unwrap(); + let claims = registry_breg::postgres::ClaimContext::for_compiled( + &fixture.registry, + "organization", + Some(MEMBER.to_owned()), + MEMBER, + None, + Vec::new(), + ) + .unwrap(); + let transaction = registry_breg::postgres::begin_record_transaction( + &mut client, + RegistryLockKey::derive(PACKAGE).unwrap(), + Duration::from_secs(2), + &fixture.identity, + &claims, + ) + .await + .unwrap(); + let table = &fixture.registry.entities()["organization"].physical_table; + let visible: i64 = transaction + .transaction_for_test() + .query_one( + &format!("SELECT count(*) FROM registry_data.\"{table}\""), + &[], + ) + .await + .unwrap() + .get(0); + assert_eq!( + visible, 0, + "ordinary queries must have no reference-only reach" + ); + transaction.commit().await.unwrap(); + drop(client); + drop(pool); + let member = fixture.member(); + let create = |label: &str, partner: &str| { + let app = fixture.app.clone(); + let member = member.clone(); + let body = + json!({"data":{"organization":fixture.keys.allowed,"label":label,"partner":partner}}); + async move { request(&app, &member, Method::POST, RECORDS, MEMBER, body, None).await } + }; + create("names-second", &fixture.keys.second) + .await + .success(StatusCode::CREATED); + let before = fixture.durable_state().await; + let unreachable = create("names-foreign", &fixture.keys.foreign).await; + unreachable.problem(StatusCode::CONFLICT, "mutation.conflict"); + unreachable.assert_same_problem(&create("names-missing", &Uuid::new_v4().to_string()).await); + assert_eq!( + fixture.durable_state().await, + before, + "refused writes leave nothing behind" + ); + let get = |id: String| { + let app = fixture.app.clone(); + let member = member.clone(); + async move { + request( + &app, + &member, + Method::GET, + &format!("/v1/records/organizations/{id}"), + MEMBER, + Value::Null, + None, + ) + .await + } + }; + let missing = get(Uuid::new_v4().to_string()).await; + assert!(missing.status.is_client_error(), "{}", missing.body); + for id in [fixture.keys.allowed.clone(), fixture.keys.second.clone()] { + let reply = get(id).await; + assert_ne!(reply.status, StatusCode::OK, "{}", reply.body); + reply.assert_same_problem(&missing); + } + fixture.database.cleanup().await; +} + +#[derive(Clone, Default)] +struct Logs(std::sync::Arc>>); +impl std::io::Write for Logs { + fn write(&mut self, bytes: &[u8]) -> std::io::Result { + self.0.lock().unwrap().extend_from_slice(bytes); + Ok(bytes.len()) + } + fn flush(&mut self) -> std::io::Result<()> { + Ok(()) + } +} +impl<'a> tracing_subscriber::fmt::MakeWriter<'a> for Logs { + type Writer = Self; + fn make_writer(&'a self) -> Self::Writer { + self.clone() + } +} + +#[tokio::test] +async fn a_batch_item_after_a_reference_read_runs_under_the_written_types_boundaries() { + // The claim-bounded writer reads every organisation but writes facilities + // of its claimed organisations only. Reading a referenced organisation + // sets the organisation's row boundaries for that read alone, so the next + // item reaches exactly the facilities it would reach without that read. + let fixture = Fixture::configured( + Duration::from_secs(2), + partner_project(), + Vec::new(), + |service| service, + ) + .await; + let claimed = fixture.claimed(); + // A row's ETag is per profile, so the writer creates the row it renames. + let own = request( + &fixture.app, + &claimed, + Method::POST, + RECORDS, + "claimed", + json!({"data":{"organization":fixture.keys.allowed,"label":"own"}}), + None, + ) + .await + .success(StatusCode::CREATED); + let foreign = fixture.seed(Some(&fixture.keys.foreign), "foreign").await; + let batch = |first: Value, then: &Reply, label: &str| { + let app = fixture.app.clone(); + let claimed = claimed.clone(); + let body = json!({"items":[ + {"operation":"create","data":first}, + {"operation":"patch","recordId":then.record_id(),"ifMatch":then.etag(),"patch":patch("label", label)} + ]}); + async move { + request( + &app, + &claimed, + Method::POST, + &format!("{RECORDS}:batch"), + "claimed", + body, + None, + ) + .await + } + }; + let names_partner = |label: &str| json!({"organization":fixture.keys.allowed,"label":label,"partner":fixture.keys.allowed}); + let plain = |label: &str| json!({"organization":fixture.keys.allowed,"label":label}); + let before = fixture.durable_state().await; + let refused = batch(plain("plain-first"), &foreign, "taken").await; + assert!(refused.status.is_client_error(), "{}", refused.body); + refused.assert_same_problem(&batch(names_partner("partner-first"), &foreign, "taken").await); + assert_eq!(fixture.durable_state().await, before); + batch(names_partner("partner-then-own"), &own, "renamed") + .await + .success(StatusCode::OK); + let read = request( + &fixture.app, + &claimed, + Method::GET, + &record(&own.record_id()), + "claimed", + Value::Null, + None, + ) + .await + .success(StatusCode::OK); + assert_eq!(read.body["data"]["domainData"]["label"], "renamed"); + fixture.database.cleanup().await; +} diff --git a/crates/registry-breg/tests/support/membership_write_project.rs b/crates/registry-breg/tests/support/membership_write_project.rs index e2311b7dd7..a9d8597ea4 100644 --- a/crates/registry-breg/tests/support/membership_write_project.rs +++ b/crates/registry-breg/tests/support/membership_write_project.rs @@ -50,6 +50,23 @@ pub(super) fn project() -> Value { "readableFields":readable.clone(),"writableFields":writable.clone() }]} }); + // A direct write names only records the writer can read. The member reads + // the organisations it belongs to; the claim-bounded writer's facility + // grant already bounds which organisation it writes, so it reads any. + project["accessProfiles"]["member"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push( + json!({"recordType":"organization","operations":["get"],"readableFields":["name"], + "rowBoundaries":[{"field":"id","membership":"membership"}]}), + ); + project["accessProfiles"]["claimed"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push( + json!({"recordType":"organization","operations":["get"],"readableFields":["name"], + "rowBoundaries":"unrestricted"}), + ); for (id, fields) in [ ("observer", json!(["organization", "label"])), ("limited", json!(["label"])), diff --git a/crates/registry-bregctl/src/consent_module/profiles.yaml b/crates/registry-bregctl/src/consent_module/profiles.yaml index 9ec1ee0af5..80e59534cb 100644 --- a/crates/registry-bregctl/src/consent_module/profiles.yaml +++ b/crates/registry-bregctl/src/consent_module/profiles.yaml @@ -105,6 +105,11 @@ __SUBJECT__-consent-link-steward: operations: [create, get, list, patch] readableFields: [subject, principal, active] writableFields: [subject, principal, active] + # A link names its subject. The steward may name any subject and reads none. + - recordType: __SUBJECT__ + rowBoundaries: unrestricted + operations: [reference] + readableFields: [] __SUBJECT__-consent-recipient: principalClaim: __CLAIM__ requiredScopes: ['consent:__SUBJECT__:read'] diff --git a/crates/registry-bregctl/src/lib.rs b/crates/registry-bregctl/src/lib.rs index ce93cd8ac6..73187eeeb0 100644 --- a/crates/registry-bregctl/src/lib.rs +++ b/crates/registry-bregctl/src/lib.rs @@ -12154,6 +12154,7 @@ fn operation_wire_name(operation: registry_breg::contract::Operation) -> &'stati registry_breg::contract::Operation::Start => "start", registry_breg::contract::Operation::Snapshot => "snapshot", registry_breg::contract::Operation::Import => "import", + registry_breg::contract::Operation::Reference => "reference", } } diff --git a/docs/site/src/content/docs/configure/breg-access.mdx b/docs/site/src/content/docs/configure/breg-access.mdx index f43e538974..9785156213 100644 --- a/docs/site/src/content/docs/configure/breg-access.mdx +++ b/docs/site/src/content/docs/configure/breg-access.mdx @@ -198,6 +198,64 @@ standing agents, and `bregctl check` reports `breg.access-profile.task-grant-row products/breg/fixtures/multi-reference-array-claim/dev.yaml; crates/registry-breg/tests/postgres_multi_reference_action_authority.rs. */} +### Name referenced records + +A direct Create, Patch, Batch item or Import row that sets a reference field must name a record +the same profile can read. BReg reads the referenced record inside the write transaction, under +the profile's own grant on that Record type. Actions check their reference targets against their +own target grants. An out-of-reach, missing, or tombstoned reference returns +`409 mutation.conflict` on Create, Patch, and Batch. Ingestion returns the value-free +`412 precondition.failed` for the same cases. Each Batch or ingestion item checks the +references it sets against the transaction state at that item. + +A Patch checks only the references it sets. A Patch that sends a reference again is checked +again, even when the value is unchanged. A client that replaces whole records therefore gets +`409` once the record it names leaves its reach. + +The profile's grant on the referenced type may not admit the caller. For example, the token may +lack a claim its row boundaries name. Every write naming that type then receives the route's +unavailable-reference response. BReg logs `reference-target-unauthorized` with the Record type and profile, never the record. + +Give each profile that writes a reference field a `get` grant on the referenced Record type, +bounded to the records it may name. Without one, `bregctl check` refuses the grant with +`breg.access.reference-target-ungranted`. A profile that should name records without reading +them takes a `reference` grant instead. + +```yaml + - recordType: person + rowBoundaries: unrestricted + operations: [reference] + readableFields: [] +``` + +A `reference` grant serves no route. Its row boundaries and membership entries decide which +records the profile's writes may name. A GET under the profile answers as it does for a Record +type the profile holds no grant on. An unrestricted `reference` grant lets the profile's writes +name any active record of the type. Every write could do that before writes checked their +references. It grants no other operation, field, read path, lookup, filter, count, revision, +export or spatial access (`breg.access-profile.reference-exclusive`). A derived field cannot read +its Record type through it either, so derived SQL over that type still needs a grant that reads. +A grant that no writable reference field of its profile uses is refused with +`breg.access.reference-grant-unused`. A reference to the written +Record type itself needs `get`, since a profile holds one grant per Record type. A `reference` +grant is bounded by row boundaries and membership entries only, not by consent: to let writes +name only subjects with recorded consent, use a consent-gated `get` with no readable fields. + +{/* Evidence: crates/registry-breg/src/access.rs, validate_reference_targets; + crates/registry-breg/src/mutation/reference_reach.rs, require_readable_references; + crates/registry-breg/tests/reference_authority_authoring.rs, + a_writable_reference_without_a_get_grant_on_its_target_is_refused, + a_reference_grant_grants_nothing_else, + a_reference_grant_no_write_of_the_profile_uses_is_refused, + a_reference_grant_serves_no_read_path; + crates/registry-breg/src/compiler/disclosure/reach.rs, reading_grant; + crates/registry-breg/tests/disclosure_compile.rs, + a_reference_grant_does_not_let_a_derived_field_read_its_record_type; + crates/registry-breg/src/api/mod.rs, reference_grant_context; + crates/registry-breg/tests/support/membership_write_journeys.rs, + a_direct_write_names_only_records_the_writer_can_read, + a_reference_grant_names_records_in_reach_and_reads_none. */} + ## Disclose related Records A Record type can declare a read path to related Records. The facility reaches its operators @@ -857,11 +915,13 @@ before any record is read. The reason is stored on the subject access log entry read alert, so a reviewer can ask why. See [Record why a record was read or written](../../operate/breg-access-log/#record-why-a-record-was-read-or-written). -The reason is checked on record reads and direct writes only. A direct Create, Patch, Batch or -Tombstone under the profile must carry the header. On a Record type with `accessLog`, each record it +The reason is checked on Record reads, direct writes and Batch-backed ingestion requests. +A direct Create, Patch, Batch or Tombstone under the profile must carry the header. +On a Record type with `accessLog`, each record it changes gets a subject access log entry with `accessKind: write` and the reason, written in the same transaction. On a Record type without `accessLog` the header is still required, but nothing stores -the reason. `bregctl check` refuses the key on a profile that grants import, invoke or start +the reason. BReg discards the reason text after validating it for ingestion. +`bregctl check` refuses the key on a profile that grants import, invoke or start operations, bulk data export, or an action, proposal, dataset, external view or projection-refresh permission, because those paths do not check it (`breg.access-profile.access-reason-operation-unsupported`). Bulk export is refused even though it @@ -870,6 +930,7 @@ export omits every grant of such a profile, with the reason `access-reason`, bec term for the header. {/* Evidence: crates/registry-breg/src/api/context.rs bind_access_reason; + crates/registry-breg/src/api/ingestion.rs, validate_ingestion_access_reason(); crates/registry-breg/src/subject_access_log.rs access_reason; crates/registry-breg/src/compiler/disclosure.rs, validate_access_reason_operations and validate_module_access_reason_operations; diff --git a/docs/site/src/content/docs/configure/breg-consent.mdx b/docs/site/src/content/docs/configure/breg-consent.mdx index 5d401e0004..d428f52bdb 100644 --- a/docs/site/src/content/docs/configure/breg-consent.mdx +++ b/docs/site/src/content/docs/configure/breg-consent.mdx @@ -351,6 +351,7 @@ Not enforced: - A profile without `requireConsent` bypasses consent entirely. `bregctl check` reports `breg.access.consent-ungated-client` for a profile that reads a gated Record type's rows without consent while it admits any client, or while it shares a client with a gated profile. + A `reference` grant reads no row through any route, so it is not reported: the link steward's grant on the subject only lets its link writes name a subject, and a GET under it answers as for a subject the steward holds no grant on. Give each gated profile's recipients their own clients, and give an ungated reader clients no gated profile admits. - The feed discloses unsolicited withdrawals and invalidations. A recipient learns of every non-refusal decision addressed to it, including a withdrawal for a subject it never received a give for. @@ -375,7 +376,8 @@ The self Actions answer an unknown subject exactly like a subject the caller's l crates/registry-breg/tests/consent_access.rs evidence_source_export_refuses_a_gated_profile; crates/registry-breg/tests/consent_access.rs breg.access.consent-ungated-client; crates/registry-breg/tests/postgres_consent_access.rs real_postgres_consent_refusals_reach_no_recipient_through_an_authored_selector; - crates/registry-breg/src/access.rs breg.access.consent-ungated-client. */} + crates/registry-breg/src/access.rs breg.access.consent-ungated-client; + crates/registry-breg/tests/postgres_consent_examples.rs the_link_steward_names_subjects_it_cannot_read. */} ## How the probe runs diff --git a/docs/site/src/content/docs/configure/breg.mdx b/docs/site/src/content/docs/configure/breg.mdx index f856611ac8..15beac6737 100644 --- a/docs/site/src/content/docs/configure/breg.mdx +++ b/docs/site/src/content/docs/configure/breg.mdx @@ -472,7 +472,7 @@ The grant follows the derived relation, not the column, so reading one column ne `bregctl check` checks each profile that reads, filters or sorts a derived field. For each other Record type the SQL reads, the profile's grant on that type must: -- include `get`, `lookup`, `list`, `batch`, `revisions` or `snapshot`, refused otherwise with `breg.disclosure.derived-reads-unreadable-source` +- include `get`, `lookup`, `list`, `batch`, `revisions` or `snapshot`, refused otherwise with `breg.disclosure.derived-reads-unreadable-source`. A `reference` grant does not count: it reads no field - have the same `rowBoundaries`, in the same order, as the profile's grant on the Record type that owns the derived field - require no `requiredPurposes`, or every purpose that the owner's grant requires diff --git a/docs/site/src/content/docs/reference/breg-api.mdx b/docs/site/src/content/docs/reference/breg-api.mdx index 46ffd0b9ef..6ec705edef 100644 --- a/docs/site/src/content/docs/reference/breg-api.mdx +++ b/docs/site/src/content/docs/reference/breg-api.mdx @@ -379,12 +379,18 @@ another caller's run and an unknown run answer the same 404. Run responses carry metadata only, never source rows or record values. Every ingestion response carries `Cache-Control: no-store`. +Send a valid [`Registry-Access-Reason`](#access-reason) header on each Batch-backed ingestion +request when its grant requires a reason. A Batch-backed chunk can also supply the header for a +referenced Record type whose grant requires one. Import-backed ingestion ignores the header. +BReg discards the reason text after validation for ingestion. + The ingestion routes refuse an `Idempotency-Key` header with `400 request.invalid`. The server derives each chunk's attempt key from the run ID, input digest, chunk index, and chunk digest, so resubmitting the exact chunk is always safe. For the procedure, see [load records through an import window](../../operate/breg-data/#load-records-through-an-import-window). -{/* Evidence: crates/registry-breg/src/api/ingestion.rs, create_run(), submit_chunk(), ingestion_response(); +{/* Evidence: crates/registry-breg/src/api/ingestion.rs, create_run(), submit_chunk(), ingestion_response(), + admit_ingestion(), ingestion_openapi_publishes_the_selected_grants_reason_precondition; crates/registry-breg/src/ingestion_store.rs, IngestionRunRecord created_issuer and created_subject; crates/registry-breg/src/data.rs, ingestion_route() and ingestion_chunk_idempotency_key(). */} @@ -474,10 +480,10 @@ when its `digest` and `prefixDigest` equal the stored ones, the answer is the st `replayed: true` and nothing is written. Any other mismatch of index, digest, prefix digest, count, or operation answers `409 ingestion.chunk-mismatch` and writes nothing. -An item whose prospective row falls outside the run profile's row boundary answers the run -protocol's value-free `412 precondition.failed`, records `lastAttempt.outcome` as `refused`, and -leaves the checkpoint unchanged. An ingestion item never answers the distinct -`403 write.outside-boundary`. +An item whose prospective row falls outside the run profile's row boundary, or whose reference +target is missing, tombstoned, or outside the profile's reach, answers with a value-free +`412 precondition.failed`. The run records `lastAttempt.outcome` as `refused` and keeps its +checkpoint unchanged. | Receipt member | Meaning | | --- | --- | @@ -495,6 +501,8 @@ chunk's counts stay in the run. crates/registry-breg/src/data.rs, plan_chunks() and canonical_chunk_body(); crates/registry-breg/src/mutation.rs, terminal-chunk check chunk_binding.prefix_digest != run.input_digest; crates/registry-breg/src/postgres/mutation.rs, submit_ingestion_chunk_in() and receipt_json(); + crates/registry-breg/tests/postgres_ingestion_runs.rs, + an_unavailable_ingestion_reference_is_a_value_free_precondition_refusal; crates/registry-breg-client/src/ingestion.rs, BREG_INGESTION_CHUNK_ALGORITHM_VERSION. */} ### List, read, and cancel diff --git a/docs/site/src/content/docs/security/breg.mdx b/docs/site/src/content/docs/security/breg.mdx index e9338ff6b3..9133d1b93d 100644 --- a/docs/site/src/content/docs/security/breg.mdx +++ b/docs/site/src/content/docs/security/breg.mdx @@ -321,6 +321,47 @@ The audit journal's `refusalReason` stays the three values it lists below. proposal_membership_refusals_match_the_claim_boundary_answer, membership_diagnostics_count_only_observed_denials. */} +### Referenced records in direct writes + +A direct Create, Patch, Batch item or Import row that sets a reference field must name a record the caller can read. +BReg reads each referenced record under the caller's own grant on that Record type, inside the write transaction. +If the target grant requires an access reason, the write must supply a valid `Registry-Access-Reason` header before BReg probes the target. +The probe requires an admitted target grant even when the target has the same Record type as the write. +Batch-backed chunks can supply the reason for a target grant. +BReg refuses an Import item that sets a reference under a target grant that requires a reason. +An unavailable target grant affects only items that set a reference to that Record type. +Actions check their reference targets against their own target grants instead. +Direct writes return `409 mutation.conflict` for missing, tombstoned, or unauthorized references. +Ingestion chunks return the same value-free `412 precondition.failed` for all three cases. +Each Batch or ingestion item checks the references it sets against the transaction state at that item. +`bregctl check` refuses a writable reference field whose profile has no `get` or `reference` grant on the referenced Record type (`breg.access.reference-target-ungranted`). +The database policy for a `reference` grant applies during the write's explicit probe of that Record type. The probe returns only whether the named records are in reach. +`bregctl check` refuses any read member on it, a read path included (`breg.access-profile.reference-exclusive`), and does not count it as a grant that derived SQL may read through. +The consent module's link steward holds an unrestricted one on the subject Record type. +It can link any active subject and still reads none. +An unrestricted `reference` grant is not reported as `breg.access.profile-unrestricted-rows`, since it reads nothing a write could not already name before this check. + +Residuals: + +- **Point-in-time read.** The read sees the transaction's snapshot and takes no lock. A revocation that commits after the read and before the write commits does not stop the write. +- **Timing.** A missing or tombstoned reference fails at the row's foreign key. A probe that finds no readable target fails after the row is written and three more statements. Those statements open the probe with the referenced type's boundaries, count the readable records, and restore the written type's boundaries. Refusal timing can reveal differences with repeated samples. +- **Probe logging.** The read discloses one bit about whether the named record is in reach. The write follows the subject access logging rules of the written Record type and its grant. The probe creates no separate entry. + +{/* Evidence: crates/registry-breg/src/mutation/reference_reach.rs, require_readable_references; + crates/registry-breg/src/access.rs, validate_reference_targets; + crates/registry-breg/src/api/context.rs, a_reference_context_requires_its_own_access_reason; + crates/registry-breg/src/api/ingestion.rs, only_batch_ingestion_can_supply_a_targets_required_reason; + crates/registry-breg/src/postgres/mutation.rs, a_same_type_probe_requires_an_admitted_target_context, + an_invalid_target_context_does_not_invalidate_other_record_types; + crates/registry-breg/tests/reference_authority_authoring.rs, a_module_target_grant_keeps_its_own_reason_requirement; + crates/registry-breg/tests/support/membership_write_journeys.rs, + a_direct_write_names_only_records_the_writer_can_read, + a_reference_grant_names_records_in_reach_and_reads_none; + crates/registry-breg/tests/postgres_ingestion_runs.rs, + an_unavailable_ingestion_reference_is_a_value_free_precondition_refusal; + crates/registry-breg/tests/postgres_consent_examples.rs, + the_link_steward_names_subjects_it_cannot_read. */} + ### Membership boundaries A membership boundary limits a grant to target keys for which the authenticated principal has an active membership Record. @@ -498,10 +539,12 @@ profile can read. An automatic Proposal is checked against the profile that submitted its version, but it reads and writes under `system-proposal-apply`, which no condition can exempt. -A profile with `requireAccessReason` must send a `Registry-Access-Reason` header on each Record read -and direct write. +A caller must send a `Registry-Access-Reason` header on each Record read or direct write whose +route grant sets `requireAccessReason`. BReg refuses a missing or invalid header with `400 request.access-reason-required` before any Record is read, and stores the reason on the subject access log entry of a Record type with `accessLog`. +The same precondition applies to Batch-backed ingestion requests under a grant that requires it. +BReg discards the reason text after validating it for ingestion. The compiler refuses the key on a profile that grants an operation that does not check the header. BReg writes no subject-log entry for a Proposal attachment download or a Proposal review read, even when the review shows fields of a Record type with `accessLog`. @@ -516,6 +559,7 @@ See obligation 22 and `BREG-RES-27` for what remains. crates/registry-breg/src/postgres/revision_read.rs, withholds_history; crates/registry-breg/src/compiler/disclosure/reach.rs, validate_read_paths; crates/registry-breg/src/api/context.rs, bind_access_reason; + crates/registry-breg/src/api/ingestion.rs, admit_ingestion(), batch_ingestion_requires_a_valid_reason_when_its_grant_does; crates/registry-breg/tests/disclosure/records.rs, the_record_guard_hides_a_protected_row_from_every_profile_but_the_exempt_and_the_timer; crates/registry-breg/tests/disclosure/fields.rs, a_list_nulls_withheld_members_row_by_row; diff --git a/products/breg/CHANGELOG.md b/products/breg/CHANGELOG.md index 238c3ac4a3..3b223f3867 100644 --- a/products/breg/CHANGELOG.md +++ b/products/breg/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- BREAKING: Direct Record writes now check the caller's authority over referenced records, under the caller's own grant on the referenced Record type. Actions keep checking against their own target grants. An unavailable reference returns `409 mutation.conflict` for Create, Patch, and Batch, or the value-free `412 precondition.failed` for ingestion. Each Batch or ingestion item checks the references it sets against the transaction state at that item. Migration: give each writing profile a `get` or `reference` grant on the referenced Record type that covers the records it may name. +- BREAKING: `bregctl check` refuses a writable reference field whose profile has no `get` or `reference` grant on the referenced Record type, with `breg.access.reference-target-ungranted`. A stored package that lacks the grant is refused when BReg starts, since startup compiles it again. The startup error is generic, so run `bregctl check` on the source project to see the code. Migration: add the grant and rebuild the package; an unrestricted `reference` grant keeps today's reach and reads nothing. Projects generated by `bregctl module add consent` now give the consent link steward such a grant on the subject Record type. +- New grant operation `reference`: it lets the profile's direct writes name records of the Record type, within the grant's row boundaries and membership entries, and serves no route. It grants no other operation, field, read path, lookup, filter, count, revision, export or spatial access (`breg.access-profile.reference-exclusive`), a derived field cannot read its Record type through it (`breg.disclosure.derived-reads-unreadable-source`), a grant no writable reference field of its profile uses is refused (`breg.access.reference-grant-unused`), and an unrestricted one is not reported as `breg.access.profile-unrestricted-rows`. - BREAKING: BReg authoring diagnostics use Record type codes. Migration: update diagnostic code matchers using these mappings. - `breg.manifest.entity-id-collision` → `breg.manifest.record-type-id-collision` diff --git a/products/breg/contracts/security-invariant-matrix.yaml b/products/breg/contracts/security-invariant-matrix.yaml index 183b9f5ec5..10e136248a 100644 --- a/products/breg/contracts/security-invariant-matrix.yaml +++ b/products/breg/contracts/security-invariant-matrix.yaml @@ -306,3 +306,4 @@ invariants: - {"id": "BREG-SEC-287", "state": "enforced", "targetWave": "W5", "threat": "An agent, service or task-grant profile is given a review-context field that shows an additional form.", "enforcementPoint": "Project compilation refuses readableContextFields that include an additional-form field on a profile with actorKind agent or service or with a taskGrant.", "refusal": "Refuse compilation with breg.additional-form.context-reader-invalid.", "negativeId": "BREG-NEG-287", "negativeTest": {"path": "crates/registry-breg/tests/proposal_additional_forms.rs", "name": "an_additional_form_context_field_is_refused_to_profiles_no_person_reads_through"}} - {"id": "BREG-SEC-288", "state": "enforced", "targetWave": "W5", "threat": "A message or mark-read by the party or the office, landing while the automatic worker applies an approved request, makes the Apply fail and hands the request back to the party.", "enforcementPoint": "The worker's Apply is fenced by its claimed lease, the submission version and the frozen effect digest inside the Apply transaction, not by a Proposal ETag read in an earlier one.", "refusal": "Apply the request; thread activity changes the revision but never what is applied.", "negativeId": "BREG-NEG-288", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "thread_activity_during_automatic_application_does_not_strand_the_request"}} - {"id": "BREG-SEC-289", "state": "enforced", "targetWave": "W5", "threat": "Office staff whose grant does not reach a Proposal confirm that it exists from how a thread route answers a malformed request.", "enforcementPoint": "Every thread route checks that the Proposal is visible to the admitted caller, under row boundaries and memberships, before it reads any header, query or body.", "refusal": "Conceal a hidden Proposal with 404 resource.not-found exactly as an unknown one.", "negativeId": "BREG-NEG-289", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_unknown_one"}} + - {"id": "BREG-SEC-290", "state": "enforced", "targetWave": "W5", "threat": "A direct Record write names a referenced record the caller cannot read.", "enforcementPoint": "The write transaction reads each reference the item sets under the caller's own get or reference grant on the referenced Record type, using current transaction state. The probe requires an available row context and a validated reason when that grant requires one. Project compilation requires the grant. The reference-only policy applies only during the probe for that Record type.", "refusal": "An unauthorized, missing or tombstoned target yields 409 mutation.conflict for direct writes and 412 precondition.failed for ingestion. The same refusal applies when the attempted target grant requires a reason the request cannot supply. Refuse at compile with breg.access.reference-target-ungranted, breg.access-profile.reference-exclusive or breg.access.reference-grant-unused.", "negativeId": "BREG-NEG-290", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_direct_write_names_only_records_the_writer_can_read"}} diff --git a/products/breg/contracts/security-test-traceability.yaml b/products/breg/contracts/security-test-traceability.yaml index 690ccc0a7c..d4842ab4f3 100644 --- a/products/breg/contracts/security-test-traceability.yaml +++ b/products/breg/contracts/security-test-traceability.yaml @@ -349,3 +349,4 @@ traceability: - {"id": "BREG-SEC-287", "state": "enforced", "negativeId": "BREG-NEG-287", "negativeTest": {"path": "crates/registry-breg/tests/proposal_additional_forms.rs", "name": "an_additional_form_context_field_is_refused_to_profiles_no_person_reads_through"}} - {"id": "BREG-SEC-288", "state": "enforced", "negativeId": "BREG-NEG-288", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "thread_activity_during_automatic_application_does_not_strand_the_request"}} - {"id": "BREG-SEC-289", "state": "enforced", "negativeId": "BREG-NEG-289", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_unknown_one"}} + - {"id": "BREG-SEC-290", "state": "enforced", "negativeId": "BREG-NEG-290", "negativeTest": {"path": "crates/registry-breg/tests/support/membership_write_journeys.rs", "name": "a_direct_write_names_only_records_the_writer_can_read"}} diff --git a/products/breg/fixtures/consent-land-registry/registry.yaml b/products/breg/fixtures/consent-land-registry/registry.yaml index d316dd5417..edffe5d0d4 100644 --- a/products/breg/fixtures/consent-land-registry/registry.yaml +++ b/products/breg/fixtures/consent-land-registry/registry.yaml @@ -634,6 +634,14 @@ "principal", "active" ] + }, + { + "recordType": "tenure-right", + "rowBoundaries": "unrestricted", + "operations": [ + "reference" + ], + "readableFields": [] } ] } diff --git a/products/breg/fixtures/consent-person-registry/registry.yaml b/products/breg/fixtures/consent-person-registry/registry.yaml index 75d2a6a0c2..ce74cec0d4 100644 --- a/products/breg/fixtures/consent-person-registry/registry.yaml +++ b/products/breg/fixtures/consent-person-registry/registry.yaml @@ -210,6 +210,10 @@ accessProfiles: operations: [create, get, list, patch] readableFields: [subject, principal, active] writableFields: [subject, principal, active] + - recordType: person + rowBoundaries: unrestricted + operations: [reference] + readableFields: [] person-consent-recipient: principalClaim: registry_principal requiredScopes: ['consent:person:read'] diff --git a/products/breg/scripts/test_validate_product.py b/products/breg/scripts/test_validate_product.py index 9b3bbd11be..800e298e9b 100644 --- a/products/breg/scripts/test_validate_product.py +++ b/products/breg/scripts/test_validate_product.py @@ -74,7 +74,7 @@ def test_security_range_and_negative_ids_are_closed(self) -> None: ) extension_rows = matrix["invariants"][24:] self.assertEqual( - [f"BREG-NEG-{index:02d}" for index in range(25, 290) if index not in {61, 62}], + [f"BREG-NEG-{index:02d}" for index in range(25, 291) if index not in {61, 62}], [invariant["negativeId"] for invariant in extension_rows], ) for invariant in extension_rows: diff --git a/products/breg/scripts/validate_product.py b/products/breg/scripts/validate_product.py index ce82b32fca..f87af0b0da 100644 --- a/products/breg/scripts/validate_product.py +++ b/products/breg/scripts/validate_product.py @@ -31,7 +31,7 @@ CONTRACT_STATES = {"enforced", "partial", "planned"} V1_REQUIREMENT_IDS = tuple(f"BREG-V1-{index:02d}" for index in range(1, 45)) ACCEPTANCE_JOURNEY_IDS = tuple(f"BREG-J{index:02d}" for index in range(1, 25)) -SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 290) if index not in {61, 62}) +SECURITY_INVARIANT_IDS = tuple(f"BREG-SEC-{index:02d}" for index in range(1, 291) if index not in {61, 62}) ACCEPTANCE_FIXTURES = { "BREG-J01": ("asset-site-placement", "acceptance/asset-site-placement"), "BREG-J02": ("asset-site-placement", "acceptance/asset-site-placement"), From e904510150c8f3649a299769dadddb36ae55ab91 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:17:36 +0000 Subject: [PATCH 07/96] test(breg): cover reference reasons in direct and ingestion Batch Provisional authored source for the protected v0.52 replay. Signed-off-by: Jeremi Joslin --- .../tests/postgres_ingestion_runs.rs | 220 +++++++++++++++--- 1 file changed, 183 insertions(+), 37 deletions(-) diff --git a/crates/registry-breg/tests/postgres_ingestion_runs.rs b/crates/registry-breg/tests/postgres_ingestion_runs.rs index 224e4e4faf..0d0b7c070f 100644 --- a/crates/registry-breg/tests/postgres_ingestion_runs.rs +++ b/crates/registry-breg/tests/postgres_ingestion_runs.rs @@ -15,7 +15,7 @@ use std::time::Duration; use axum::body::{to_bytes, Body}; use axum::http::{HeaderName, HeaderValue, Method, Request, StatusCode}; -use base64::engine::general_purpose::STANDARD as BASE64; +use base64::engine::general_purpose::{STANDARD as BASE64, URL_SAFE_NO_PAD}; use base64::Engine as _; use client_http::ClientHttp; use postgres_harness::TestDatabase; @@ -25,7 +25,7 @@ use registry_breg::api::{ }; use registry_breg::audit::RegistryAudit; use registry_breg::compiler::{compile_project, CompileProfile}; -use registry_breg::contract::parse_project_json; +use registry_breg::contract::{parse_module_json, parse_project_json}; use registry_breg::cursor::CursorCodec; use registry_breg::field_encryption::{FieldEncryptionProvider, FieldEncryptionService}; use registry_breg::import_authority::{ @@ -4296,47 +4296,20 @@ async fn an_outside_boundary_ingestion_item_remains_a_value_free_precondition_re #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn an_unavailable_ingestion_reference_is_a_value_free_precondition_refusal() { - let mut source: Value = serde_json::from_str(&format!("{FIXTURE_HEAD}{FIXTURE_TAIL}")).unwrap(); - source["recordTypes"]["widget"]["fields"] + let mut source = widget_project_with_ledger_reference(); + source["accessProfiles"]["operator"]["permissions"]["records"] .as_array_mut() .unwrap() - .push( - json!({"id":"ledger","type":"reference","target":"ledger","classification":"public"}), - ); - let grants = source["accessProfiles"]["operator"]["permissions"]["records"] - .as_array_mut() - .unwrap(); - grants[0]["writableFields"] - .as_array_mut() - .unwrap() - .push(json!("ledger")); - grants.push(json!({ - "recordType":"ledger","operations":["reference"], - "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] - })); + .push(json!({ + "recordType":"ledger","operations":["reference"], + "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + })); let project = parse_project_json(&serde_json::to_vec(&source).unwrap()).unwrap(); let registry = compile_project(&project, &[], CompileProfile::Authoring).unwrap(); let harness = IngestionHarness::from_registry(Arc::new(registry)).await; let claims = operator_claims(PRINCIPAL, "zone-a"); - let outside = Uuid::new_v4().to_string(); - let inside = Uuid::new_v4().to_string(); - let ledger = &harness.registry.entities()["ledger"]; - harness - .database - .admin - .execute( - &format!( - "INSERT INTO registry_data.\"{}\" (record_id, active_package_revision, \"{}\", \"{}\") - VALUES ($1::text::uuid, $3, 'zone-b', 'ledger-canary'), - ($2::text::uuid, $3, 'zone-a', 'in-reach')", - ledger.physical_table, - ledger.fields["jurisdiction"].physical_name, - ledger.fields["memo"].physical_name, - ), - &[&outside, &inside, &harness.identity.activation_id], - ) - .await - .expect("seed synthetic ledgers inside and outside the run's boundary"); + let outside = harness.seed_ledger("zone-b", "ledger-canary").await; + let inside = harness.seed_ledger("zone-a", "in-reach").await; let chunk_plan = |target: &str| { let items = [json!({"operation":"create","data":{ @@ -4393,6 +4366,143 @@ async fn an_unavailable_ingestion_reference_is_a_value_free_precondition_refusal harness.database.cleanup().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn direct_batch_requires_the_reference_targets_reason_atomically() { + let (harness, items) = reason_required_reference_batch().await; + let claims = operator_claims(PRINCIPAL, "zone-a"); + let mut headers = vec![ + ("content-type", "application/json"), + ("idempotency-key", "direct-reason-batch"), + ]; + let body = serde_json::to_vec(&json!({"items":items})).unwrap(); + let response = send( + &harness.app, + Method::POST, + "/v1/records/widgets:batch", + Some(claims.clone()), + &headers, + body.clone(), + ) + .await; + let status = response.status(); + let problem = body_json(response).await; + assert_eq!(status, StatusCode::CONFLICT, "{problem}"); + assert_eq!(problem["code"], "mutation.conflict"); + assert_no_reference_batch_commit(&harness).await; + + let reason = URL_SAFE_NO_PAD.encode("Link the authorized ledger"); + headers.push(("registry-access-reason", &reason)); + let response = send( + &harness.app, + Method::POST, + "/v1/records/widgets:batch", + Some(claims), + &headers, + body, + ) + .await; + let status = response.status(); + let committed = body_json(response).await; + assert_eq!(status, StatusCode::OK, "{committed}"); + assert_eq!(committed["results"].as_array().unwrap().len(), 2); + assert_eq!(durable_widget_count(&harness).await, 2); + harness.database.cleanup().await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn ingestion_batch_requires_the_reference_targets_reason_atomically() { + let (harness, items) = reason_required_reference_batch().await; + let claims = operator_claims(PRINCIPAL, "zone-a"); + let chunks = plan_chunks(&items, 3); + let run_id = harness.create_run(&claims, &chunks).await; + let path = format!("/v1/records/widgets/ingestion-runs/{run_id}/chunks"); + let chunk = chunk_body(&chunks, 0); + let response = harness.post_json(&path, &claims, chunk.clone()).await; + let status = response.status(); + let problem = body_json(response).await; + assert_eq!(status, StatusCode::PRECONDITION_FAILED, "{problem}"); + assert_eq!(problem["code"], "precondition.failed"); + assert_eq!(problem["detail"], "The mutation precondition failed."); + let run = harness.read_run(&claims, &run_id).await; + assert_eq!(run["status"], "open"); + assert_eq!(run["nextChunkIndex"], 0); + assert_eq!(run["committedItems"], 0); + assert_eq!(run["lastAttempt"]["outcome"], "refused"); + assert_no_reference_batch_commit(&harness).await; + + let reason = URL_SAFE_NO_PAD.encode("Link the authorized ledger"); + let response = send( + &harness.app, + Method::POST, + &path, + Some(claims), + &[ + ("content-type", "application/json"), + ("registry-access-reason", &reason), + ], + serde_json::to_vec(&chunk).unwrap(), + ) + .await; + let status = response.status(); + let committed = body_json(response).await; + assert_eq!(status, StatusCode::OK, "{committed}"); + assert_eq!(committed["run"]["status"], "complete"); + assert_eq!(committed["run"]["nextChunkIndex"], 1); + assert_eq!(committed["run"]["committedItems"], 2); + assert_eq!(committed["receipt"]["replayed"], false); + assert_eq!(durable_widget_count(&harness).await, 2); + harness.database.cleanup().await; +} + +async fn reason_required_reference_batch() -> (IngestionHarness, Vec) { + let project = + parse_project_json(&serde_json::to_vec(&widget_project_with_ledger_reference()).unwrap()) + .expect("reference fixture parses"); + // The target's module grant owns the reason requirement. The widget's + // Batch grant has no reason precondition of its own. + let ledger = parse_module_json( + &serde_json::to_vec(&json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1", + "kind":"BRegModule","id":"ledger-authority","version":"1", + "extendRecordTypes":{"ledger":{"accessProfiles":{"operator":{ + "principalClaim":"registry_principal","requiredScopes":["records:write"], + "requiredPurposes":["case-management","case-review"], + "operations":["reference"],"requireAccessReason":true, + "rowBoundaries":[{"field":"jurisdiction","claim":"jurisdiction","operator":"equals"}] + }}}} + })) + .unwrap(), + ) + .expect("ledger module parses"); + let registry = compile_project(&project, &[ledger], CompileProfile::Authoring) + .expect("reason-required reference fixture compiles"); + let harness = IngestionHarness::from_registry(Arc::new(registry)).await; + let target = harness.seed_ledger("zone-a", "in-reach").await; + let mut items = announce_items("reason-batch", 2); + // A reference-free first item must roll back if the second is refused. + items[1]["data"]["ledger"] = json!(target); + (harness, items) +} + +async fn assert_no_reference_batch_commit(harness: &IngestionHarness) { + assert_eq!(durable_widget_count(harness).await, 0); + let durable = harness + .database + .admin + .query_one( + "SELECT + (SELECT count(*) FROM registry_internal.registry_revisions WHERE entity_id = 'widget'), + (SELECT count(*) FROM registry_internal.registry_idempotency), + (SELECT count(*) FROM registry_internal.registry_ingestion_run_chunks)", + &[], + ) + .await + .expect("durable mutation state is inspectable"); + assert_eq!(durable.get::<_, i64>(0), 0, "no widget revision"); + assert_eq!(durable.get::<_, i64>(1), 0, "no idempotency receipt"); + assert_eq!(durable.get::<_, i64>(2), 0, "no chunk receipt"); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn listing_runs_filters_by_status_and_input_digest() { let harness = IngestionHarness::create().await; @@ -4949,6 +5059,26 @@ impl IngestionHarness { Self::from_registry(Arc::new(compiled_registry())).await } + async fn seed_ledger(&self, jurisdiction: &str, memo: &str) -> String { + let target = Uuid::new_v4(); + let ledger = &self.registry.entities()["ledger"]; + self.database + .admin + .execute( + &format!( + "INSERT INTO registry_data.\"{}\" (record_id, active_package_revision, \"{}\", \"{}\") + VALUES ($1, $2, $3, $4)", + ledger.physical_table, + ledger.fields["jurisdiction"].physical_name, + ledger.fields["memo"].physical_name, + ), + &[&target, &self.identity.activation_id, &jurisdiction, &memo], + ) + .await + .expect("seed an active synthetic ledger"); + target.to_string() + } + /// Build the same harness around one caller-chosen compiled registry, so a /// test can pin authored shapes the shared fixture does not carry. async fn from_registry(registry: Arc) -> Self { @@ -5505,6 +5635,22 @@ fn compiled_registry() -> registry_breg::CompiledRegistry { .expect("ingestion fixture compiles to trusted inventories") } +fn widget_project_with_ledger_reference() -> Value { + let mut project: Value = + serde_json::from_str(&format!("{FIXTURE_HEAD}{FIXTURE_TAIL}")).unwrap(); + project["recordTypes"]["widget"]["fields"] + .as_array_mut() + .unwrap() + .push( + json!({"id":"ledger","type":"reference","target":"ledger","classification":"public"}), + ); + project["accessProfiles"]["operator"]["permissions"]["records"][0]["writableFields"] + .as_array_mut() + .unwrap() + .push(json!("ledger")); + project +} + fn compiled_registry_with_created_webhook() -> registry_breg::CompiledRegistry { let fixture = format!("{FIXTURE_HEAD}{FIXTURE_TAIL}").replacen( r#"{"phase":"after","id":"widget-created","trigger":"created","projection":["label"]}"#, From c62909df380d61f558cdd2e4c2b98863e6286cba Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:34:16 +0000 Subject: [PATCH 08/96] fix(breg): enforce bare reference grant field selection Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/compiler.rs | 21 +++++++++++++------ .../tests/reference_authority_authoring.rs | 21 +++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index 6f0e2ecd6a..a84f6b52fc 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -4277,7 +4277,14 @@ fn resolve_readable_fields( for profile in &mut profiles { let consent_scope = (!profile.require_consent.is_empty()) .then(|| format!("recordTypes[id={id}].accessProfiles[id={}]", profile.id)); - if let Some(ceiling) = profile.readable_fields_ceiling.take() { + // Reference exclusivity checks the authored selection even when it + // would select no fields. + let ceiling = if profile.operations.contains(&Operation::Reference) { + None + } else { + profile.readable_fields_ceiling.take() + }; + if let Some(ceiling) = ceiling { if let Some(path) = &consent_scope { errors.push(consent_ceiling_refusal(format!("{path}.readableFields"))); } @@ -6055,11 +6062,6 @@ fn reaches<'a>( .any(|(_, next)| reaches(next, target, edges, visited)) } -/// An `import` grant creates records only through a durable ingestion run, -/// so it needs the entity's chunk bounds and no raw batch grant beside it on -/// the entity: a batch grant would write the same records outside any import -/// authority, leaving the authority bounding nothing. The creator a run is -/// scoped to is the principal claim every profile names. /// Whether a `reference` grant carries only what it may: the operation, the /// rows it may name (row boundaries and membership entries), and the members /// its profile sets for every grant. Every member is named, so a member added @@ -6083,6 +6085,7 @@ fn reference_grant_is_bare(access: &AccessProfileSource) -> bool { operations, // Everything below serves or shapes a read or a write. readable_fields, + readable_fields_ceiling, readable_attachments, writable_fields, filterable_fields, @@ -6099,6 +6102,7 @@ fn reference_grant_is_bare(access: &AccessProfileSource) -> bool { } = access; operations.len() == 1 && readable_fields.is_empty() + && readable_fields_ceiling.is_none() && readable_attachments.is_empty() && writable_fields.is_empty() && filterable_fields.is_empty() @@ -6114,6 +6118,11 @@ fn reference_grant_is_bare(access: &AccessProfileSource) -> bool { && !allow_data_export } +/// An `import` grant creates records only through a durable ingestion run, +/// so it needs the entity's chunk bounds and no raw batch grant beside it on +/// the entity: a batch grant would write the same records outside any import +/// authority, leaving the authority bounding nothing. The creator a run is +/// scoped to is the principal claim every profile names. fn validate_import_grant( entity: &EntitySource, access: &AccessProfileSource, diff --git a/crates/registry-breg/tests/reference_authority_authoring.rs b/crates/registry-breg/tests/reference_authority_authoring.rs index 7e5d7e3ea2..755a2f70ae 100644 --- a/crates/registry-breg/tests/reference_authority_authoring.rs +++ b/crates/registry-breg/tests/reference_authority_authoring.rs @@ -306,6 +306,27 @@ fn a_reference_grant_grants_nothing_else() { } } +#[test] +fn a_reference_grant_refuses_a_field_ceiling_even_when_no_fields_match() { + let writable = &["jurisdiction", "name", "target"]; + let mut grant = reference_grant(json!([ + {"field":"jurisdiction","claim":"jurisdiction","operator":"equals"} + ])); + let compiled = + compile(&project(writable, Some(grant.clone()))).expect("a bare reference grant compiles"); + assert!(compiled.entities()["target"].access_profiles["linker"] + .readable_fields + .is_empty()); + + // Both target fields are internal, so this ceiling would select no fields. + grant["readableFields"] = json!({"upToClassification":"public"}); + assert_refused_with( + &project(writable, Some(grant)), + REFERENCE_EXCLUSIVE, + TARGET_GRANT, + ); +} + #[test] fn a_reference_grant_serves_no_read_path() { // `target` reaches `item` through `source`. A read path grant would serve From 04c2cb6444b6971a7d5580a25049b1b332f798ba Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:48:58 +0000 Subject: [PATCH 09/96] fix(breg): account for the Reference grant in the client inventory Signed-off-by: Jeremi Joslin --- products/breg/contracts/client-capabilities.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/products/breg/contracts/client-capabilities.json b/products/breg/contracts/client-capabilities.json index ea98833423..b57ff2ea44 100644 --- a/products/breg/contracts/client-capabilities.json +++ b/products/breg/contracts/client-capabilities.json @@ -12,7 +12,8 @@ "Revisions", "Snapshot", "Invoke", - "Start" + "Start", + "Reference" ], "queryKinds": [ "List", From 45f2e9af156147bde1ac04148ccb65cae9cdfa3e Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:09:12 +0000 Subject: [PATCH 10/96] fix(breg): remove duplicate provenance schema default Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/contract/sentinel.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/registry-breg/src/contract/sentinel.rs b/crates/registry-breg/src/contract/sentinel.rs index 43f3769eaa..ec6e8674c9 100644 --- a/crates/registry-breg/src/contract/sentinel.rs +++ b/crates/registry-breg/src/contract/sentinel.rs @@ -913,7 +913,6 @@ pub(super) struct AuthoredEntityPermission { feature = "schema", schemars(with = "UniqueSet", extend("default" = [])) )] - #[cfg_attr(feature = "schema", schemars(extend("default" = [])))] provenance_fields: Vec, #[serde(default)] allow_data_export: bool, From b728ed35b71e63713f8e3fbcf31bc4df89af4686 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:10:33 +0000 Subject: [PATCH 11/96] fix(breg): wire proposal message types into history erasure tests Signed-off-by: Jeremi Joslin --- crates/registry-breg/tests/postgres_history_erasure.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/registry-breg/tests/postgres_history_erasure.rs b/crates/registry-breg/tests/postgres_history_erasure.rs index 9fe237d6f8..c49d39c078 100644 --- a/crates/registry-breg/tests/postgres_history_erasure.rs +++ b/crates/registry-breg/tests/postgres_history_erasure.rs @@ -21,9 +21,15 @@ mod history_schema { mod model { pub use registry_breg::model::*; } +mod mutation { + pub use registry_breg::mutation::MutationError; +} mod plan { pub use registry_breg::plan::MAX_PLAN_FIELD_MUTATIONS; } +mod problem_location { + pub use registry_breg::problem_location::RequestLocation; +} #[path = "../src/history_store.rs"] #[allow(dead_code)] mod history_store; @@ -103,6 +109,9 @@ mod idempotency; #[path = "support/postgres_harness.rs"] #[allow(dead_code)] mod postgres_harness; +#[path = "../src/proposal_messages.rs"] +#[allow(dead_code)] +mod proposal_messages; #[path = "../src/stored_bytes.rs"] #[allow(dead_code)] mod stored_bytes; From 05f0cdde8957b79489c6502134b864c13e21bf4b Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:13:06 +0000 Subject: [PATCH 12/96] fix(breg): gate sealed project unit test on runtime Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/contract.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/registry-breg/src/contract.rs b/crates/registry-breg/src/contract.rs index b8e73b38da..5a465d998b 100644 --- a/crates/registry-breg/src/contract.rs +++ b/crates/registry-breg/src/contract.rs @@ -8101,6 +8101,7 @@ mod tests { } } + #[cfg(feature = "runtime")] #[test] fn only_a_sealed_project_translates_historical_proposal_ownership() { let current = include_str!("../../../products/breg/examples/minimal/registry.yaml"); From 6790774b3f84f1289a1f6c966591c3f18b784ff6 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:22:41 +0000 Subject: [PATCH 13/96] test(review): format the form-want compatibility case Signed-off-by: Jeremi Joslin --- crates/registry-review-client/tests/http_boundary.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/registry-review-client/tests/http_boundary.rs b/crates/registry-review-client/tests/http_boundary.rs index f7df709007..8ae4bd3eaf 100644 --- a/crates/registry-review-client/tests/http_boundary.rs +++ b/crates/registry-review-client/tests/http_boundary.rs @@ -2718,7 +2718,10 @@ async fn ask_responses_validate_known_form_wants() { (json!({"kind":"document"}), true), (json!({"kind":"answer","formId":"extra-details"}), true), (json!({"kind":"document","formId":"extra-details"}), true), - (json!({"kind":"form","form":"extra-details","futureWantMember":true}), true), + ( + json!({"kind":"form","form":"extra-details","futureWantMember":true}), + true, + ), (json!({"kind":"form","formId":"extra-details"}), false), (json!({"kind":"form","form":"Invalid"}), false), (json!({"kind":"future-want"}), false), From 5eec64c7b0c1bb7b7c8c19548418b2ca8342344d Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:45:53 +0000 Subject: [PATCH 14/96] chore(breg): format lifecycle artifact imports Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/artifacts.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/registry-breg/src/artifacts.rs b/crates/registry-breg/src/artifacts.rs index 4f882a410b..66df030f3d 100644 --- a/crates/registry-breg/src/artifacts.rs +++ b/crates/registry-breg/src/artifacts.rs @@ -19,10 +19,10 @@ use crate::model::{ CompiledActionInput, CompiledActionInventory, CompiledActionRoute, CompiledEntity, CompiledEventDeliveryInventory, CompiledManifestProjection, CompiledMetadataInventory, CompiledModuleIdentity, CompiledPlanEffect, CompiledPlanMutation, CompiledPlanValue, - CompiledQueryInventory, CompiledQueryKind, CompiledQueryOperation, CompiledQueryTemporalBinding, - CompiledQueryTemporalSemantics, CompiledQueryTemporalValueKind, CompiledRecipients, - CompiledRevisionKind, CompiledRoute, CompiledRouteInventory, CompiledStatisticalDataset, - DisclosureWithhold, HttpMethod, + CompiledQueryInventory, CompiledQueryKind, CompiledQueryOperation, + CompiledQueryTemporalBinding, CompiledQueryTemporalSemantics, CompiledQueryTemporalValueKind, + CompiledRecipients, CompiledRevisionKind, CompiledRoute, CompiledRouteInventory, + CompiledStatisticalDataset, DisclosureWithhold, HttpMethod, }; use crate::physical_names::{hex_prefix, PhysicalNameInventory}; use crate::record_profile::{link_header_value, CONTEXT_IDENTIFIER, PROFILE_IDENTIFIER}; From 527aeecfd9e7570501a8f295a3d353e9e9504441 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:40:48 +0000 Subject: [PATCH 15/96] fix(identifiers): refresh Draft B catalog and authoring schemas Signed-off-by: Jeremi Joslin --- .../authoring/registry-module.schema.json | 221 ++++++++++-- .../authoring/registry-project.schema.json | 306 ++++++++++++---- .../identifiers/generated/catalog.v1.json | 326 ++++++++++++------ 3 files changed, 642 insertions(+), 211 deletions(-) diff --git a/products/breg/generated/authoring/registry-module.schema.json b/products/breg/generated/authoring/registry-module.schema.json index 7f55675f08..c47ca91786 100644 --- a/products/breg/generated/authoring/registry-module.schema.json +++ b/products/breg/generated/authoring/registry-module.schema.json @@ -868,6 +868,59 @@ ], "type": "object" }, + "AdditionalFormSource": { + "additionalProperties": false, + "properties": { + "inputs": { + "items": { + "allOf": [ + { + "$ref": "#/$defs/ActionInputSource" + }, + { + "not": { + "required": [ + "pattern" + ] + }, + "properties": { + "type": { + "not": { + "enum": [ + "reference", + "crs84-point", + "crs84-polygon", + "structured", + "vocabulary-code" + ] + } + } + }, + "required": [ + "type" + ], + "type": "object" + } + ], + "unevaluatedProperties": false + }, + "maxItems": 16, + "minItems": 1, + "type": "array" + }, + "maximumCount": { + "default": 8, + "format": "uint8", + "maximum": 32, + "minimum": 1, + "type": "integer" + } + }, + "required": [ + "inputs" + ], + "type": "object" + }, "AttachmentSlotSource": { "additionalProperties": false, "properties": { @@ -2885,32 +2938,24 @@ ], "type": "string" }, - "MembershipBoundarySource": { + "MembershipDeclarationSource": { "additionalProperties": false, - "description": "A one-hop current membership requirement, combined with every other row boundary.\nThe root field and membership key must reference the same entity. The active\nfield is Boolean, and principalField matches the profile's verified principal.", + "description": "Stored fields that establish a current membership fact.", "properties": { - "activeField": { - "type": "string" - }, - "field": { - "type": "string" - }, - "membershipKeyField": { - "type": "string" + "active": { + "$ref": "#/$defs/LocalId" }, - "membershipRecordType": { - "type": "string" + "key": { + "$ref": "#/$defs/LocalId" }, - "principalField": { - "type": "string" + "principal": { + "$ref": "#/$defs/LocalId" } }, "required": [ - "field", - "membershipRecordType", - "membershipKeyField", - "principalField", - "activeField" + "key", + "principal", + "active" ], "type": "object" }, @@ -3018,6 +3063,11 @@ "const": "import", "description": "Create records through a durable ingestion run, and nothing else. The\ngrant is enabled only while an operator-opened import authority is open\nfor the entity and profile. It declares no item route and no raw batch\nroute, and change control does not count it as a direct write.", "type": "string" + }, + { + "const": "reference", + "description": "Let the profile's direct writes name records of this Record type, and\nnothing else. A write naming a record reads it under this grant's row\nreach; the grant serves no route and reads no field.", + "type": "string" } ] }, @@ -3105,6 +3155,23 @@ }, "ProposalContextValueSource": { "oneOf": [ + { + "additionalProperties": false, + "properties": { + "form": { + "$ref": "#/$defs/LocalId" + }, + "type": { + "const": "additional-form", + "type": "string" + } + }, + "required": [ + "type", + "form" + ], + "type": "object" + }, { "additionalProperties": false, "properties": { @@ -3208,6 +3275,7 @@ "asked", "answered", "added", + "messaged", "started", "edited", "submitted", @@ -3249,9 +3317,35 @@ ], "type": "object" }, + "ProposalMessagesSource": { + "additionalProperties": false, + "description": "The message thread on each Proposal of an Action. It needs no review.", + "properties": { + "maximumCount": { + "default": 200, + "description": "The most messages each side, the party and the office, writes on one\nProposal's thread.", + "format": "uint32", + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + }, + "type": "object" + }, "ProposalPolicySource": { "additionalProperties": false, "properties": { + "additionalForms": { + "additionalProperties": { + "$ref": "#/$defs/AdditionalFormSource" + }, + "description": "Typed information a reviewed Proposal can declare separately from its Action inputs.", + "maxProperties": 8, + "propertyNames": { + "$ref": "#/$defs/LocalId" + }, + "type": "object" + }, "additions": { "$ref": "#/$defs/AdditionSlotSource" }, @@ -3276,6 +3370,10 @@ }, "type": "array" }, + "messages": { + "$ref": "#/$defs/ProposalMessagesSource", + "description": "One message thread between the party and the office. Presence opens it." + }, "retention": { "$ref": "#/$defs/ProposalRetentionSource" }, @@ -3284,6 +3382,10 @@ }, "reviewContext": { "$ref": "#/$defs/ProposalReviewContextSource" + }, + "subject": { + "$ref": "#/$defs/ProposalSubjectSource", + "description": "The person the Proposal is about, frozen at its first Submit." } }, "required": [ @@ -3391,6 +3493,22 @@ } ] }, + "ProposalSubjectSource": { + "additionalProperties": false, + "description": "Where a Proposal's subject comes from: an Action input, or a field of the\nRecord a reference input names.", + "properties": { + "field": { + "type": "string" + }, + "input": { + "type": "string" + } + }, + "required": [ + "input" + ], + "type": "object" + }, "ProvenanceFieldSource": { "description": "A member of a revision's `changeContext` a profile may read. Each value\nis spelled as the member it names is (CFG-NAME-2).", "enum": [ @@ -3803,20 +3921,62 @@ "type": "string" }, { - "description": "Reach the rows every listed boundary binds to the caller's claims.", + "description": "Reach the rows bounded by every listed claim or membership entry.", "items": { - "$ref": "#/$defs/RowBoundarySource" + "$ref": "#/$defs/RowBoundaryEntry" }, "minItems": 1, "type": "array" }, { "$ref": "#/$defs/RowBoundarySetReference", - "description": "Reach the rows every boundary of a named set binds to the caller's claims." + "description": "Reach the rows bounded by every entry in a named set." } ], "description": "The rows a permission reaches: the keyword `unrestricted`, a list of at\nleast one row boundary, or a reference to a named list of them." }, + "RowBoundaryEntry": { + "additionalProperties": false, + "description": "A claim entry {field, claim, operator} or a membership entry {field, membership}.", + "else": { + "required": [ + "claim", + "operator" + ] + }, + "if": { + "required": [ + "membership" + ] + }, + "properties": { + "claim": { + "type": "string" + }, + "field": { + "type": "string" + }, + "membership": { + "$ref": "#/$defs/LocalId" + }, + "operator": { + "$ref": "#/$defs/BoundaryOperator" + } + }, + "required": [ + "field" + ], + "then": { + "properties": { + "claim": false, + "field": { + "$ref": "#/$defs/LocalId" + }, + "operator": false + } + }, + "type": "object" + }, "RowBoundarySetReference": { "additionalProperties": false, "description": "A reference to a named list of row boundaries the file declares under\n`rowBoundarySets`. The reader expands a reference into the set's boundaries\nbefore the typed model is decoded, so the compiler never holds one.", @@ -4571,12 +4731,6 @@ }, "type": "array" }, - "membershipBoundaries": { - "items": { - "$ref": "#/$defs/MembershipBoundarySource" - }, - "type": "array" - }, "operations": { "items": { "$ref": "#/$defs/Operation" @@ -4825,12 +4979,6 @@ }, "type": "array" }, - "membershipBoundaries": { - "items": { - "$ref": "#/$defs/MembershipBoundarySource" - }, - "type": "array" - }, "operations": { "items": { "$ref": "#/$defs/Operation" @@ -5076,6 +5224,9 @@ }, "type": "array" }, + "membership": { + "$ref": "#/$defs/MembershipDeclarationSource" + }, "mutationMode": { "$ref": "#/$defs/MutationMode" }, @@ -5125,7 +5276,7 @@ "rowBoundarySets": { "additionalProperties": { "items": { - "$ref": "#/$defs/RowBoundarySource" + "$ref": "#/$defs/RowBoundaryEntry" }, "minItems": 1, "type": "array" diff --git a/products/breg/generated/authoring/registry-project.schema.json b/products/breg/generated/authoring/registry-project.schema.json index a23f45bdfa..2f044a0bad 100644 --- a/products/breg/generated/authoring/registry-project.schema.json +++ b/products/breg/generated/authoring/registry-project.schema.json @@ -659,7 +659,7 @@ "targets": { "default": [], "items": { - "$ref": "#/$defs/ActionTargetPermissionSource" + "$ref": "#/$defs/AuthoredTargetPermission" }, "type": "array" } @@ -833,23 +833,6 @@ ], "type": "object" }, - "ActionTargetPermissionSource": { - "additionalProperties": false, - "properties": { - "recordType": { - "type": "string" - }, - "rowBoundaries": { - "$ref": "#/$defs/RowBoundaries", - "description": "Row reach: `unrestricted`, or a list of at least one row boundary." - } - }, - "required": [ - "recordType", - "rowBoundaries" - ], - "type": "object" - }, "ActionTargetSource": { "additionalProperties": false, "properties": { @@ -921,6 +904,59 @@ ], "type": "object" }, + "AdditionalFormSource": { + "additionalProperties": false, + "properties": { + "inputs": { + "items": { + "allOf": [ + { + "$ref": "#/$defs/ActionInputSource" + }, + { + "not": { + "required": [ + "pattern" + ] + }, + "properties": { + "type": { + "not": { + "enum": [ + "reference", + "crs84-point", + "crs84-polygon", + "structured", + "vocabulary-code" + ] + } + } + }, + "required": [ + "type" + ], + "type": "object" + } + ], + "unevaluatedProperties": false + }, + "maxItems": 16, + "minItems": 1, + "type": "array" + }, + "maximumCount": { + "default": 8, + "format": "uint8", + "maximum": 32, + "minimum": 1, + "type": "integer" + } + }, + "required": [ + "inputs" + ], + "type": "object" + }, "AttachmentSlotSource": { "additionalProperties": false, "properties": { @@ -955,6 +991,22 @@ ], "type": "object" }, + "AuthoredTargetPermission": { + "additionalProperties": false, + "properties": { + "recordType": { + "type": "string" + }, + "rowBoundaries": { + "$ref": "#/$defs/RowBoundaries" + } + }, + "required": [ + "recordType", + "rowBoundaries" + ], + "type": "object" + }, "BatchSource": { "additionalProperties": false, "properties": { @@ -2336,14 +2388,6 @@ }, "type": "array" }, - "membershipBoundaries": { - "default": [], - "description": "Current active membership required for each stored reference key.", - "items": { - "$ref": "#/$defs/MembershipBoundarySource" - }, - "type": "array" - }, "operations": { "items": { "$ref": "#/$defs/Operation" @@ -3772,32 +3816,24 @@ ], "type": "object" }, - "MembershipBoundarySource": { + "MembershipDeclarationSource": { "additionalProperties": false, - "description": "A one-hop current membership requirement, combined with every other row boundary.\nThe root field and membership key must reference the same entity. The active\nfield is Boolean, and principalField matches the profile's verified principal.", + "description": "Stored fields that establish a current membership fact.", "properties": { - "activeField": { - "type": "string" - }, - "field": { - "type": "string" - }, - "membershipKeyField": { - "type": "string" + "active": { + "$ref": "#/$defs/LocalId" }, - "membershipRecordType": { - "type": "string" + "key": { + "$ref": "#/$defs/LocalId" }, - "principalField": { - "type": "string" + "principal": { + "$ref": "#/$defs/LocalId" } }, "required": [ - "field", - "membershipRecordType", - "membershipKeyField", - "principalField", - "activeField" + "key", + "principal", + "active" ], "type": "object" }, @@ -3905,6 +3941,11 @@ "const": "import", "description": "Create records through a durable ingestion run, and nothing else. The\ngrant is enabled only while an operator-opened import authority is open\nfor the entity and profile. It declares no item route and no raw batch\nroute, and change control does not count it as a direct write.", "type": "string" + }, + { + "const": "reference", + "description": "Let the profile's direct writes name records of this Record type, and\nnothing else. A write naming a record reads it under this grant's row\nreach; the grant serves no route and reads no field.", + "type": "string" } ] }, @@ -4055,6 +4096,23 @@ }, "ProposalContextValueSource": { "oneOf": [ + { + "additionalProperties": false, + "properties": { + "form": { + "$ref": "#/$defs/LocalId" + }, + "type": { + "const": "additional-form", + "type": "string" + } + }, + "required": [ + "type", + "form" + ], + "type": "object" + }, { "additionalProperties": false, "properties": { @@ -4158,6 +4216,7 @@ "asked", "answered", "added", + "messaged", "started", "edited", "submitted", @@ -4199,6 +4258,21 @@ ], "type": "object" }, + "ProposalMessagesSource": { + "additionalProperties": false, + "description": "The message thread on each Proposal of an Action. It needs no review.", + "properties": { + "maximumCount": { + "default": 200, + "description": "The most messages each side, the party and the office, writes on one\nProposal's thread.", + "format": "uint32", + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + }, + "type": "object" + }, "ProposalOperation": { "enum": [ "answer", @@ -4215,15 +4289,24 @@ "get-review-status", "get-review-context", "get-task-grant-context", - "get-application-actor" + "get-application-actor", + "message" ], "type": "string" }, - "ProposalOwnership": { - "enum": [ - "caller" - ], - "type": "string" + "ProposalParty": { + "oneOf": [ + { + "const": "owner", + "description": "The caller who filed the Proposal.", + "type": "string" + }, + { + "const": "subject", + "description": "The person the Proposal is about, frozen at its first Submit.", + "type": "string" + } + ] }, "ProposalPermissionSource": { "additionalProperties": false, @@ -4238,8 +4321,9 @@ "type": "array", "uniqueItems": true }, - "ownership": { - "$ref": "#/$defs/ProposalOwnership" + "party": { + "$ref": "#/$defs/ProposalParty", + "description": "Binds the grant to one party of each Proposal. Absent grants are not\nbound to a party, as a reviewer's or officer's are." }, "readableAttachments": { "default": [], @@ -4257,6 +4341,13 @@ "type": "array", "uniqueItems": true }, + "readableForms": { + "items": { + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, "readableInputs": { "default": [], "items": { @@ -4271,10 +4362,13 @@ "reviewAuthority": { "type": "string" }, + "submitsFor": { + "$ref": "#/$defs/ProposalSubmitsFor" + }, "targets": { "default": [], "items": { - "$ref": "#/$defs/ProposalTargetPermissionSource" + "$ref": "#/$defs/AuthoredTargetPermission" }, "type": "array" }, @@ -4286,6 +4380,13 @@ "type": "array", "uniqueItems": true }, + "writableForms": { + "items": { + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, "writableInputs": { "description": "Action inputs this grant may set. Absent leaves every declared input writable.", "items": { @@ -4304,6 +4405,17 @@ "ProposalPolicySource": { "additionalProperties": false, "properties": { + "additionalForms": { + "additionalProperties": { + "$ref": "#/$defs/AdditionalFormSource" + }, + "description": "Typed information a reviewed Proposal can declare separately from its Action inputs.", + "maxProperties": 8, + "propertyNames": { + "$ref": "#/$defs/LocalId" + }, + "type": "object" + }, "additions": { "$ref": "#/$defs/AdditionSlotSource" }, @@ -4328,6 +4440,10 @@ }, "type": "array" }, + "messages": { + "$ref": "#/$defs/ProposalMessagesSource", + "description": "One message thread between the party and the office. Presence opens it." + }, "retention": { "$ref": "#/$defs/ProposalRetentionSource" }, @@ -4336,6 +4452,10 @@ }, "reviewContext": { "$ref": "#/$defs/ProposalReviewContextSource" + }, + "subject": { + "$ref": "#/$defs/ProposalSubjectSource", + "description": "The person the Proposal is about, frozen at its first Submit." } }, "required": [ @@ -4443,22 +4563,29 @@ } ] }, - "ProposalTargetPermissionSource": { + "ProposalSubjectSource": { "additionalProperties": false, + "description": "Where a Proposal's subject comes from: an Action input, or a field of the\nRecord a reference input names.", "properties": { - "recordType": { + "field": { "type": "string" }, - "rowBoundaries": { - "$ref": "#/$defs/RowBoundaries" + "input": { + "type": "string" } }, "required": [ - "recordType", - "rowBoundaries" + "input" ], "type": "object" }, + "ProposalSubmitsFor": { + "description": "Whom a Submit may name as the Proposal's subject. Absent means only the\nsubmitter themselves.", + "enum": [ + "anyone" + ], + "type": "string" + }, "ProvenanceFieldSource": { "description": "A member of a revision's `changeContext` a profile may read. Each value\nis spelled as the member it names is (CFG-NAME-2).", "enum": [ @@ -4975,20 +5102,62 @@ "type": "string" }, { - "description": "Reach the rows every listed boundary binds to the caller's claims.", + "description": "Reach the rows bounded by every listed claim or membership entry.", "items": { - "$ref": "#/$defs/RowBoundarySource" + "$ref": "#/$defs/RowBoundaryEntry" }, "minItems": 1, "type": "array" }, { "$ref": "#/$defs/RowBoundarySetReference", - "description": "Reach the rows every boundary of a named set binds to the caller's claims." + "description": "Reach the rows bounded by every entry in a named set." } ], "description": "The rows a permission reaches: the keyword `unrestricted`, a list of at\nleast one row boundary, or a reference to a named list of them." }, + "RowBoundaryEntry": { + "additionalProperties": false, + "description": "A claim entry {field, claim, operator} or a membership entry {field, membership}.", + "else": { + "required": [ + "claim", + "operator" + ] + }, + "if": { + "required": [ + "membership" + ] + }, + "properties": { + "claim": { + "type": "string" + }, + "field": { + "type": "string" + }, + "membership": { + "$ref": "#/$defs/LocalId" + }, + "operator": { + "$ref": "#/$defs/BoundaryOperator" + } + }, + "required": [ + "field" + ], + "then": { + "properties": { + "claim": false, + "field": { + "$ref": "#/$defs/LocalId" + }, + "operator": false + } + }, + "type": "object" + }, "RowBoundarySetReference": { "additionalProperties": false, "description": "A reference to a named list of row boundaries the file declares under\n`rowBoundarySets`. The reader expands a reference into the set's boundaries\nbefore the typed model is decoded, so the compiler never holds one.", @@ -6432,12 +6601,6 @@ }, "type": "array" }, - "membershipBoundaries": { - "items": { - "$ref": "#/$defs/MembershipBoundarySource" - }, - "type": "array" - }, "operations": { "items": { "$ref": "#/$defs/Operation" @@ -6683,6 +6846,9 @@ }, "type": "array" }, + "membership": { + "$ref": "#/$defs/MembershipDeclarationSource" + }, "mutationMode": { "$ref": "#/$defs/MutationMode" }, @@ -6762,7 +6928,7 @@ "rowBoundarySets": { "additionalProperties": { "items": { - "$ref": "#/$defs/RowBoundarySource" + "$ref": "#/$defs/RowBoundaryEntry" }, "minItems": 1, "type": "array" diff --git a/products/identifiers/generated/catalog.v1.json b/products/identifiers/generated/catalog.v1.json index dc0e6b171e..9f6daced1d 100644 --- a/products/identifiers/generated/catalog.v1.json +++ b/products/identifiers/generated/catalog.v1.json @@ -30,7 +30,7 @@ "description": "Base Registry Engine fixed Proposal lifecycle event schema, reproduced byte-for-byte from its packaged artifact.", "source": { "path": "crates/registry-breg/src/proposal_hooks.rs", - "sha256": "8536d155fb4b4007e70122255cbac89bc40ae0aaf42c60366c5c49e0d21caff6" + "sha256": "1d9216f1bcd35554f3d4e879b75ca9e12738793acedc729413429f3cf465d0cc" }, "artifact": { "path": "products/breg/generated/event-schemas/proposal-lifecycle.schema.json", @@ -270,7 +270,7 @@ "description": "Multiple access profiles admit this request on this route; select one with accessProfile.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "access-profile.ambiguous", @@ -289,7 +289,7 @@ "description": "The declared Evidence dependency could not be accepted.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "action.evidence-failed", @@ -308,7 +308,7 @@ "description": "The action guard was not satisfied.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "action.guard-failed", @@ -327,7 +327,7 @@ "description": "The action handler could not produce an accepted result.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "action.handler-failed", @@ -346,7 +346,7 @@ "description": "The action was refused by a declared business rule.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "action.refused", @@ -365,7 +365,7 @@ "description": "The file media type is not one the attachment slot accepts.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.content-type", @@ -384,7 +384,7 @@ "description": "The file content does not match its declared SHA-256 digest.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.digest-mismatch", @@ -403,7 +403,7 @@ "description": "The supporting document slot has reached its file limit.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.limit-reached", @@ -422,7 +422,7 @@ "description": "The required attachment slot is empty.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.required", @@ -441,7 +441,7 @@ "description": "The record attachment slot already holds a file and is write-once.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.slot-write-once", @@ -460,7 +460,7 @@ "description": "The file is larger than the attachment slot accepts.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.too-large", @@ -479,7 +479,7 @@ "description": "The attachment is awaiting verification. Refresh the Proposal before submitting.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.verification-pending", @@ -498,7 +498,7 @@ "description": "The attachment was rejected by verification. Replace or remove the file before submitting.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "attachment.verification-rejected", @@ -517,7 +517,7 @@ "description": "The bearer token or delivery signature was not accepted.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "authentication.refused", @@ -536,7 +536,7 @@ "description": "The external view's indexed coverage is incomplete for this request.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "external-view.incomplete", @@ -555,7 +555,7 @@ "description": "The held response of the idempotency key expired; the key stays spent.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "idempotency.expired", @@ -574,7 +574,7 @@ "description": "The idempotency key is bound to another request.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "idempotency.key-reused", @@ -593,7 +593,7 @@ "description": "The chunk does not match the expected next chunk.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "ingestion.chunk-mismatch", @@ -612,7 +612,7 @@ "description": "The selected access profile does not match the run's bound profile.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "ingestion.profile-mismatch", @@ -631,7 +631,7 @@ "description": "The stored receipt of the chunk was erased.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "ingestion.receipt-erased", @@ -650,7 +650,7 @@ "description": "The ingestion run is blocked and refuses further chunks.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "ingestion.run-blocked", @@ -669,7 +669,7 @@ "description": "The ingestion run is not open for this transition.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "ingestion.run-not-open", @@ -688,7 +688,7 @@ "description": "The lookup did not resolve exactly one record.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "lookup.unresolved", @@ -707,7 +707,7 @@ "description": "The mutation conflicts with current state.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "mutation.conflict", @@ -726,7 +726,7 @@ "description": "A production registry refuses task assertions issued in development.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "platform.task-grant.development-assertion", @@ -745,7 +745,7 @@ "description": "The mutation precondition failed.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "precondition.failed", @@ -764,7 +764,7 @@ "description": "The mutation precondition is required.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "precondition.required", @@ -783,7 +783,7 @@ "description": "No access profile admits this caller for this request.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "profile.not-authorized", @@ -792,6 +792,63 @@ ] } }, + { + "uri": "https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "breg", + "title": "Conflict", + "description": "The submission has reached the entry limit for this form.", + "source": { + "path": "crates/registry-breg/src/problem.rs", + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" + }, + "problem": { + "code": "proposal.form-limit-reached", + "httpStatuses": [ + 409 + ] + } + }, + { + "uri": "https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "breg", + "title": "Not Found", + "description": "The Action does not declare this additional form.", + "source": { + "path": "crates/registry-breg/src/problem.rs", + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" + }, + "problem": { + "code": "proposal.form-undeclared", + "httpStatuses": [ + 404 + ] + } + }, + { + "uri": "https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "breg", + "title": "Conflict", + "description": "This Proposal's message thread is full.", + "source": { + "path": "crates/registry-breg/src/problem.rs", + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" + }, + "problem": { + "code": "proposal.message-limit-reached", + "httpStatuses": [ + 409 + ] + } + }, { "uri": "https://id.registrystack.org/problems/registry-breg/proposal/rejected", "kind": "problem", @@ -802,7 +859,7 @@ "description": "The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "proposal.rejected", @@ -821,7 +878,7 @@ "description": "The current review result does not match the retained approval.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "proposal.review-result-mismatch", @@ -830,6 +887,44 @@ ] } }, + { + "uri": "https://id.registrystack.org/problems/registry-breg/proposal/subject-changed", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "breg", + "title": "Conflict", + "description": "The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.", + "source": { + "path": "crates/registry-breg/src/problem.rs", + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" + }, + "problem": { + "code": "proposal.subject-changed", + "httpStatuses": [ + 409 + ] + } + }, + { + "uri": "https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "breg", + "title": "Forbidden", + "description": "This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.", + "source": { + "path": "crates/registry-breg/src/problem.rs", + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" + }, + "problem": { + "code": "proposal.subject-not-caller", + "httpStatuses": [ + 403 + ] + } + }, { "uri": "https://id.registrystack.org/problems/registry-breg/proposal/submission-expired", "kind": "problem", @@ -840,7 +935,7 @@ "description": "The review result and application receipt of the submission are no longer retained.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "proposal.submission-expired", @@ -859,7 +954,7 @@ "description": "The query cursor is invalid.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "query.cursor-invalid", @@ -878,7 +973,7 @@ "description": "The list did not carry the search criteria its access profile requires.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "query.filter-required", @@ -897,7 +992,7 @@ "description": "The query request is invalid.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "query.invalid", @@ -916,7 +1011,7 @@ "description": "The access profile requires a valid Registry-Access-Reason header.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "request.access-reason-required", @@ -935,7 +1030,7 @@ "description": "The request is invalid.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "request.invalid", @@ -954,7 +1049,7 @@ "description": "The request timed out.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "request.timeout", @@ -973,7 +1068,7 @@ "description": "The requested resource was not found.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "resource.not-found", @@ -992,7 +1087,7 @@ "description": "The Registry field-encryption service is unavailable.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "runtime.field-encryption.unavailable", @@ -1011,7 +1106,7 @@ "description": "Registry runtime is not ready.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "runtime.not-ready", @@ -1030,7 +1125,7 @@ "description": "The Registry mutation service is unavailable.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "service.unavailable", @@ -1049,7 +1144,7 @@ "description": "The Registry data service is unavailable.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "source.unavailable", @@ -1068,7 +1163,7 @@ "description": "A statistical dataset contains a code outside its declared domain.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "statistical-dataset.domain-violation", @@ -1087,7 +1182,7 @@ "description": "The statistical dataset release operation is not eligible.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "statistical-dataset.release-refused", @@ -1106,7 +1201,7 @@ "description": "The statistical dataset computation was superseded or its package changed.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "statistical-dataset.version-conflict", @@ -1125,7 +1220,7 @@ "description": "The statistical dataset version was withdrawn.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "statistical-dataset.version-withdrawn", @@ -1144,7 +1239,7 @@ "description": "The request media type is not supported.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "unsupported.media-type", @@ -1163,7 +1258,7 @@ "description": "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.", "source": { "path": "crates/registry-breg/src/problem.rs", - "sha256": "9f3ad71d8b93289ba293ef2e22f999a94697e1a62fc6f7c8ca940775c877d425" + "sha256": "c6c0ea7438097c7af22375aac53330e5c6d4bf481c9e9612ef0021230b89c2b1" }, "problem": { "code": "write.outside-boundary", @@ -1182,7 +1277,7 @@ "description": "Choose cover assignments that do not return to an earlier person during a shared period.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "absence.cover-cycle", @@ -1201,7 +1296,7 @@ "description": "Set until later than from.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "absence.invalid-period", @@ -1220,7 +1315,7 @@ "description": "Adjust the period so this person has no overlapping absence.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "absence.overlap", @@ -1239,7 +1334,7 @@ "description": "Choose a different staff member as cover.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "absence.self-cover", @@ -1258,7 +1353,7 @@ "description": "Multiple access profiles admit this request on this route; select one with accessProfile.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "access-profile.ambiguous", @@ -1277,7 +1372,7 @@ "description": "The bearer credential is missing, invalid, or expired. Sign in again.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "authentication.refused", @@ -1296,7 +1391,7 @@ "description": "Create a new recompute preview and review it before applying.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "clock.recompute-preview-expired", @@ -1315,7 +1410,7 @@ "description": "This cursor has expired. Start again without a cursor and deduplicate entries by eventId.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "cursor.expired", @@ -1334,7 +1429,7 @@ "description": "The cursor is invalid for this request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "cursor.invalid", @@ -1353,7 +1448,7 @@ "description": "The stored response for this idempotency key has expired. Reconcile the original operation before choosing a new key.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "idempotency.expired", @@ -1372,7 +1467,7 @@ "description": "This idempotency key was used for a different request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "idempotency.key-reused", @@ -1391,7 +1486,7 @@ "description": "Your current Casework authority does not allow this operation.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "operation.not-authorized", @@ -1410,7 +1505,7 @@ "description": "The item or directory changed since you loaded it. Reload and try again.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "precondition.failed", @@ -1429,7 +1524,7 @@ "description": "This mutation requires the revision that you loaded.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "precondition.required", @@ -1448,7 +1543,7 @@ "description": "The selected Casework profile does not authorize this request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "profile.not-authorized", @@ -1467,7 +1562,7 @@ "description": "This action is reserved for a human session.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "profile.not-human", @@ -1486,7 +1581,7 @@ "description": "The request body exceeds the one MiB limit.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.body-too-large", @@ -1505,7 +1600,7 @@ "description": "The Casework request is invalid.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.invalid", @@ -1524,7 +1619,7 @@ "description": "The limit query parameter must be from 1 to 100, or from 1 to 1000 on the directory absence list. Omit it for the default page size.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.limit-out-of-range", @@ -1543,7 +1638,7 @@ "description": "This route does not accept that HTTP method.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.method-not-allowed", @@ -1562,7 +1657,7 @@ "description": "The requested Casework route does not exist.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.not-found", @@ -1581,7 +1676,7 @@ "description": "The request body does not match the Casework contract.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.unprocessable", @@ -1600,7 +1695,7 @@ "description": "Send a JSON request body with Content-Type application/json.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "request.unsupported-media-type", @@ -1619,7 +1714,7 @@ "description": "Wait for the open ask on this request to be answered or closed before asking again.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-already-open", @@ -1638,7 +1733,7 @@ "description": "Report the time the applicant's answer was committed: not before the ask was made and no more than five minutes ahead of Casework's clock.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-answer-time-invalid", @@ -1647,6 +1742,25 @@ ] } }, + { + "uri": "https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown", + "kind": "problem", + "status": "active", + "compatibilityLine": "v1alpha1", + "owner": "casework", + "title": "Unknown review ask form", + "description": "The review source does not declare the requested form.", + "source": { + "path": "crates/registry-casework/src/problem.rs", + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" + }, + "problem": { + "code": "review.ask-form-unknown", + "httpStatuses": [ + 422 + ] + } + }, { "uri": "https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached", "kind": "problem", @@ -1657,7 +1771,7 @@ "description": "This review request has reached its limit of 50 asks. Continue the review without opening another ask.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-limit-reached", @@ -1676,7 +1790,7 @@ "description": "The active stage of this review policy does not let a reviewer ask the applicant.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-not-offered", @@ -1695,7 +1809,7 @@ "description": "This ask was already answered or closed, or the applicant answered after its due date.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-not-open", @@ -1714,7 +1828,7 @@ "description": "The producer of this request does not read asks, so the reviewer cannot ask the applicant.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-producer-unsupported", @@ -1733,7 +1847,7 @@ "description": "Ask from a task at the active stage of a request that is still under review.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.ask-task-inactive", @@ -1752,7 +1866,7 @@ "description": "Each approval in this stage must be supplied by a different reviewer.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.distinct-approver-required", @@ -1771,7 +1885,7 @@ "description": "You submitted this request, and this review stage excludes the person who submitted it. Another reviewer must take it.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.initiator-excluded", @@ -1790,7 +1904,7 @@ "description": "This review policy excludes the person who submitted the request, so the request must name its initiator.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.initiator-required", @@ -1809,7 +1923,7 @@ "description": "The expected review policy binding does not match the active policy.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.policy-mismatch", @@ -1828,7 +1942,7 @@ "description": "Narrow the queue or exact subject query to complete it within the configured read budget.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.query-too-broad", @@ -1847,7 +1961,7 @@ "description": "The retained review result is no longer available. Reconcile through the producer's retained source correlation.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.result-expired", @@ -1866,7 +1980,7 @@ "description": "The same producer, source subject, version, and policy were already submitted with different canonical content.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.submission-conflict", @@ -1885,7 +1999,7 @@ "description": "Claim the review task before deciding it, and decide only while the claim remains current.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "review.task-not-held", @@ -1904,7 +2018,7 @@ "description": "Casework could not complete the request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "runtime.failure", @@ -1923,7 +2037,7 @@ "description": "Casework storage is unavailable. Try again after the service recovers.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "service.unavailable", @@ -1942,7 +2056,7 @@ "description": "Send a separate source bearer token in the Registry-Source-Authorization header along with Registry-Source-Profile.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source-authorization.required", @@ -1961,7 +2075,7 @@ "description": "Omit the Registry-Source-Profile header for this request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source-profile.not-applicable", @@ -1980,7 +2094,7 @@ "description": "Send the Registry-Source-Profile header to select the source profile for this request.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source-profile.required", @@ -1999,7 +2113,7 @@ "description": "The source returned a response that does not match its registered contract.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source.bad-gateway", @@ -2018,7 +2132,7 @@ "description": "Deploy the same Registry Stack version for Casework and its source.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source.version-mismatch", @@ -2037,7 +2151,7 @@ "description": "The source did not report its engine version. Deploy matching Registry Stack versions.", "source": { "path": "crates/registry-casework/src/problem.rs", - "sha256": "c98b69008b0a25d13f452630f5d1b1b53d215f7bd61fe43d5a13662dd12710ae" + "sha256": "dd3a79760d624a1cb1168f2cd45ca0bfff48aefa157f7f8a10c2084a6f8d20a3" }, "problem": { "code": "source.version-unavailable", @@ -5670,11 +5784,11 @@ "description": "Base Registry Engine bregctl explain output JSON Schemas, written by hand and held to bregctl's output by its contract test.", "source": { "path": "products/breg/contracts/explain/AccessExplanation.schema.json", - "sha256": "7c8c696f2da9b62b8043cdc4b3584c479374a6c31b29899de4a07a1ce278bdc3" + "sha256": "1f6853a1f2295586bb3dd1aa241089b3b5ffb037a165c50a2adc1f1b5837503f" }, "artifact": { "path": "products/breg/contracts/explain/AccessExplanation.schema.json", - "sha256": "7c8c696f2da9b62b8043cdc4b3584c479374a6c31b29899de4a07a1ce278bdc3", + "sha256": "1f6853a1f2295586bb3dd1aa241089b3b5ffb037a165c50a2adc1f1b5837503f", "mediaType": "application/schema+json" } }, @@ -5706,7 +5820,7 @@ "description": "Base Registry Engine portable Action contract export schema, reproduced from the canonical compiled project.", "source": { "path": "crates/registry-breg/src/artifacts.rs", - "sha256": "c23555cfb9db5fb39dd6fe9271c670c78bc3a5082806dfb60c5b44ffe4fb6963" + "sha256": "c0aa8c1c7d6d833c0a252463b61b652dae7d92989ec4d12898c31fc3d04ad089" }, "artifact": { "path": "products/breg/generated/facility/generated/action-contracts.schema.json", @@ -5796,11 +5910,11 @@ "description": "Base Registry Engine bregctl explain output JSON Schemas, written by hand and held to bregctl's output by its contract test.", "source": { "path": "products/breg/contracts/explain/EventsExplanation.schema.json", - "sha256": "5aa42feda951f66b823a7d5ec44901864089313704790f571231352ab9a4a89b" + "sha256": "83b910ac925a1e223e1796e0f09c21df828d54fe95ca1221cbf85f8d57f57517" }, "artifact": { "path": "products/breg/contracts/explain/EventsExplanation.schema.json", - "sha256": "5aa42feda951f66b823a7d5ec44901864089313704790f571231352ab9a4a89b", + "sha256": "83b910ac925a1e223e1796e0f09c21df828d54fe95ca1221cbf85f8d57f57517", "mediaType": "application/schema+json" } }, @@ -5841,20 +5955,20 @@ } }, { - "uri": "https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha9.schema.json", + "uri": "https://id.registrystack.org/schemas/breg/lifecycle-explanation/lifecycle-explanation.v1alpha10.schema.json", "kind": "schema", "status": "active", - "compatibilityLine": "v1alpha9", + "compatibilityLine": "v1alpha10", "owner": "breg", "title": "LifecycleExplanation", "description": "Base Registry Engine bregctl explain output JSON Schemas, written by hand and held to bregctl's output by its contract test.", "source": { "path": "products/breg/contracts/explain/LifecycleExplanation.schema.json", - "sha256": "6b1e7b817a6d38a99de07315432a0ad883f6a0675fc15d4602a4d596a58cf555" + "sha256": "5c1cb662a76e7ef6ff4c0087a589a4ebaa1324772f7ef904a2ef901f96abacce" }, "artifact": { "path": "products/breg/contracts/explain/LifecycleExplanation.schema.json", - "sha256": "6b1e7b817a6d38a99de07315432a0ad883f6a0675fc15d4602a4d596a58cf555", + "sha256": "5c1cb662a76e7ef6ff4c0087a589a4ebaa1324772f7ef904a2ef901f96abacce", "mediaType": "application/schema+json" } }, @@ -5944,7 +6058,7 @@ }, "artifact": { "path": "products/breg/generated/authoring/registry-module.schema.json", - "sha256": "a6c426f05687fce0775f6a4690189de9d2826675f86fe094dbd06671fd31b513", + "sha256": "24d2b59bcf4b702eb251dd56d001e50490ecbb5e8e60f440ec09cf52011e27e9", "mediaType": "application/schema+json" } }, @@ -5962,7 +6076,7 @@ }, "artifact": { "path": "products/breg/generated/authoring/registry-project.schema.json", - "sha256": "712e989a790b9c4fc59b1a1f14a32437f158b9fd7d405909274a641556173f76", + "sha256": "6b6d9371a98f18b3610acf64a4b4d8e565468a0033c3bd66f426bbbaf27d6dfd", "mediaType": "application/schema+json" } }, From e2eb6212f933c58d845df1b9783ff0464ce43f36 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:46:23 +0000 Subject: [PATCH 16/96] fix(casework): refresh the TypeScript review context contract Signed-off-by: Jeremi Joslin --- clients/typescript/generated/casework.ts | 40 ++- clients/typescript/tests/casework.test.ts | 2 +- .../generated/registry-casework.openapi.json | 311 +++++++++++++++++- 3 files changed, 338 insertions(+), 15 deletions(-) diff --git a/clients/typescript/generated/casework.ts b/clients/typescript/generated/casework.ts index e4831c55c0..89d00fe88b 100644 --- a/clients/typescript/generated/casework.ts +++ b/clients/typescript/generated/casework.ts @@ -1,5 +1,5 @@ // Generated for Stack version 0.52.0, client version 0.52.0. -// Source SHA-256 095bdd1b45a0e8031bb3d6cff6b2223514c250f14c985ca177abe6f8d18d9277 +// Source SHA-256 195bfdca62f16e84447145617876a65a104e70f4d96b3b3aa1c6a682be591041 // Unconstrained JSON /components/schemas/ReviewHistoryEntry/properties/detail // Unconstrained JSON /components/schemas/ReviewPolicy/properties/displaySchema // Unconstrained JSON /components/schemas/ReviewPolicy/properties/resultSchema @@ -56,7 +56,7 @@ export type Schema_InputHolidaySetDocument = ({ "dates": (Array<(string)>); "hol export type Schema_InputHumanIdentity = ({ "issuer": (string); "subject": (string) }) export type Schema_InputIssuerPrincipal = ({ "issuer": (string); "subject": (string) }) export type Schema_InputPolicySelection = ({ "digest"?: Schema_InputContentDigest; "id": (string); "version"?: (string) }) -export type Schema_InputReviewAskWant = (({ "kind": "answer" & (string) }) | ({ "kind": "document" & (string) })) +export type Schema_InputReviewAskWant = (({ "kind": "answer" & (string) }) | ({ "kind": "document" & (string) }) | ({ "form": (string); "kind": "form" & (string) })) export type Schema_InputReviewContext = (({ "mode": "submitted" & (string); "snapshot": (Record) }) | ({ "binding": Schema_InputSourceContextBinding; "mode": "current-source" & (string) })) export type Schema_InputReviewHistoryAudience = ("reviewers" | "requester") & (string) export type Schema_InputReviewRequestInclude = ("progress") & (string) @@ -98,6 +98,7 @@ export type Schema_ProblemRequestUnprocessable = (Schema_Problem & ({ "code"?: " export type Schema_ProblemRequestUnsupportedMediaType = (Schema_Problem & ({ "code"?: "request.unsupported-media-type"; "detail"?: "Send a JSON request body with Content-Type application/json."; "status"?: 415; "title"?: "Unsupported media type"; "type"?: "https://id.registrystack.org/problems/registry-casework/request/unsupported-media-type" })) export type Schema_ProblemReviewAskAlreadyOpen = (Schema_Problem & ({ "code"?: "review.ask-already-open"; "detail"?: "Wait for the open ask on this request to be answered or closed before asking again."; "status"?: 409; "title"?: "Review ask already open"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-already-open" })) export type Schema_ProblemReviewAskAnswerTimeInvalid = (Schema_Problem & ({ "code"?: "review.ask-answer-time-invalid"; "detail"?: "Report the time the applicant's answer was committed: not before the ask was made and no more than five minutes ahead of Casework's clock."; "status"?: 422; "title"?: "Review ask answer time invalid"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-answer-time-invalid" })) +export type Schema_ProblemReviewAskFormUnknown = (Schema_Problem & ({ "code"?: "review.ask-form-unknown"; "detail"?: "The review source does not declare the requested form."; "status"?: 422; "title"?: "Unknown review ask form"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown" })) export type Schema_ProblemReviewAskLimitReached = (Schema_Problem & ({ "code"?: "review.ask-limit-reached"; "detail"?: "This review request has reached its limit of 50 asks. Continue the review without opening another ask."; "status"?: 409; "title"?: "Review ask limit reached"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached" })) export type Schema_ProblemReviewAskNotOffered = (Schema_Problem & ({ "code"?: "review.ask-not-offered"; "detail"?: "The active stage of this review policy does not let a reviewer ask the applicant."; "status"?: 409; "title"?: "Review ask not offered"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-not-offered" })) export type Schema_ProblemReviewAskNotOpen = (Schema_Problem & ({ "code"?: "review.ask-not-open"; "detail"?: "This ask was already answered or closed, or the applicant answered after its due date."; "status"?: 409; "title"?: "Review ask not open"; "type"?: "https://id.registrystack.org/problems/registry-casework/review/ask-not-open" })) @@ -126,13 +127,14 @@ export type Schema_ReadyStatus = ({ "developmentSettings": (Array<({ "code": (st export type Schema_ReviewAccountabilityRecord = ({ "actor": Schema_IssuerPrincipal; "actorRef": (string); "decision": (string); "decisionReceipt"?: (Schema_ReviewDecisionReceipt | (null)); "eventId": (string); "occurredAt": (string); "privateReason"?: (string | null); "profileId": (string); "requestId": (string); "resultDigest"?: (string | null); "retainedUntil": (string); "taskId": (string) }) export type Schema_ReviewAnswerDocument = ({ "byteSize": (number); "contentType": (string); "download"?: (Schema_ReviewAnswerDownload | (null)); "id": (string); "sha256": (string); "verificationStatus"?: (string | null) }) export type Schema_ReviewAnswerDownload = ({ "accessProfile": (string); "method": (string); "operation": (string); "path": (string) }) +export type Schema_ReviewAnswerFormEntry = ({ "addedAt": (string); "contractChanged"?: (boolean); "id": (string); "input"?: (Record | null) }) export type Schema_ReviewAsk = ({ "answeredAt"?: (string | null); "askId": (string); "askedAt": (string); "closedAt"?: (string | null); "dueAt"?: (string | null); "requestId": (string); "state": Schema_ReviewAskState; "subject": Schema_SubjectBinding; "text": (string); "wants": (Array) }) export type Schema_ReviewAskAnswer = ({ "answeredAt": (string); "subject": Schema_InputSubjectBinding }) export type Schema_ReviewAskFeedEntry = ({ "askId": (string); "changedAt": (string); "eventId": (string); "requestId": (string) }) export type Schema_ReviewAskFeedPage = ({ "items": (Array); "nextCursor"?: (string | null) }) export type Schema_ReviewAskOnDue = ("return-to-reviewer") & (string) export type Schema_ReviewAskState = ("open" | "answered" | "expired" | "closed") & (string) -export type Schema_ReviewAskWant = (({ "kind": "answer" & (string) }) | ({ "kind": "document" & (string) })) +export type Schema_ReviewAskWant = (({ "kind": "answer" & (string) }) | ({ "kind": "document" & (string) }) | ({ "form": (string); "kind": "form" & (string) })) export type Schema_ReviewCancelRequest = ({ "reason": (string); "subject": Schema_InputSubjectBinding }) export type Schema_ReviewCancelResponse = (({ "outcome": "cancelled" & (string); "result": Schema_ReviewResult }) | ({ "outcome": "already-terminal" & (string); "result": Schema_ReviewResult })) export type Schema_ReviewCaseloadApplyRequest = ({ "previewId": (string) }) @@ -152,7 +154,7 @@ export type Schema_ReviewClockState = ("running" | "paused" | "completed" | "can export type Schema_ReviewCompletion = ({ "completedAt": (string); "eventId": (string); "requestId": (string); "resultId": (string); "type": Schema_ReviewCompletionType }) export type Schema_ReviewCompletionDestinationPolicy = ({ "destinationId": Schema_LocalId; "recipientBinding": (string) }) export type Schema_ReviewCompletionType = ("review.completed") & (string) -export type Schema_ReviewContextAnswer = ({ "answeredAt": (string); "documents": (Array); "text"?: (string | null) }) +export type Schema_ReviewContextAnswer = ({ "answeredAt": (string); "documents": (Array); "formEntries"?: (Array); "text"?: (string | null) }) export type Schema_ReviewContextAsk = ({ "answer"?: (Schema_ReviewContextAnswer | (null)); "answeredAt"?: (string | null); "askId": (string); "askedAt": (string); "dueAt"?: (string | null); "state": Schema_ReviewAskState; "taskId": (string); "text": (string); "wants": (Array) }) export type Schema_ReviewContextCapability = ("human-display" | "service-status" | "task-grant-context" | "routing-context") & (string) export type Schema_ReviewContextContract = ({ "id": Schema_ExternalId; "revision": Schema_ContentDigest; "schemaDigest": Schema_Digest }) @@ -191,10 +193,10 @@ export type Schema_ReviewSourceProjection = ({ "binding": Schema_SubjectBinding; export type Schema_ReviewStaffingQuery = ({ "cursor"?: (string | null); "limit"?: (number | null); "marker"?: (Schema_InputReviewTaskMarker | (null)); "ownership"?: (Schema_InputReviewTaskOwnership | (null)); "queue"?: (string | null); "reference"?: (string | null); "sort"?: Schema_InputReviewTaskSort; "subjectDigest"?: (Schema_InputContentDigest | (null)); "subjectId"?: (string | null); "subjectSource"?: (string | null); "subjectType"?: (string | null); "subjectVersion"?: (string | null) }) export type Schema_ReviewStageAsksPolicy = ({ "answerWithin"?: (Schema_ElapsedDuration | (null)); "onDue"?: Schema_ReviewAskOnDue; "pauseClocks"?: (boolean) }) export type Schema_ReviewStagePolicy = ({ "asks"?: (Schema_ReviewStageAsksPolicy | (null)); "decidingProfiles": (Array<(string)>); "excludeInitiator": (boolean); "excludePreviousStageReviewers": (boolean); "id": Schema_LocalId; "label"?: (Schema_DisplayText | (null)); "negativeDecisions"?: Schema_ReviewNegativeDecisionMode; "outcomes"?: (Array | null); "publicProgressCode"?: (Schema_ReviewProgressCode | (null)); "queue": (string); "requiredApprovals": (number) }) -export type Schema_ReviewTask = ({ "createdAt": (string); "deadlineAt": (string | null); "decidedByCaller"?: (boolean | null); "decisionReceipt"?: (Schema_ReviewDecisionReceipt | (null)); "displayReference"?: (string | null); "eligibleProfiles": (Array<(string)>); "marker"?: (Schema_ReviewTaskMarker | (null)); "queue": (string); "requestId": (string); "requesterReference": (string); "revision": (number); "staffingDiagnostic"?: Schema_StaffingDiagnostic; "stageId": (string); "stageIndex": (number); "state": Schema_ReviewTaskState; "subject": Schema_SubjectBinding; "taskId": (string) }) +export type Schema_ReviewTask = ({ "createdAt": (string); "deadlineAt": (string | null); "decidedByCaller"?: (boolean | null); "decisionReceipt"?: (Schema_ReviewDecisionReceipt | (null)); "displayReference"?: (string | null); "eligibleProfiles": (Array<(string)>); "marker"?: (Schema_ReviewTaskMarker | (null)); "queue": (string); "requestId": (string); "requesterReference": (string); "revision": (number); "staffingDiagnostic"?: Schema_StaffingDiagnostic; "stageId": (string); "stageIndex": (number); "state": Schema_ReviewTaskState; "subject": Schema_SubjectBinding; "taskId": (string); "unreadMessages"?: (number | null) }) export type Schema_ReviewTaskAskRequest = ({ "text": (string); "wants": (Array) }) export type Schema_ReviewTaskAsked = ({ "ask": Schema_ReviewAsk; "task": Schema_ReviewTask }) -export type Schema_ReviewTaskContext = ({ "asks"?: (Array); "context": Schema_ReviewTaskContextData; "policy": Schema_PolicyBinding; "policyClosure": Schema_ReviewPolicyClosure; "requestId": (string); "requesterReference": (string); "resultConstraints"?: JsonValue; "subject": Schema_SubjectBinding; "taskId": (string) }) +export type Schema_ReviewTaskContext = ({ "additionalForms"?: (Record); "asks"?: (Array); "context": Schema_ReviewTaskContextData; "messages"?: (Schema_SourceMessageThread | (null)); "policy": Schema_PolicyBinding; "policyClosure": Schema_ReviewPolicyClosure; "requestId": (string); "requesterReference": (string); "resultConstraints"?: JsonValue; "subject": Schema_SubjectBinding; "taskId": (string) }) export type Schema_ReviewTaskContextData = (({ "mode": "submitted" & (string); "snapshot": JsonValue }) | ({ "bindingStatus": Schema_ReviewSourceBindingStatus; "mode": "current-source" & (string); "projection"?: (Schema_ReviewSourceProjection | (null)); "reference": (string) })) export type Schema_ReviewTaskDecisionRequest = ({ "decision": Schema_InputDecisionKind }) export type Schema_ReviewTaskDraft = ({ "author": Schema_IssuerPrincipal; "body": JsonValue; "revision": (number); "taskId": (string); "updatedAt": (string) }) @@ -207,6 +209,12 @@ export type Schema_RoutingCondition = ({ "fields"?: (Record) })) export type Schema_RoutingRule = ({ "because": Schema_DisplayText; "id": Schema_LocalId; "label"?: (Schema_DisplayText | (null)); "queue": (string); "when": Schema_RoutingCondition }) export type Schema_SchedulingTaskPermission = ({ "actions": (Array<(string)>); "location": (string); "service": (string) }) +export type Schema_SourceMessage = ({ "from": Schema_SourceMessageSide; "id": (string); "mine": (boolean); "partyRole"?: (Schema_SourceMessagePartyRole | (null)); "sentAt": (string); "text"?: (string | null) }) +export type Schema_SourceMessageAvailability = ({ "available": (boolean); "observedRevision": (number); "reason"?: (string | null); "recovery"?: (string | null) }) +export type Schema_SourceMessageLink = ({ "accessProfile": (string); "availability": (Schema_SourceMessageAvailability | (null)); "ifMatch"?: (string | null); "method": (string); "operation": (string); "path": (string) }) +export type Schema_SourceMessagePartyRole = ("owner" | "subject") & (string) +export type Schema_SourceMessageSide = ("party" | "official") & (string) +export type Schema_SourceMessageThread = ({ "count": (number); "items"?: (Array | null); "lastSentAt"?: (string | null); "links"?: (Record | null); "unread": (number) }) export type Schema_StaffingDiagnostic = ("no-cover-available" | "insufficient-distinct-approvers") & (string) export type Schema_StageClockAnchor = ({ "type": Schema_StageClockAnchorType }) export type Schema_StageClockAnchorType = ("stage-entered") & (string) @@ -337,7 +345,7 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/InputHumanIdentity", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"issuer\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"subject\"],\"type\":\"object\"}")], ["/components/schemas/InputIssuerPrincipal", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"issuer\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"subject\"],\"type\":\"object\"}")], ["/components/schemas/InputPolicySelection", JSON.parse("{\"additionalProperties\":false,\"dependentRequired\":{\"digest\":[\"version\"],\"version\":[\"digest\"]},\"properties\":{\"digest\":{\"$ref\":\"/components/schemas/InputContentDigest\"},\"id\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}},\"required\":[\"id\"],\"type\":\"object\"}")], - ["/components/schemas/InputReviewAskWant", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"answer\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"document\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"}]}")], + ["/components/schemas/InputReviewAskWant", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"answer\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"document\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\",\"type\":\"string\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]}")], ["/components/schemas/InputReviewContext", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"submitted\",\"type\":\"string\"},\"snapshot\":{\"additionalProperties\":true,\"type\":\"object\"}},\"required\":[\"mode\",\"snapshot\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"binding\":{\"$ref\":\"/components/schemas/InputSourceContextBinding\"},\"mode\":{\"const\":\"current-source\",\"type\":\"string\"}},\"required\":[\"mode\",\"binding\"],\"type\":\"object\"}]}")], ["/components/schemas/InputReviewHistoryAudience", JSON.parse("{\"enum\":[\"reviewers\",\"requester\"],\"type\":\"string\"}")], ["/components/schemas/InputReviewRequestInclude", JSON.parse("{\"enum\":[\"progress\"],\"type\":\"string\"}")], @@ -377,6 +385,7 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/ProblemRequestUnsupportedMediaType", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"request.unsupported-media-type\"},\"detail\":{\"const\":\"Send a JSON request body with Content-Type application/json.\"},\"status\":{\"const\":415},\"title\":{\"const\":\"Unsupported media type\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/request/unsupported-media-type\"}}}]}")], ["/components/schemas/ProblemReviewAskAlreadyOpen", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-already-open\"},\"detail\":{\"const\":\"Wait for the open ask on this request to be answered or closed before asking again.\"},\"status\":{\"const\":409},\"title\":{\"const\":\"Review ask already open\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-already-open\"}}}]}")], ["/components/schemas/ProblemReviewAskAnswerTimeInvalid", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-answer-time-invalid\"},\"detail\":{\"const\":\"Report the time the applicant's answer was committed: not before the ask was made and no more than five minutes ahead of Casework's clock.\"},\"status\":{\"const\":422},\"title\":{\"const\":\"Review ask answer time invalid\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-answer-time-invalid\"}}}]}")], + ["/components/schemas/ProblemReviewAskFormUnknown", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-form-unknown\"},\"detail\":{\"const\":\"The review source does not declare the requested form.\"},\"status\":{\"const\":422},\"title\":{\"const\":\"Unknown review ask form\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown\"}}}]}")], ["/components/schemas/ProblemReviewAskLimitReached", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-limit-reached\"},\"detail\":{\"const\":\"This review request has reached its limit of 50 asks. Continue the review without opening another ask.\"},\"status\":{\"const\":409},\"title\":{\"const\":\"Review ask limit reached\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-limit-reached\"}}}]}")], ["/components/schemas/ProblemReviewAskNotOffered", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-not-offered\"},\"detail\":{\"const\":\"The active stage of this review policy does not let a reviewer ask the applicant.\"},\"status\":{\"const\":409},\"title\":{\"const\":\"Review ask not offered\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-not-offered\"}}}]}")], ["/components/schemas/ProblemReviewAskNotOpen", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"const\":\"review.ask-not-open\"},\"detail\":{\"const\":\"This ask was already answered or closed, or the applicant answered after its due date.\"},\"status\":{\"const\":409},\"title\":{\"const\":\"Review ask not open\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-casework/review/ask-not-open\"}}}]}")], @@ -404,13 +413,14 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/ReviewAccountabilityRecord", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actor\":{\"$ref\":\"/components/schemas/IssuerPrincipal\"},\"actorRef\":{\"type\":\"string\"},\"decision\":{\"type\":\"string\"},\"decisionReceipt\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewDecisionReceipt\"},{\"type\":\"null\"}]},\"eventId\":{\"type\":\"string\"},\"occurredAt\":{\"type\":\"string\"},\"privateReason\":{\"type\":[\"string\",\"null\"]},\"profileId\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"},\"resultDigest\":{\"type\":[\"string\",\"null\"]},\"retainedUntil\":{\"type\":\"string\"},\"taskId\":{\"type\":\"string\"}},\"required\":[\"eventId\",\"requestId\",\"taskId\",\"actorRef\",\"actor\",\"profileId\",\"decision\",\"occurredAt\",\"retainedUntil\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAnswerDocument", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":0,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"download\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewAnswerDownload\"},{\"type\":\"null\"}]},\"id\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[0-9a-f]{64}$\",\"type\":\"string\"},\"verificationStatus\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"id\",\"sha256\",\"contentType\",\"byteSize\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAnswerDownload", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"method\":{\"pattern\":\"^GET$\",\"type\":\"string\"},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"operation\",\"accessProfile\",\"path\"],\"type\":\"object\"}")], + ["/components/schemas/ReviewAnswerFormEntry", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"addedAt\":{\"type\":\"string\"},\"contractChanged\":{\"type\":\"boolean\"},\"id\":{\"type\":\"string\"},\"input\":{\"additionalProperties\":true,\"type\":[\"object\",\"null\"]}},\"required\":[\"id\",\"addedAt\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAsk", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":[\"string\",\"null\"]},\"askId\":{\"type\":\"string\"},\"askedAt\":{\"type\":\"string\"},\"closedAt\":{\"type\":[\"string\",\"null\"]},\"dueAt\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"state\":{\"$ref\":\"/components/schemas/ReviewAskState\"},\"subject\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAskWant\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"askId\",\"requestId\",\"subject\",\"text\",\"wants\",\"askedAt\",\"state\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAskAnswer", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":\"string\"},\"subject\":{\"$ref\":\"/components/schemas/InputSubjectBinding\"}},\"required\":[\"subject\",\"answeredAt\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAskFeedEntry", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"askId\":{\"type\":\"string\"},\"changedAt\":{\"type\":\"string\"},\"eventId\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"}},\"required\":[\"eventId\",\"requestId\",\"askId\",\"changedAt\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAskFeedPage", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"items\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAskFeedEntry\"},\"type\":\"array\"},\"nextCursor\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"items\"],\"type\":\"object\"}")], ["/components/schemas/ReviewAskOnDue", JSON.parse("{\"enum\":[\"return-to-reviewer\"],\"type\":\"string\"}")], ["/components/schemas/ReviewAskState", JSON.parse("{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"],\"type\":\"string\"}")], - ["/components/schemas/ReviewAskWant", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"answer\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"document\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"}]}")], + ["/components/schemas/ReviewAskWant", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"answer\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"document\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\",\"type\":\"string\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]}")], ["/components/schemas/ReviewCancelRequest", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"reason\":{\"type\":\"string\"},\"subject\":{\"$ref\":\"/components/schemas/InputSubjectBinding\"}},\"required\":[\"subject\",\"reason\"],\"type\":\"object\"}")], ["/components/schemas/ReviewCancelResponse", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"outcome\":{\"const\":\"cancelled\",\"type\":\"string\"},\"result\":{\"$ref\":\"/components/schemas/ReviewResult\"}},\"required\":[\"outcome\",\"result\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"outcome\":{\"const\":\"already-terminal\",\"type\":\"string\"},\"result\":{\"$ref\":\"/components/schemas/ReviewResult\"}},\"required\":[\"outcome\",\"result\"],\"type\":\"object\"}]}")], ["/components/schemas/ReviewCaseloadApplyRequest", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"previewId\":{\"type\":\"string\"}},\"required\":[\"previewId\"],\"type\":\"object\"}")], @@ -429,7 +439,7 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/ReviewClockState", JSON.parse("{\"enum\":[\"running\",\"paused\",\"completed\",\"cancelled\",\"source-facts-missing\"],\"type\":\"string\"}")], ["/components/schemas/ReviewCompletionDestinationPolicy", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"destinationId\":{\"$ref\":\"/components/schemas/LocalId\"},\"recipientBinding\":{\"type\":\"string\"}},\"required\":[\"destinationId\",\"recipientBinding\"],\"type\":\"object\"}")], ["/components/schemas/ReviewCompletionType", JSON.parse("{\"enum\":[\"review.completed\"],\"type\":\"string\"}")], - ["/components/schemas/ReviewContextAnswer", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":\"string\"},\"documents\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAnswerDocument\"},\"maxItems\":32,\"type\":\"array\"},\"text\":{\"maxLength\":2000,\"type\":[\"string\",\"null\"]}},\"required\":[\"documents\",\"answeredAt\"],\"type\":\"object\"}")], + ["/components/schemas/ReviewContextAnswer", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":\"string\"},\"documents\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAnswerDocument\"},\"maxItems\":32,\"type\":\"array\"},\"formEntries\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAnswerFormEntry\"},\"maxItems\":32,\"type\":\"array\"},\"text\":{\"maxLength\":2000,\"type\":[\"string\",\"null\"]}},\"required\":[\"documents\",\"answeredAt\"],\"type\":\"object\"}")], ["/components/schemas/ReviewContextAsk", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"answer\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewContextAnswer\"},{\"type\":\"null\"}]},\"answeredAt\":{\"type\":[\"string\",\"null\"]},\"askId\":{\"type\":\"string\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":[\"string\",\"null\"]},\"state\":{\"$ref\":\"/components/schemas/ReviewAskState\"},\"taskId\":{\"type\":\"string\"},\"text\":{\"type\":\"string\"},\"wants\":{\"items\":{\"$ref\":\"/components/schemas/ReviewAskWant\"},\"type\":\"array\"}},\"required\":[\"askId\",\"taskId\",\"text\",\"wants\",\"askedAt\",\"state\"],\"type\":\"object\"}")], ["/components/schemas/ReviewContextCapability", JSON.parse("{\"enum\":[\"human-display\",\"service-status\",\"task-grant-context\",\"routing-context\"],\"type\":\"string\"}")], ["/components/schemas/ReviewContextContract", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"id\":{\"$ref\":\"/components/schemas/ExternalId\",\"maxLength\":256,\"pattern\":\"\\\\S\"},\"revision\":{\"$ref\":\"/components/schemas/ContentDigest\"},\"schemaDigest\":{\"$ref\":\"/components/schemas/Digest\"}},\"required\":[\"id\",\"revision\",\"schemaDigest\"],\"type\":\"object\"}")], @@ -466,10 +476,10 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/ReviewSourceProjection", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"binding\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"display\":{\"additionalProperties\":true,\"type\":\"object\"},\"displayReference\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"binding\",\"display\"],\"type\":\"object\"}")], ["/components/schemas/ReviewStageAsksPolicy", JSON.parse("{\"additionalProperties\":false,\"allOf\":[{\"if\":{\"properties\":{\"pauseClocks\":{\"const\":true}},\"required\":[\"pauseClocks\"]},\"then\":{\"required\":[\"answerWithin\"]}}],\"properties\":{\"answerWithin\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ElapsedDuration\"},{\"type\":\"null\"}]},\"onDue\":{\"$ref\":\"/components/schemas/ReviewAskOnDue\"},\"pauseClocks\":{\"type\":\"boolean\"}},\"type\":\"object\"}")], ["/components/schemas/ReviewStagePolicy", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"asks\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewStageAsksPolicy\"},{\"type\":\"null\"}]},\"decidingProfiles\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"excludeInitiator\":{\"type\":\"boolean\"},\"excludePreviousStageReviewers\":{\"type\":\"boolean\"},\"id\":{\"$ref\":\"/components/schemas/LocalId\"},\"label\":{\"anyOf\":[{\"$ref\":\"/components/schemas/DisplayText\"},{\"type\":\"null\"}]},\"negativeDecisions\":{\"$ref\":\"/components/schemas/ReviewNegativeDecisionMode\"},\"outcomes\":{\"items\":{\"$ref\":\"/components/schemas/LocalId\"},\"minItems\":1,\"type\":[\"array\",\"null\"],\"uniqueItems\":true},\"publicProgressCode\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewProgressCode\"},{\"type\":\"null\"}]},\"queue\":{\"type\":\"string\"},\"requiredApprovals\":{\"maximum\":32,\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"id\",\"queue\",\"decidingProfiles\",\"requiredApprovals\",\"excludeInitiator\",\"excludePreviousStageReviewers\"],\"type\":\"object\"}")], - ["/components/schemas/ReviewTask", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"createdAt\":{\"type\":\"string\"},\"deadlineAt\":{\"type\":[\"string\",\"null\"]},\"decidedByCaller\":{\"type\":[\"boolean\",\"null\"]},\"decisionReceipt\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewDecisionReceipt\"},{\"type\":\"null\"}]},\"displayReference\":{\"type\":[\"string\",\"null\"]},\"eligibleProfiles\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"marker\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewTaskMarker\"},{\"type\":\"null\"}]},\"queue\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"},\"requesterReference\":{\"type\":\"string\"},\"revision\":{\"type\":\"integer\"},\"staffingDiagnostic\":{\"$ref\":\"/components/schemas/StaffingDiagnostic\"},\"stageId\":{\"type\":\"string\"},\"stageIndex\":{\"maximum\":65535,\"minimum\":0,\"type\":\"integer\"},\"state\":{\"$ref\":\"/components/schemas/ReviewTaskState\"},\"subject\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"taskId\":{\"type\":\"string\"}},\"required\":[\"subject\",\"requesterReference\",\"deadlineAt\",\"createdAt\",\"taskId\",\"requestId\",\"stageIndex\",\"stageId\",\"queue\",\"revision\",\"eligibleProfiles\",\"state\"],\"type\":\"object\"}")], + ["/components/schemas/ReviewTask", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"createdAt\":{\"type\":\"string\"},\"deadlineAt\":{\"type\":[\"string\",\"null\"]},\"decidedByCaller\":{\"type\":[\"boolean\",\"null\"]},\"decisionReceipt\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewDecisionReceipt\"},{\"type\":\"null\"}]},\"displayReference\":{\"type\":[\"string\",\"null\"]},\"eligibleProfiles\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"marker\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewTaskMarker\"},{\"type\":\"null\"}]},\"queue\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"},\"requesterReference\":{\"type\":\"string\"},\"revision\":{\"type\":\"integer\"},\"staffingDiagnostic\":{\"$ref\":\"/components/schemas/StaffingDiagnostic\"},\"stageId\":{\"type\":\"string\"},\"stageIndex\":{\"maximum\":65535,\"minimum\":0,\"type\":\"integer\"},\"state\":{\"$ref\":\"/components/schemas/ReviewTaskState\"},\"subject\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"taskId\":{\"type\":\"string\"},\"unreadMessages\":{\"minimum\":0,\"type\":[\"integer\",\"null\"]}},\"required\":[\"subject\",\"requesterReference\",\"deadlineAt\",\"createdAt\",\"taskId\",\"requestId\",\"stageIndex\",\"stageId\",\"queue\",\"revision\",\"eligibleProfiles\",\"state\"],\"type\":\"object\"}")], ["/components/schemas/ReviewTaskAskRequest", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"$ref\":\"/components/schemas/InputReviewAskWant\"},\"maxItems\":8,\"type\":\"array\"}},\"required\":[\"text\",\"wants\"],\"type\":\"object\"}")], ["/components/schemas/ReviewTaskAsked", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"ask\":{\"$ref\":\"/components/schemas/ReviewAsk\"},\"task\":{\"$ref\":\"/components/schemas/ReviewTask\"}},\"required\":[\"task\",\"ask\"],\"type\":\"object\"}")], - ["/components/schemas/ReviewTaskContext", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"asks\":{\"items\":{\"$ref\":\"/components/schemas/ReviewContextAsk\"},\"type\":\"array\"},\"context\":{\"$ref\":\"/components/schemas/ReviewTaskContextData\"},\"policy\":{\"$ref\":\"/components/schemas/PolicyBinding\"},\"policyClosure\":{\"$ref\":\"/components/schemas/ReviewPolicyClosure\"},\"requestId\":{\"type\":\"string\"},\"requesterReference\":{\"type\":\"string\"},\"resultConstraints\":true,\"subject\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"taskId\":{\"type\":\"string\"}},\"required\":[\"taskId\",\"requestId\",\"subject\",\"requesterReference\",\"policy\",\"policyClosure\",\"context\"],\"type\":\"object\"}")], + ["/components/schemas/ReviewTaskContext", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"additionalForms\":{\"additionalProperties\":{\"type\":\"string\"},\"type\":\"object\"},\"asks\":{\"items\":{\"$ref\":\"/components/schemas/ReviewContextAsk\"},\"type\":\"array\"},\"context\":{\"$ref\":\"/components/schemas/ReviewTaskContextData\"},\"messages\":{\"anyOf\":[{\"$ref\":\"/components/schemas/SourceMessageThread\"},{\"type\":\"null\"}]},\"policy\":{\"$ref\":\"/components/schemas/PolicyBinding\"},\"policyClosure\":{\"$ref\":\"/components/schemas/ReviewPolicyClosure\"},\"requestId\":{\"type\":\"string\"},\"requesterReference\":{\"type\":\"string\"},\"resultConstraints\":true,\"subject\":{\"$ref\":\"/components/schemas/SubjectBinding\"},\"taskId\":{\"type\":\"string\"}},\"required\":[\"taskId\",\"requestId\",\"subject\",\"requesterReference\",\"policy\",\"policyClosure\",\"context\"],\"type\":\"object\"}")], ["/components/schemas/ReviewTaskContextData", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"mode\":{\"const\":\"submitted\",\"type\":\"string\"},\"snapshot\":true},\"required\":[\"mode\",\"snapshot\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"bindingStatus\":{\"$ref\":\"/components/schemas/ReviewSourceBindingStatus\"},\"mode\":{\"const\":\"current-source\",\"type\":\"string\"},\"projection\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewSourceProjection\"},{\"type\":\"null\"}]},\"reference\":{\"type\":\"string\"}},\"required\":[\"mode\",\"reference\",\"bindingStatus\"],\"type\":\"object\"}]}")], ["/components/schemas/ReviewTaskDecisionRequest", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"decision\":{\"$ref\":\"/components/schemas/InputDecisionKind\"}},\"required\":[\"decision\"],\"type\":\"object\"}")], ["/components/schemas/ReviewTaskDraft", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"author\":{\"$ref\":\"/components/schemas/IssuerPrincipal\"},\"body\":true,\"revision\":{\"type\":\"integer\"},\"taskId\":{\"type\":\"string\"},\"updatedAt\":{\"type\":\"string\"}},\"required\":[\"taskId\",\"author\",\"body\",\"revision\",\"updatedAt\"],\"type\":\"object\"}")], @@ -481,6 +491,12 @@ const rules: Record = Object.fromEntries([ ["/components/schemas/RoutingPredicate", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"equals\":true},\"required\":[\"equals\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"oneOf\":{\"items\":true,\"type\":\"array\"}},\"required\":[\"oneOf\"],\"type\":\"object\"}]}")], ["/components/schemas/RoutingRule", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"because\":{\"$ref\":\"/components/schemas/DisplayText\"},\"id\":{\"$ref\":\"/components/schemas/LocalId\"},\"label\":{\"anyOf\":[{\"$ref\":\"/components/schemas/DisplayText\"},{\"type\":\"null\"}]},\"queue\":{\"type\":\"string\"},\"when\":{\"$ref\":\"/components/schemas/RoutingCondition\"}},\"required\":[\"id\",\"because\",\"when\",\"queue\"],\"type\":\"object\"}")], ["/components/schemas/SchedulingTaskPermission", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actions\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"location\":{\"type\":\"string\"},\"service\":{\"type\":\"string\"}},\"required\":[\"service\",\"location\",\"actions\"],\"type\":\"object\"}")], + ["/components/schemas/SourceMessage", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"from\":{\"$ref\":\"/components/schemas/SourceMessageSide\"},\"id\":{\"type\":\"string\"},\"mine\":{\"type\":\"boolean\"},\"partyRole\":{\"anyOf\":[{\"$ref\":\"/components/schemas/SourceMessagePartyRole\"},{\"type\":\"null\"}]},\"sentAt\":{\"type\":\"string\"},\"text\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"id\",\"from\",\"mine\",\"sentAt\"],\"type\":\"object\"}")], + ["/components/schemas/SourceMessageAvailability", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":0,\"type\":\"integer\"},\"reason\":{\"type\":[\"string\",\"null\"]},\"recovery\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"available\",\"observedRevision\"],\"type\":\"object\"}")], + ["/components/schemas/SourceMessageLink", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"anyOf\":[{\"$ref\":\"/components/schemas/SourceMessageAvailability\"},{\"type\":\"null\"}]},\"ifMatch\":{\"type\":[\"string\",\"null\"]},\"method\":{\"type\":\"string\"},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"availability\"],\"type\":\"object\"}")], + ["/components/schemas/SourceMessagePartyRole", JSON.parse("{\"enum\":[\"owner\",\"subject\"],\"type\":\"string\"}")], + ["/components/schemas/SourceMessageSide", JSON.parse("{\"enum\":[\"party\",\"official\"],\"type\":\"string\"}")], + ["/components/schemas/SourceMessageThread", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"count\":{\"maximum\":65535,\"minimum\":0,\"type\":\"integer\"},\"items\":{\"items\":{\"$ref\":\"/components/schemas/SourceMessage\"},\"type\":[\"array\",\"null\"]},\"lastSentAt\":{\"type\":[\"string\",\"null\"]},\"links\":{\"additionalProperties\":{\"$ref\":\"/components/schemas/SourceMessageLink\"},\"type\":[\"object\",\"null\"]},\"unread\":{\"maximum\":65535,\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"count\",\"unread\"],\"type\":\"object\"}")], ["/components/schemas/StaffingDiagnostic", JSON.parse("{\"enum\":[\"no-cover-available\",\"insufficient-distinct-approvers\"],\"type\":\"string\"}")], ["/components/schemas/StageClockAnchor", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"type\":{\"$ref\":\"/components/schemas/StageClockAnchorType\"}},\"required\":[\"type\"],\"type\":\"object\"}")], ["/components/schemas/StageClockAnchorType", JSON.parse("{\"enum\":[\"stage-entered\"],\"type\":\"string\"}")], @@ -1021,7 +1037,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/412/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemPreconditionFailed\"}")], ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/413/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemRequestBodyTooLarge\"}")], ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/415/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemRequestUnsupportedMediaType\"}")], - ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/422/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemRequestUnprocessable\"}")], + ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/422/content/application~1problem+json/schema", JSON.parse("{\"oneOf\":[{\"$ref\":\"/components/schemas/ProblemRequestUnprocessable\"},{\"$ref\":\"/components/schemas/ProblemReviewAskFormUnknown\"}]}")], ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemPreconditionRequired\"}")], ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/500/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/ProblemRuntimeFailure\"}")], ["/paths/~1v1~1review-tasks~1{taskId}~1asks/post/responses/502/content/application~1problem+json/schema", JSON.parse("{\"oneOf\":[{\"$ref\":\"/components/schemas/ProblemSourceBadGateway\"},{\"$ref\":\"/components/schemas/ProblemSourceVersionMismatch\"},{\"$ref\":\"/components/schemas/ProblemSourceVersionUnavailable\"}]}")], diff --git a/clients/typescript/tests/casework.test.ts b/clients/typescript/tests/casework.test.ts index 435ffe302e..39d0f3d676 100644 --- a/clients/typescript/tests/casework.test.ts +++ b/clients/typescript/tests/casework.test.ts @@ -109,7 +109,7 @@ test('Casework accepts source threads with absent optional fields and still requ list: { ...link, method: 'GET', availability }, } const readContext = (messages: unknown) => client(200, JSON.stringify({ ...taskContext, messages }), - { 'content-type': 'application/json', traceparent }).call('getReviewTaskContext', { path: { task_id: id } }) + { 'content-type': 'application/json', traceparent }).call('getReviewTaskContext', { path: { taskId: id } }) const thread = { count: 2, unread: 1, lastSentAt: sentAt, items: [erased, official], links } assert.equal((await readContext(undefined)).data.messages, undefined) diff --git a/products/casework/generated/registry-casework.openapi.json b/products/casework/generated/registry-casework.openapi.json index 51f855982a..11e95fec1d 100644 --- a/products/casework/generated/registry-casework.openapi.json +++ b/products/casework/generated/registry-casework.openapi.json @@ -1285,6 +1285,24 @@ "kind" ], "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "form": { + "pattern": "^[a-z][a-z0-9_-]{0,63}$", + "type": "string" + }, + "kind": { + "const": "form", + "type": "string" + } + }, + "required": [ + "kind", + "form" + ], + "type": "object" } ] }, @@ -2233,6 +2251,32 @@ } ] }, + "ProblemReviewAskFormUnknown": { + "allOf": [ + { + "$ref": "#/components/schemas/Problem" + }, + { + "properties": { + "code": { + "const": "review.ask-form-unknown" + }, + "detail": { + "const": "The review source does not declare the requested form." + }, + "status": { + "const": 422 + }, + "title": { + "const": "Unknown review ask form" + }, + "type": { + "const": "https://id.registrystack.org/problems/registry-casework/review/ask-form-unknown" + } + } + } + ] + }, "ProblemReviewAskLimitReached": { "allOf": [ { @@ -3009,6 +3053,34 @@ ], "type": "object" }, + "ReviewAnswerFormEntry": { + "additionalProperties": false, + "properties": { + "addedAt": { + "format": "date-time", + "type": "string" + }, + "contractChanged": { + "type": "boolean" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "input": { + "additionalProperties": true, + "type": [ + "object", + "null" + ] + } + }, + "required": [ + "id", + "addedAt" + ], + "type": "object" + }, "ReviewAsk": { "additionalProperties": false, "description": "A reviewer's request for more from the subject's owner. The provider owns\nthe ask; the producer reads it and reports only that it was answered.", @@ -3190,6 +3262,24 @@ "kind" ], "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "form": { + "pattern": "^[a-z][a-z0-9_-]{0,63}$", + "type": "string" + }, + "kind": { + "const": "form", + "type": "string" + } + }, + "required": [ + "kind", + "form" + ], + "type": "object" } ] }, @@ -3645,6 +3735,13 @@ "maxItems": 32, "type": "array" }, + "formEntries": { + "items": { + "$ref": "#/components/schemas/ReviewAnswerFormEntry" + }, + "maxItems": 32, + "type": "array" + }, "text": { "maxLength": 2000, "type": [ @@ -5014,6 +5111,15 @@ "taskId": { "format": "uuid", "type": "string" + }, + "unreadMessages": { + "description": "Party messages on the source's thread that no office reader has read\nyet, as the caller's own source read returned it for this list. Present\nonly when positive. Computed for each read and never stored.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] } }, "required": [ @@ -5076,6 +5182,12 @@ "ReviewTaskContext": { "additionalProperties": false, "properties": { + "additionalForms": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + }, "asks": { "description": "The asks of the applicant on this request, oldest first.", "items": { @@ -5086,6 +5198,17 @@ "context": { "$ref": "#/components/schemas/ReviewTaskContextData" }, + "messages": { + "anyOf": [ + { + "$ref": "#/components/schemas/SourceMessageThread" + }, + { + "type": "null" + } + ], + "description": "The source's live message thread with the applicant, as the source\nserved it to this reviewer. Casework stores none of it." + }, "policy": { "$ref": "#/components/schemas/PolicyBinding" }, @@ -5420,6 +5543,183 @@ ], "type": "object" }, + "SourceMessage": { + "additionalProperties": false, + "description": "One message as the source serves it: plain text, never markup.", + "properties": { + "from": { + "$ref": "#/components/schemas/SourceMessageSide" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "mine": { + "type": "boolean" + }, + "partyRole": { + "anyOf": [ + { + "$ref": "#/components/schemas/SourceMessagePartyRole" + }, + { + "type": "null" + } + ] + }, + "sentAt": { + "format": "date-time", + "type": "string" + }, + "text": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "id", + "from", + "mine", + "sentAt" + ], + "type": "object" + }, + "SourceMessageAvailability": { + "additionalProperties": false, + "properties": { + "available": { + "type": "boolean" + }, + "observedRevision": { + "format": "uint64", + "minimum": 0, + "type": "integer" + }, + "reason": { + "type": [ + "string", + "null" + ] + }, + "recovery": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "available", + "observedRevision" + ], + "type": "object" + }, + "SourceMessageLink": { + "additionalProperties": false, + "description": "A thread command the reviewer follows with their own source token.", + "properties": { + "accessProfile": { + "type": "string" + }, + "availability": { + "anyOf": [ + { + "$ref": "#/components/schemas/SourceMessageAvailability" + }, + { + "type": "null" + } + ] + }, + "ifMatch": { + "type": [ + "string", + "null" + ] + }, + "method": { + "type": "string" + }, + "operation": { + "type": "string" + }, + "path": { + "type": "string" + } + }, + "required": [ + "method", + "path", + "accessProfile", + "operation", + "availability" + ], + "type": "object" + }, + "SourceMessagePartyRole": { + "enum": [ + "owner", + "subject" + ], + "type": "string" + }, + "SourceMessageSide": { + "enum": [ + "party", + "official" + ], + "type": "string" + }, + "SourceMessageThread": { + "additionalProperties": false, + "description": "The published shape of a source's message thread. Casework passes the\nthread through as the source served it; this type only describes it.", + "properties": { + "count": { + "format": "uint16", + "maximum": 65535, + "minimum": 0, + "type": "integer" + }, + "items": { + "items": { + "$ref": "#/components/schemas/SourceMessage" + }, + "type": [ + "array", + "null" + ] + }, + "lastSentAt": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "links": { + "additionalProperties": { + "$ref": "#/components/schemas/SourceMessageLink" + }, + "type": [ + "object", + "null" + ] + }, + "unread": { + "format": "uint16", + "maximum": 65535, + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "count", + "unread" + ], + "type": "object" + }, "StaffingDiagnostic": { "enum": [ "no-cover-available", @@ -20131,11 +20431,18 @@ "content": { "application/problem+json": { "schema": { - "$ref": "#/components/schemas/ProblemRequestUnprocessable" + "oneOf": [ + { + "$ref": "#/components/schemas/ProblemRequestUnprocessable" + }, + { + "$ref": "#/components/schemas/ProblemReviewAskFormUnknown" + } + ] } } }, - "description": "Problem: request.unprocessable", + "description": "Problem: request.unprocessable, review.ask-form-unknown", "headers": { "Registry-Casework-Validation-Path": { "description": "Bounded value-free JSON path of the member the request type refused; present together with the validation reason.", From d869077771fed3011302255ced517ff172ceb9ee Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:49:00 +0000 Subject: [PATCH 17/96] fix(breg): refresh Proposal event and explain artifacts Signed-off-by: Jeremi Joslin --- products/breg/examples/formats/ctl-report.json | 16 ++++++---------- .../formats/explain/access-explanation.json | 14 ++++++-------- .../formats/explain/actions-explanation.json | 14 +++++--------- .../authored-display-access-explanation.json | 5 +++-- .../authored-display-actions-explanation.json | 6 +++--- .../authored-display-model-explanation.json | 8 ++++---- ...authored-display-proposals-explanation.json | 4 ++-- .../formats/explain/lifecycle-explanation.json | 10 +++++++--- .../formats/explain/model-explanation.json | 18 +++++++----------- .../formats/explain/proposals-explanation.json | 12 ++++-------- .../proposal-lifecycle.schema.json | 2 +- products/identifiers/generated/catalog.v1.json | 2 +- 12 files changed, 49 insertions(+), 62 deletions(-) diff --git a/products/breg/examples/formats/ctl-report.json b/products/breg/examples/formats/ctl-report.json index 488e1ab2da..2da99ab112 100644 --- a/products/breg/examples/formats/ctl-report.json +++ b/products/breg/examples/formats/ctl-report.json @@ -110,7 +110,6 @@ "operations": [ "get-review-status" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "casework-review-status", "readableAttachments": [], @@ -137,7 +136,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -178,7 +176,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [ @@ -220,7 +218,6 @@ "operations": [ "get-review-context" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "proposal-reviewer", "readableAttachments": [], @@ -395,7 +392,7 @@ } } ], - "migrationReviewRevision": "sha256:fdc2665cbe3d95e95b0ce1d02748f6781994ff29ad8ba7d33ef185b3be1c78e0", + "migrationReviewRevision": "sha256:f89bdab0a25240e9d9daba5b96f343bfcba1395894f0c740fd763bc4840e4d27", "permissions": [ { "default": false, @@ -561,7 +558,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -602,7 +598,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [], @@ -659,7 +655,7 @@ } } ], - "migrationReviewRevision": "sha256:9357b712eb303f3e4472bdd8aa4328260f70c0a35c351b5bbbd76e93ca8089cc", + "migrationReviewRevision": "sha256:46a369b59a2d446c60561e60aa5ae9c6f70b4dd6e4cc5f4578373111fe089e61", "permissions": [ { "default": false, @@ -1664,13 +1660,13 @@ "protocol": "id.registrystack.org/protocols/review/v1" } ], - "revision": "sha256:da8467d58f3d97da519f2f7c59ef3eaf9c64cd585cf5bae8b40fdc5fe87a080b", + "revision": "sha256:46625fa6337dd2de466fe8104caf3cd3f464096deeb5325334e7381732437fe0", "statisticalDatasets": [] }, "kind": "BRegCtlReport", "ok": true, "profile": "authoring", - "revision": "sha256:da8467d58f3d97da519f2f7c59ef3eaf9c64cd585cf5bae8b40fdc5fe87a080b", + "revision": "sha256:46625fa6337dd2de466fe8104caf3cd3f464096deeb5325334e7381732437fe0", "status": "complete", "version": "0.52.0-dev" } diff --git a/products/breg/examples/formats/explain/access-explanation.json b/products/breg/examples/formats/explain/access-explanation.json index f22a71b2e6..66aaf31d50 100644 --- a/products/breg/examples/formats/explain/access-explanation.json +++ b/products/breg/examples/formats/explain/access-explanation.json @@ -126,7 +126,6 @@ "operations": [ "get-review-status" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "casework-review-status", "readableAttachments": [], @@ -153,7 +152,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -194,7 +192,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [ @@ -236,7 +234,6 @@ "operations": [ "get-review-context" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "proposal-reviewer", "readableAttachments": [], @@ -411,7 +408,7 @@ } } ], - "migrationReviewRevision": "sha256:fdc2665cbe3d95e95b0ce1d02748f6781994ff29ad8ba7d33ef185b3be1c78e0", + "migrationReviewRevision": "sha256:f89bdab0a25240e9d9daba5b96f343bfcba1395894f0c740fd763bc4840e4d27", "permissions": [ { "default": false, @@ -577,7 +574,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -618,7 +614,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [], @@ -675,7 +671,7 @@ } } ], - "migrationReviewRevision": "sha256:9357b712eb303f3e4472bdd8aa4328260f70c0a35c351b5bbbd76e93ca8089cc", + "migrationReviewRevision": "sha256:46a369b59a2d446c60561e60aa5ae9c6f70b4dd6e4cc5f4578373111fe089e61", "permissions": [ { "default": false, @@ -1838,6 +1834,7 @@ }, { "ownerOnly": true, + "party": "owner", "profile": "facility-correction-author", "recordType": "facility", "rowBoundaries": [ @@ -1921,6 +1918,7 @@ }, { "ownerOnly": true, + "party": "owner", "profile": "facility-correction-author", "recordType": "facility", "rowBoundaries": [ diff --git a/products/breg/examples/formats/explain/actions-explanation.json b/products/breg/examples/formats/explain/actions-explanation.json index 7119b2880a..5571596aab 100644 --- a/products/breg/examples/formats/explain/actions-explanation.json +++ b/products/breg/examples/formats/explain/actions-explanation.json @@ -87,7 +87,6 @@ "operations": [ "get-review-status" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "casework-review-status", "readableAttachments": [], @@ -114,7 +113,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -155,7 +153,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [ @@ -197,7 +195,6 @@ "operations": [ "get-review-context" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "proposal-reviewer", "readableAttachments": [], @@ -372,7 +369,7 @@ } } ], - "migrationReviewRevision": "sha256:fdc2665cbe3d95e95b0ce1d02748f6781994ff29ad8ba7d33ef185b3be1c78e0", + "migrationReviewRevision": "sha256:f89bdab0a25240e9d9daba5b96f343bfcba1395894f0c740fd763bc4840e4d27", "permissions": [ { "default": false, @@ -538,7 +535,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -579,7 +575,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [], @@ -636,7 +632,7 @@ } } ], - "migrationReviewRevision": "sha256:9357b712eb303f3e4472bdd8aa4328260f70c0a35c351b5bbbd76e93ca8089cc", + "migrationReviewRevision": "sha256:46a369b59a2d446c60561e60aa5ae9c6f70b4dd6e4cc5f4578373111fe089e61", "permissions": [ { "default": false, @@ -1641,6 +1637,6 @@ "protocol": "id.registrystack.org/protocols/review/v1" } ], - "revision": "sha256:da8467d58f3d97da519f2f7c59ef3eaf9c64cd585cf5bae8b40fdc5fe87a080b", + "revision": "sha256:46625fa6337dd2de466fe8104caf3cd3f464096deeb5325334e7381732437fe0", "statisticalDatasets": [] } diff --git a/products/breg/examples/formats/explain/authored-display-access-explanation.json b/products/breg/examples/formats/explain/authored-display-access-explanation.json index c64a3b9f44..9d8211d7ec 100644 --- a/products/breg/examples/formats/explain/authored-display-access-explanation.json +++ b/products/breg/examples/formats/explain/authored-display-access-explanation.json @@ -67,7 +67,7 @@ "submit", "cancel" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "directory-editor", "readableAttachments": [], @@ -174,7 +174,7 @@ } } ], - "migrationReviewRevision": "sha256:0a8b66458099c77f339e79b5ae3b13792abde68b014bd226de89af94fa4546f5", + "migrationReviewRevision": "sha256:d03e9d47e003a8f16e6cc8642517a13f5b63846abdd1aa52b5f1ed9481521995", "permissions": [ { "default": true, @@ -396,6 +396,7 @@ }, { "ownerOnly": true, + "party": "owner", "profile": "directory-editor", "recordType": "entry", "rowBoundaries": [], diff --git a/products/breg/examples/formats/explain/authored-display-actions-explanation.json b/products/breg/examples/formats/explain/authored-display-actions-explanation.json index 597db92247..4f2785b333 100644 --- a/products/breg/examples/formats/explain/authored-display-actions-explanation.json +++ b/products/breg/examples/formats/explain/authored-display-actions-explanation.json @@ -55,7 +55,7 @@ "submit", "cancel" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "directory-editor", "readableAttachments": [], @@ -162,7 +162,7 @@ } } ], - "migrationReviewRevision": "sha256:0a8b66458099c77f339e79b5ae3b13792abde68b014bd226de89af94fa4546f5", + "migrationReviewRevision": "sha256:d03e9d47e003a8f16e6cc8642517a13f5b63846abdd1aa52b5f1ed9481521995", "permissions": [ { "default": true, @@ -366,7 +366,7 @@ ], "registryId": "labelled-directory", "reviewAuthorities": [], - "revision": "sha256:c605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50", + "revision": "sha256:91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0", "statisticalDatasets": [ { "accessProfiles": { diff --git a/products/breg/examples/formats/explain/authored-display-model-explanation.json b/products/breg/examples/formats/explain/authored-display-model-explanation.json index d3e93dd588..07038c74b6 100644 --- a/products/breg/examples/formats/explain/authored-display-model-explanation.json +++ b/products/breg/examples/formats/explain/authored-display-model-explanation.json @@ -55,7 +55,7 @@ "submit", "cancel" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "directory-editor", "readableAttachments": [], @@ -163,7 +163,7 @@ } } ], - "migrationReviewRevision": "sha256:0a8b66458099c77f339e79b5ae3b13792abde68b014bd226de89af94fa4546f5", + "migrationReviewRevision": "sha256:d03e9d47e003a8f16e6cc8642517a13f5b63846abdd1aa52b5f1ed9481521995", "permissions": [ { "default": true, @@ -432,7 +432,7 @@ "/accessProfiles/directory-editor/permissions/proposals/0/readableInputs/0", "/accessProfiles/directory-editor/permissions/proposals/0/readableInputs/1", "/accessProfiles/directory-editor/permissions/proposals/0/readableInputs/2", - "/accessProfiles/directory-editor/permissions/proposals/0/ownership", + "/accessProfiles/directory-editor/permissions/proposals/0/party", "/accessProfiles/directory-editor/permissions/proposals/0/targets", "/accessProfiles/directory-editor/permissions/proposals/0/targets/0", "/accessProfiles/directory-editor/permissions/proposals/0/targets/0/recordType", @@ -634,7 +634,7 @@ "registryId": "labelled-directory", "requiresPostgis": false, "reviewAuthorities": [], - "revision": "sha256:c605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50", + "revision": "sha256:91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0", "statisticalDatasets": [ { "accessProfiles": { diff --git a/products/breg/examples/formats/explain/authored-display-proposals-explanation.json b/products/breg/examples/formats/explain/authored-display-proposals-explanation.json index 032f4836a5..d01ea63caf 100644 --- a/products/breg/examples/formats/explain/authored-display-proposals-explanation.json +++ b/products/breg/examples/formats/explain/authored-display-proposals-explanation.json @@ -46,7 +46,7 @@ "submit", "cancel" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "directory-editor", "readableAttachments": [], @@ -153,7 +153,7 @@ } } ], - "migrationReviewRevision": "sha256:0a8b66458099c77f339e79b5ae3b13792abde68b014bd226de89af94fa4546f5", + "migrationReviewRevision": "sha256:d03e9d47e003a8f16e6cc8642517a13f5b63846abdd1aa52b5f1ed9481521995", "permissions": [ { "default": true, diff --git a/products/breg/examples/formats/explain/lifecycle-explanation.json b/products/breg/examples/formats/explain/lifecycle-explanation.json index 2d164cdd38..034e398813 100644 --- a/products/breg/examples/formats/explain/lifecycle-explanation.json +++ b/products/breg/examples/formats/explain/lifecycle-explanation.json @@ -1,5 +1,5 @@ { - "apiVersion": "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha9", + "apiVersion": "id.registrystack.org/formats/breg/lifecycle-explanation/v1alpha10", "kind": "BRegLifecycleExplanation", "lifecycles": [ { @@ -135,16 +135,20 @@ ], "terminal": false, "turns": [ + { + "condition": "An office message on the thread is unread by the party. This changes the turn only, never the status.", + "turn": "party" + }, { "condition": "The submission package is blocked; Review is pending or retrying with an open ask; Review ended without a usable approval; or, after approval or when Review is not required, application is not manual and is blocked without recovery retry.", "turn": "party" }, { - "condition": "The submission package is not blocked, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry.", + "condition": "The submission package is not blocked, no office message is unread by the party, and either Review is pending or being retried without an open ask, or, after approval or when Review is not required, application is manual or is blocked with recovery retry.", "turn": "official" }, { - "condition": "The submission package is not blocked, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status.", + "condition": "The submission package is not blocked, no office message is unread by the party, Review is approved or not required, and application is neither manual nor blocked, including queued, running, or unreported application status.", "turn": "nobody" } ], diff --git a/products/breg/examples/formats/explain/model-explanation.json b/products/breg/examples/formats/explain/model-explanation.json index f02e5d879e..d64651f9ba 100644 --- a/products/breg/examples/formats/explain/model-explanation.json +++ b/products/breg/examples/formats/explain/model-explanation.json @@ -87,7 +87,6 @@ "operations": [ "get-review-status" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "casework-review-status", "readableAttachments": [], @@ -114,7 +113,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -155,7 +153,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [ @@ -197,7 +195,6 @@ "operations": [ "get-review-context" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "proposal-reviewer", "readableAttachments": [], @@ -373,7 +370,7 @@ } } ], - "migrationReviewRevision": "sha256:fdc2665cbe3d95e95b0ce1d02748f6781994ff29ad8ba7d33ef185b3be1c78e0", + "migrationReviewRevision": "sha256:f89bdab0a25240e9d9daba5b96f343bfcba1395894f0c740fd763bc4840e4d27", "permissions": [ { "default": false, @@ -539,7 +536,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -580,7 +576,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [], @@ -638,7 +634,7 @@ } } ], - "migrationReviewRevision": "sha256:9357b712eb303f3e4472bdd8aa4328260f70c0a35c351b5bbbd76e93ca8089cc", + "migrationReviewRevision": "sha256:46a369b59a2d446c60561e60aa5ae9c6f70b4dd6e4cc5f4578373111fe089e61", "permissions": [ { "default": false, @@ -1713,7 +1709,7 @@ "/accessProfiles/facility-correction-author/permissions/proposals/0/readableAttachments/0", "/accessProfiles/facility-correction-author/permissions/proposals/0/writableAttachments", "/accessProfiles/facility-correction-author/permissions/proposals/0/writableAttachments/0", - "/accessProfiles/facility-correction-author/permissions/proposals/0/ownership", + "/accessProfiles/facility-correction-author/permissions/proposals/0/party", "/accessProfiles/facility-correction-author/permissions/proposals/0/targets", "/accessProfiles/facility-correction-author/permissions/proposals/0/targets/0", "/accessProfiles/facility-correction-author/permissions/proposals/0/targets/0/recordType", @@ -1733,7 +1729,7 @@ "/accessProfiles/facility-correction-author/permissions/proposals/1/operations/8", "/accessProfiles/facility-correction-author/permissions/proposals/1/readableInputs", "/accessProfiles/facility-correction-author/permissions/proposals/1/readableInputs/0", - "/accessProfiles/facility-correction-author/permissions/proposals/1/ownership", + "/accessProfiles/facility-correction-author/permissions/proposals/1/party", "/accessProfiles/facility-correction-author/permissions/proposals/1/targets", "/accessProfiles/facility-correction-author/permissions/proposals/1/targets/0", "/accessProfiles/facility-correction-author/permissions/proposals/1/targets/0/recordType", @@ -2602,7 +2598,7 @@ "protocol": "id.registrystack.org/protocols/review/v1" } ], - "revision": "sha256:da8467d58f3d97da519f2f7c59ef3eaf9c64cd585cf5bae8b40fdc5fe87a080b", + "revision": "sha256:46625fa6337dd2de466fe8104caf3cd3f464096deeb5325334e7381732437fe0", "statisticalDatasets": [], "version": "0.1.0" } diff --git a/products/breg/examples/formats/explain/proposals-explanation.json b/products/breg/examples/formats/explain/proposals-explanation.json index dbadcdbc76..4a106102ab 100644 --- a/products/breg/examples/formats/explain/proposals-explanation.json +++ b/products/breg/examples/formats/explain/proposals-explanation.json @@ -53,7 +53,6 @@ "operations": [ "get-review-status" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "casework-review-status", "readableAttachments": [], @@ -80,7 +79,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -121,7 +119,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [ @@ -163,7 +161,6 @@ "operations": [ "get-review-context" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "proposal-reviewer", "readableAttachments": [], @@ -338,7 +335,7 @@ } } ], - "migrationReviewRevision": "sha256:fdc2665cbe3d95e95b0ce1d02748f6781994ff29ad8ba7d33ef185b3be1c78e0", + "migrationReviewRevision": "sha256:f89bdab0a25240e9d9daba5b96f343bfcba1395894f0c740fd763bc4840e4d27", "permissions": [ { "default": false, @@ -504,7 +501,6 @@ "list", "apply" ], - "ownership": null, "principalClaim": "registry_principal", "profileId": "facility-correction-applier", "readableAttachments": [], @@ -545,7 +541,7 @@ "retry", "get-review-status" ], - "ownership": "caller", + "party": "owner", "principalClaim": "registry_principal", "profileId": "facility-correction-author", "readableAttachments": [], @@ -602,7 +598,7 @@ } } ], - "migrationReviewRevision": "sha256:9357b712eb303f3e4472bdd8aa4328260f70c0a35c351b5bbbd76e93ca8089cc", + "migrationReviewRevision": "sha256:46a369b59a2d446c60561e60aa5ae9c6f70b4dd6e4cc5f4578373111fe089e61", "permissions": [ { "default": false, diff --git a/products/breg/generated/event-schemas/proposal-lifecycle.schema.json b/products/breg/generated/event-schemas/proposal-lifecycle.schema.json index 625fc00c6d..3f96631296 100644 --- a/products/breg/generated/event-schemas/proposal-lifecycle.schema.json +++ b/products/breg/generated/event-schemas/proposal-lifecycle.schema.json @@ -1 +1 @@ -{"$id":"https://id.registrystack.org/contracts/breg/proposal-event/v1","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"actionId":{"maxLength":64,"minLength":1,"type":"string"},"actionRevision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"authorityKind":{"enum":["caller","system","review"]},"effectDigest":{"anyOf":[{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},{"type":"null"}]},"fromState":{"anyOf":[{"enum":["draft","submitted","applied","cancelled","rejected"],"type":"string"},{"const":"none"}]},"proposalId":{"format":"uuid","type":"string"},"revision":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"],"type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"},"systemApplyGrantRevision":{"anyOf":[{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},{"type":"null"}]},"transition":{"enum":["started","edited","submitted","revised","rebased","retried","cancelled","applied","rejected","review-returned","added","asked","answered"],"type":"string"},"turn":{"enum":["party","official","nobody"],"type":"string"}},"required":["actionId","actionRevision","proposalId","submissionVersion","revision","fromState","state","transition","effectDigest","authorityKind","systemApplyGrantRevision","turn"],"type":"object"} \ No newline at end of file +{"$id":"https://id.registrystack.org/contracts/breg/proposal-event/v1","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"else":{"not":{"required":["messageFrom"]}},"if":{"properties":{"transition":{"const":"messaged"}}},"properties":{"actionId":{"maxLength":64,"minLength":1,"type":"string"},"actionRevision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"authorityKind":{"enum":["caller","system","review"]},"effectDigest":{"anyOf":[{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},{"type":"null"}]},"fromState":{"anyOf":[{"enum":["draft","submitted","applied","cancelled","rejected"],"type":"string"},{"const":"none"}]},"messageFrom":{"enum":["party","official"]},"proposalId":{"format":"uuid","type":"string"},"revision":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"],"type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"},"systemApplyGrantRevision":{"anyOf":[{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},{"type":"null"}]},"transition":{"enum":["started","edited","submitted","revised","rebased","retried","cancelled","applied","rejected","review-returned","added","asked","answered","messaged"],"type":"string"},"turn":{"enum":["party","official","nobody"],"type":"string"}},"required":["actionId","actionRevision","proposalId","submissionVersion","revision","fromState","state","transition","effectDigest","authorityKind","systemApplyGrantRevision","turn"],"then":{"required":["messageFrom"]},"type":"object"} \ No newline at end of file diff --git a/products/identifiers/generated/catalog.v1.json b/products/identifiers/generated/catalog.v1.json index 9f6daced1d..52eb431fcd 100644 --- a/products/identifiers/generated/catalog.v1.json +++ b/products/identifiers/generated/catalog.v1.json @@ -34,7 +34,7 @@ }, "artifact": { "path": "products/breg/generated/event-schemas/proposal-lifecycle.schema.json", - "sha256": "0b68b183c193cd634e7e704051dbd87a4454fa8cc369177303b5faaae994b58e", + "sha256": "05a417817cfe9dda870c20fb9b0eb8392c1d3b3e7d1f4895d0520d3bac14f85a", "mediaType": "application/schema+json" } }, From d621d8af5e03bc1944dc3b43091844267d859bf5 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:48:49 +0000 Subject: [PATCH 18/96] docs(breg): align Proposal event reference with the native schema Signed-off-by: Jeremi Joslin --- .../scripts/breg-event-reference.test.mjs | 23 ++++++++++++++++--- docs/site/src/data/breg-events.yaml | 21 +++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/site/scripts/breg-event-reference.test.mjs b/docs/site/scripts/breg-event-reference.test.mjs index 7609d7078f..bc3aa2cd6b 100644 --- a/docs/site/scripts/breg-event-reference.test.mjs +++ b/docs/site/scripts/breg-event-reference.test.mjs @@ -69,9 +69,26 @@ test('trigger matrix covers the schema enum and the trigger-specific snapshot ru test('Proposal payload fields match the closed native schema and omit retired request data', () => { const schema = JSON.parse(read('../../../products/breg/generated/event-schemas/proposal-lifecycle.schema.json')); - const documented = tables.find((table) => table.id === 'proposal-payload').rows - .flatMap((row) => [...row[0].matchAll(/`([^`]+)`/g)].map((match) => match[1])); - assert.deepEqual(documented.sort(), [...schema.required].sort()); + const { columns, rows } = tables.find((table) => table.id === 'proposal-payload'); + const codeValues = (cell) => Array.from(cell.matchAll(/`([^`]+)`/g), (match) => match[1]); + const fields = (entries) => entries.flatMap(([field]) => codeValues(field)).sort(); + assert.equal(schema.additionalProperties, false); + assert.deepEqual(fields(rows), Object.keys(schema.properties).sort(), 'Proposal event properties'); + + const requiredColumn = columns.indexOf('Required'); + const typeColumn = columns.indexOf('Type'); + assert.deepEqual(fields(rows.filter((row) => row[requiredColumn] === 'Yes')), [...schema.required].sort()); + + const transition = rows.find(([field]) => field === '`transition`'); + assert.deepEqual(codeValues(transition[typeColumn]), schema.properties.transition.enum); + + const messageFrom = rows.find(([field]) => field === '`messageFrom`'); + assert.deepEqual(codeValues(messageFrom[typeColumn]), schema.properties.messageFrom.enum); + assert.equal(messageFrom[requiredColumn], 'Only on `messaged`'); + assert.deepEqual(schema.if, { properties: { transition: { const: 'messaged' } } }); + assert.deepEqual(schema.then, { required: ['messageFrom'] }); + assert.deepEqual(schema.else, { not: { required: ['messageFrom'] } }); + const recordPayload = tables.find((table) => table.id === 'payload').rows.map((row) => row[0]); assert.ok(recordPayload.includes('`recordType`')); assert.ok(!recordPayload.includes('`entity`')); diff --git a/docs/site/src/data/breg-events.yaml b/docs/site/src/data/breg-events.yaml index bd9e7a47a0..81a1de41ab 100644 --- a/docs/site/src/data/breg-events.yaml +++ b/docs/site/src/data/breg-events.yaml @@ -39,17 +39,18 @@ - ['`values`', 'Object', 'Exactly the declared projection, using authored field IDs; unset optional fields are null. A `read` event carries an empty object.'] - ['`access`', 'Object', 'Present on a `read` event only: `accessProfile`, `operationId`, `requester`, `purpose` (string or null), `accessReason` (string or null) and `accessLogEventId` (UUID of the subject access log entry).'] - id: proposal-payload - title: Required Proposal event data fields - columns: [Field, Type, Meaning] + title: Proposal event data fields + columns: [Field, Type, Required, Meaning] rows: - - ['`actionId`, `actionRevision`', 'String and digest', 'Exact governed Action binding.'] - - ['`proposalId`, `submissionVersion`, `revision`', 'UUID and positive integers', 'Exact durable work and transition revision.'] - - ['`fromState`, `state`, `transition`', 'Closed strings', 'Native lifecycle transition and its states. `transition` is `started`, `edited`, `submitted`, `revised`, `rebased`, `retried`, `cancelled`, `applied`, `rejected`, `review-returned` or `messaged`; `rejected` ends the Proposal in the terminal `rejected` state.'] - - ['`messageFrom`', '`party` or `official`', 'On `messaged` only: the side the message was written from. The event never carries the text.'] - - ['`effectDigest`', 'Digest or null', 'Frozen plan identity when available.'] - - ['`authorityKind`', '`caller`, `system` or `review`', 'Authority used for the transition; `review` for a transition a recorded review result caused.'] - - ['`systemApplyGrantRevision`', 'Digest or null', 'Restricted system grant binding for automatic application.'] - - ['`turn`', '`party`, `official` or `nobody`', 'Whose move the Proposal waits on after the transition.'] + - ['`actionId`, `actionRevision`', 'String and digest', 'Yes', 'Exact governed Action binding.'] + - ['`proposalId`, `submissionVersion`, `revision`', 'UUID and positive integers', 'Yes', 'Exact durable work and transition revision.'] + - ['`fromState`, `state`', 'Closed strings', 'Yes', 'Proposal states before and after the transition.'] + - ['`transition`', '`started`, `edited`, `submitted`, `revised`, `rebased`, `retried`, `cancelled`, `applied`, `rejected`, `review-returned`, `added`, `asked`, `answered` or `messaged`', 'Yes', 'Native lifecycle transition. `rejected` ends the Proposal in the terminal `rejected` state.'] + - ['`messageFrom`', '`party` or `official`', 'Only on `messaged`', 'Side that wrote the message. The event never carries the text.'] + - ['`effectDigest`', 'Digest or null', 'Yes', 'Frozen plan identity when available.'] + - ['`authorityKind`', '`caller`, `system` or `review`', 'Yes', 'Authority used for the transition. `review` applies when a recorded review result caused the transition.'] + - ['`systemApplyGrantRevision`', 'Digest or null', 'Yes', 'Restricted system grant binding for automatic application.'] + - ['`turn`', '`party`, `official` or `nobody`', 'Yes', 'Whose move the Proposal waits on after the transition.'] - id: delivery title: Delivery limits and outcomes columns: [Property, Contract] From 06bbee05c573dc244dc8b7a0cf0bb8456a15ba5d Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:53:10 +0000 Subject: [PATCH 19/96] fix(breg): sync native Node Proposal declarations Signed-off-by: Jeremi Joslin --- crates/registry-breg-client-node/index.d.ts | 7 +++ .../breg/client.d.ts | 48 ++++++++++++++++--- .../registry-stack-client-node/breg/client.js | 4 +- .../breg/index.d.ts | 7 +++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/registry-breg-client-node/index.d.ts b/crates/registry-breg-client-node/index.d.ts index e08d7793cd..5857283861 100644 --- a/crates/registry-breg-client-node/index.d.ts +++ b/crates/registry-breg-client-node/index.d.ts @@ -68,6 +68,13 @@ export declare class BaseRegistryClient { readProposalReviewContext(proposal: BRegProposal, cancellation?: ReadCancellation | undefined | null): Promise readProposalReviewContextBatch(binding: BRegProposalReviewBinding, ids: Array, cancellation?: ReadCancellation | undefined | null): Promise answerProposalAsk(proposal: BRegProposal, askId: string, body: any, key: string): Promise + sendProposalMessage(proposal: BRegProposal, text: string, key: string): Promise + listProposalMessages(proposal: BRegProposal, after?: string | undefined | null, limit?: number | undefined | null): Promise + markProposalMessagesRead(proposal: BRegProposal, through: string): Promise + sendProposalMessageFromReview(binding: BRegProposalReviewBinding, context: any, text: string, key: string): Promise + listProposalMessagesFromReview(binding: BRegProposalReviewBinding, context: any, after?: string | undefined | null, limit?: number | undefined | null): Promise + markProposalMessagesReadFromReview(binding: BRegProposalReviewBinding, context: any, through: string): Promise + addProposalFormEntry(proposal: BRegProposal, formId: string, input: Record, key: string): Promise addProposalAddition(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise downloadProposalAddition(proposal: BRegProposal, addition: string): Promise uploadProposalAttachment(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise diff --git a/crates/registry-stack-client-node/breg/client.d.ts b/crates/registry-stack-client-node/breg/client.d.ts index b8b235cb19..95b4efadfd 100644 --- a/crates/registry-stack-client-node/breg/client.d.ts +++ b/crates/registry-stack-client-node/breg/client.d.ts @@ -537,6 +537,8 @@ export interface BRegActionAttachmentDescriptor { } export interface BRegActionDescriptor { + readonly messages: {readonly maximumCount: number; readonly maximumTextBytes: 2000} | null + readonly additionalForms: Readonly> readonly attachments: ReadonlyArray readonly apiName: string readonly revision: string @@ -1020,6 +1022,13 @@ export declare class BaseRegistryClient { downloadProposalAttachment(proposal: BRegProposal, slot: string): Promise answerProposalAsk(proposal: BRegProposal, askId: string, body: BRegProposalAnswerRequest, key: string): Promise downloadProposalAddition(proposal: BRegProposal, addition: string): Promise + sendProposalMessage(proposal: BRegProposal, text: string, key: string): Promise + listProposalMessages(proposal: BRegProposal, after?: string | null, limit?: number): Promise + markProposalMessagesRead(proposal: BRegProposal, through: string): Promise + sendProposalMessageFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, text: string, key: string): Promise + listProposalMessagesFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, after?: string | null, limit?: number): Promise + markProposalMessagesReadFromReview(binding: BRegProposalReviewBinding, context: BRegProposalReviewDocument, through: string): Promise + addProposalFormEntry(proposal: BRegProposal, formId: string, input: JsonObject, key: string): Promise addProposalAddition(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise readProposalReviewStatus(proposal: BRegProposal, request?: ReadRequestOptions): Promise> readProposalReviewStatusWithProgress(proposal: BRegProposal, request?: ReadRequestOptions): Promise> @@ -1101,11 +1110,32 @@ export interface BRegProposalApplicationStatus { readonly recovery?: 'retry' | 'rebase' | 'revise' | 'correct-input' readonly automaticRetry?: {readonly scheduled: boolean; readonly attempts: number; readonly maximumAttempts: number} } +export interface BRegProposalMessage { + readonly id: string; readonly from: 'party' | 'official'; readonly partyRole?: 'owner' | 'subject'; + readonly mine: boolean; readonly sentAt: string; readonly text?: string; +} +export interface BRegProposalMessages { + readonly count: number; readonly unread: number; readonly lastSentAt?: string; + /** Present on review-context batch summaries that identify the read position. */ + readonly readerSide?: 'party' | 'official'; + readonly items?: ReadonlyArray; + readonly links?: Readonly>>; +} +export interface BRegProposalMessagePage { + readonly items: ReadonlyArray; readonly nextCursor?: string; +} +export interface BRegMessagePageOutcome { + readonly kind: 'complete'; readonly value: BRegProposalMessagePage; readonly traceId: string; +} +export interface BRegReviewMessageOutcome { + readonly kind: 'complete'; readonly value: BRegProposalReviewDocument; + readonly traceId: string; readonly etag?: string; +} export interface BRegProposalReviewDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string readonly submissionVersion: number; readonly revision: number; readonly effectDigest: string; readonly reviewable: boolean readonly subject: {readonly source: string; readonly subjectType: 'proposal'; readonly id: string; readonly version: string; readonly digest: string} - readonly context: {readonly reference: string; readonly contract?: {readonly id: string; readonly revision: string; readonly schemaDigest: string}; readonly fields?: Readonly>; readonly asks?: ReadonlyArray} + readonly context: {readonly reference: string; readonly contract?: {readonly id: string; readonly revision: string; readonly schemaDigest: string}; readonly fields?: Readonly>; readonly additionalForms?: Readonly>; readonly messages?: BRegProposalMessages; readonly asks?: ReadonlyArray} readonly requestId?: string /** Present only on an explicit progress status read while the accepted request remains pending. */ readonly progressCode?: string @@ -1130,7 +1160,7 @@ export interface BRegProposalSubmission { readonly decision?: BRegProposalDecision readonly handoffRefusal?: BRegProposalHandoffRefusal } -export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly asks?: ReadonlyArray } +export interface BRegProposalDocument { readonly id: string; readonly actionId: string; readonly actionRevision: string; readonly submissionVersion: number; readonly revision: number; readonly state: 'draft' | 'submitted' | 'cancelled' | 'applied' | 'rejected'; readonly createdAt?: string; readonly partyRole?: BRegProposalPartyRole; readonly turn?: BRegProposalTurn; readonly status?: BRegProposalStatus; readonly decision?: BRegProposalDecision; readonly handoffRefusal?: BRegProposalHandoffRefusal; readonly title?: string; readonly input?: JsonObject; readonly blockedReason?: 'package-changed'; readonly effectDigest?: string; readonly application?: BRegProposalApplication; readonly applicationStatus?: BRegProposalApplicationStatus; readonly links: Readonly>>; readonly attachments?: Readonly>; readonly additions?: Readonly>; readonly additionalForms?: Readonly>; readonly formEntryId?: string; readonly messages?: BRegProposalMessages; readonly asks?: ReadonlyArray } export declare class BRegProposal { private constructor(); private readonly __opaque: void; readonly responseEtag: string | null; readonly identifier: string; readonly actionIdentifier: string; readonly documentJson: string; readonly inputJson?: string | null } export declare class BRegProposalGetBinding { private constructor(); private readonly __opaque: void } export declare class BRegProposalReviewBinding { private constructor(); private readonly __opaque: void } @@ -1155,9 +1185,15 @@ export declare class BRegPreparedProposal { private constructor(); private reado export type BRegProposalAskState = 'open' | 'answered' | 'expired' | 'closed' -export type BRegProposalAskWant = {readonly kind: 'answer'} | {readonly kind: 'document'} -export interface BRegProposalAnswerRequest {readonly text?: string; readonly additions?: ReadonlyArray} -export interface BRegProposalAskAnswer {readonly text?: string; readonly additions: ReadonlyArray; readonly answeredAt: string} +export type BRegProposalAskWant = {readonly kind: 'answer'} | {readonly kind: 'document'} | {readonly kind: 'form'; readonly form: string} +export interface BRegReviewFormEntry { readonly id: string; readonly addedAt: string; readonly input?: JsonObject; readonly contractChanged?: boolean } +export interface BRegProposalFormEntry extends BRegReviewFormEntry { readonly submissionVersion: number } +export interface BRegProposalForm { + readonly id: string; readonly maximumCount: number; readonly items?: ReadonlyArray; + readonly links?: Readonly>>; +} +export interface BRegProposalAnswerRequest {readonly text?: string; readonly additions?: ReadonlyArray; readonly formEntries?: ReadonlyArray} +export interface BRegProposalAskAnswer {readonly text?: string; readonly additions: ReadonlyArray; readonly formEntries?: ReadonlyArray; readonly answeredAt: string} export interface BRegProposalAsk { readonly id: string; readonly text: string; readonly wants: ReadonlyArray readonly askedAt: string; readonly dueAt?: string; readonly state: BRegProposalAskState @@ -1168,5 +1204,5 @@ export interface BRegProposalReviewAnswerDocument { readonly id: string; readonly sha256: string; readonly contentType: string; readonly byteSize: number readonly verificationStatus: 'notRequired' | 'pending' | 'approved' | 'rejected'; readonly download?: BRegProposalReviewAnswerDownload } -export interface BRegProposalReviewAnswer {readonly text?: string; readonly documents: ReadonlyArray; readonly answeredAt: string} +export interface BRegProposalReviewAnswer {readonly text?: string; readonly documents: ReadonlyArray; readonly formEntries?: ReadonlyArray; readonly answeredAt: string} export interface BRegProposalReviewAsk extends Omit {readonly answer?: BRegProposalReviewAnswer} diff --git a/crates/registry-stack-client-node/breg/client.js b/crates/registry-stack-client-node/breg/client.js index 4382702991..837311f27c 100644 --- a/crates/registry-stack-client-node/breg/client.js +++ b/crates/registry-stack-client-node/breg/client.js @@ -304,7 +304,9 @@ for (const [method, jsonIndexes, requiredIndexes] of [ ['startProposal', [1], [1]], ['readProposal'], ['readProposalSubmission'], ['getProposal'], ['listProposals', [1], [1]], ['executeProposal'], ['listProposalsJson'], ['downloadProposalAttachment'], ['uploadProposalAttachment'], ['deleteProposalAttachment'], ['answerProposalAsk'], - ['addProposalAddition'], ['downloadProposalAddition'], + ['sendProposalMessage'], ['listProposalMessages'], ['markProposalMessagesRead'], + ['sendProposalMessageFromReview'], ['listProposalMessagesFromReview'], ['markProposalMessagesReadFromReview'], + ['addProposalFormEntry'], ['addProposalAddition'], ['downloadProposalAddition'], ['downloadRecordAttachment'], ['readProposalReviewStatus'], ['readProposalReviewStatusWithProgress'], ['readProposalReviewContext'], ['readProposalReviewContextBatch', [1], [1]], diff --git a/crates/registry-stack-client-node/breg/index.d.ts b/crates/registry-stack-client-node/breg/index.d.ts index 9b3c5e11bd..81769a1b0b 100644 --- a/crates/registry-stack-client-node/breg/index.d.ts +++ b/crates/registry-stack-client-node/breg/index.d.ts @@ -60,6 +60,13 @@ export declare class BaseRegistryClient { readProposalReviewContext(proposal: BRegProposal, cancellation?: ReadCancellation | undefined | null): Promise readProposalReviewContextBatch(binding: BRegProposalReviewBinding, ids: Array, cancellation?: ReadCancellation | undefined | null): Promise answerProposalAsk(proposal: BRegProposal, askId: string, body: any, key: string): Promise + sendProposalMessage(proposal: BRegProposal, text: string, key: string): Promise + listProposalMessages(proposal: BRegProposal, after?: string | undefined | null, limit?: number | undefined | null): Promise + markProposalMessagesRead(proposal: BRegProposal, through: string): Promise + sendProposalMessageFromReview(binding: BRegProposalReviewBinding, context: any, text: string, key: string): Promise + listProposalMessagesFromReview(binding: BRegProposalReviewBinding, context: any, after?: string | undefined | null, limit?: number | undefined | null): Promise + markProposalMessagesReadFromReview(binding: BRegProposalReviewBinding, context: any, through: string): Promise + addProposalFormEntry(proposal: BRegProposal, formId: string, input: Record, key: string): Promise addProposalAddition(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise downloadProposalAddition(proposal: BRegProposal, addition: string): Promise uploadProposalAttachment(proposal: BRegProposal, slot: string, contentType: string, bytes: Buffer, key: string): Promise From 2cd49b3c237d4944ecfe7e04d2a638095f9bbea6 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:54:00 +0000 Subject: [PATCH 20/96] fix(casework): synchronize the unified Node client facade Signed-off-by: Jeremi Joslin --- crates/registry-stack-client-node/casework/client.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/registry-stack-client-node/casework/client.d.ts b/crates/registry-stack-client-node/casework/client.d.ts index baec2f4f4d..e4bc790537 100644 --- a/crates/registry-stack-client-node/casework/client.d.ts +++ b/crates/registry-stack-client-node/casework/client.d.ts @@ -150,6 +150,7 @@ export type KnownCaseworkProblemCode = | 'review.distinct-approver-required' | 'review.ask-already-open' | 'review.ask-answer-time-invalid' + | 'review.ask-form-unknown' | 'review.ask-limit-reached' | 'review.ask-not-offered' | 'review.ask-not-open' @@ -323,6 +324,8 @@ export interface ReviewTask { decidedByCaller?: boolean decisionReceipt?: ReviewDecisionReceipt marker?: ReviewTaskMarker + /** Party messages on the source thread that no office reader has read, when positive. */ + unreadMessages?: SafeInteger } export interface ReviewTaskPage { items: ReadonlyArray; nextCursor?: Uuid; status: PageStatus } export type SupervisoryReviewTaskState = 'open' | 'held' | 'decided' @@ -341,7 +344,7 @@ export interface ReviewSourceProjection { binding: SubjectBinding; displayRefere export type ReviewTaskContextData = | { mode: 'submitted'; snapshot: Readonly> } | { mode: 'current-source'; reference: string; bindingStatus: ReviewSourceBindingStatus; projection?: ReviewSourceProjection } -export type ReviewAskWant = { kind: 'answer' } | { kind: 'document' } +export type ReviewAskWant = { kind: 'answer' } | { kind: 'document' } | { kind: 'form'; form: string } export type ReviewAskState = 'open' | 'answered' | 'expired' | 'closed' export interface ReviewTaskAskRequest { text: string; wants: ReadonlyArray } export interface ReviewAsk { @@ -375,6 +378,7 @@ export interface ReviewContextAnswer { text?: string documents: ReadonlyArray answeredAt: string + formEntries?: ReadonlyArray<{id: string; addedAt: string; input?: JsonObject; contractChanged?: boolean}> } export interface ReviewContextAsk { askId: Uuid @@ -397,6 +401,8 @@ export interface ReviewTaskContext { resultConstraints?: JsonObject context: ReviewTaskContextData asks?: ReadonlyArray + additionalForms?: Readonly> + messages?: JsonObject } export type ReviewClockCorrelation = | { scope: 'subject'; source: string; subjectType: string; id: string } From fe0d1d79fb6aeca168341f5c9a4a1565aa960df6 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 02:56:21 +0000 Subject: [PATCH 21/96] test(breg): expect the claim-based Action Create refusal Signed-off-by: Jeremi Joslin --- .../registry-breg/tests/support/membership_write_journeys.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/registry-breg/tests/support/membership_write_journeys.rs b/crates/registry-breg/tests/support/membership_write_journeys.rs index 151d62fb34..58b40ded88 100644 --- a/crates/registry-breg/tests/support/membership_write_journeys.rs +++ b/crates/registry-breg/tests/support/membership_write_journeys.rs @@ -1016,8 +1016,10 @@ async fn membership_refusals_match_the_claim_boundary_answer_at_each_step() { let denied = json!({"organization":fixture.keys.foreign,"label":"denied-action"}); let observed = action(app, &member, "register-facility", MEMBER, denied.clone()).await; let twin = action(app, &claimed, "register-facility", CLAIMED, denied).await; + // The claim boundary is decidable from the request. Membership needs + // a live check and retains the generic precondition response. observed.problem(StatusCode::PRECONDITION_FAILED, "precondition.failed"); - observed.assert_same_problem(&twin); + twin.assert_same_problem(&claim_refusal); answers.insert( format!("{posture}-observed-precondition"), observed.golden(), From 57f91fb59be713bb28637aab5392ac0cf4fb5e64 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 03:10:15 +0000 Subject: [PATCH 22/96] test(breg): pin revisions for Proposal Problem schemas The shared OpenAPI Problem schema adds the form and message refusal codes to every compiled inventory. Refresh the exact fixture revisions and retain the independent DDL and Action contract pins. Signed-off-by: Jeremi Joslin --- crates/registry-breg/tests/compiled_ddl_pins.rs | 14 +++++++++----- .../tests/golden/membership-revision.txt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/registry-breg/tests/compiled_ddl_pins.rs b/crates/registry-breg/tests/compiled_ddl_pins.rs index 0bfa81cee3..8d427d63c1 100644 --- a/crates/registry-breg/tests/compiled_ddl_pins.rs +++ b/crates/registry-breg/tests/compiled_ddl_pins.rs @@ -104,8 +104,12 @@ //! The generated project SDK passes `limit` to the native list calls, which //! changes the packaged SDK and artifact revisions. SQL and Action pins stay //! fixed. -//! The Proposal additional form and message OpenAPI problems move the -//! artifact revisions while preserving the SQL and Action fingerprints. +//! The shared OpenAPI Problem schema adds `proposal.form-undeclared`, +//! `proposal.form-limit-reached`, and `proposal.message-limit-reached`. +//! Every fixture includes that schema in `generated/openapi.json`, so the +//! canonical artifact inventory produces a different revision for each fixture +//! even when it declares no Proposal Actions. DDL and Action definition +//! fingerprints are computed independently of OpenAPI. use registry_breg::compiler::{compile_project, CompileProfile}; use registry_breg::contract::{parse_module_yaml, parse_project_yaml}; @@ -139,7 +143,7 @@ const FIXTURES: &[Fixture] = &[ "../../../products/breg/fixtures/asset-registration-actions/modules/asset-registration-actions-core/module.yaml" )), ddl_sha256: "43acdae956eb2f932fb22a2cccc5cee5ed19cf806f2f28bbc677eff219d00b99", - revision: "sha256:2ab48b17d42c7e06b9ca0bb33de9d3e17e7864656dc98fee4c15f386e55ddf55", + revision: "sha256:9f676cf2e5a97a63587659604a6a12c022b318856fa40a0ca34bdb6393387caf", }, Fixture { name: "facility-registry-actions", @@ -150,7 +154,7 @@ const FIXTURES: &[Fixture] = &[ "../../../products/breg/fixtures/facility-registry-actions/modules/facility-registry-actions-core/module.yaml" )), ddl_sha256: "6439a877ee6508b999a77242542695d8ccddc6d80518699d90eddc32b305780b", - revision: "sha256:9b46e4f5bf7d5d115411768b94b44db919c84648adc4cb6c5d8d9b976d3c6d6f", + revision: "sha256:b645293f26040f1cb62f8d445b22bff0bb4a030dcfd2dd8f9d5330dc09e88d03", }, Fixture { name: "household-contact-actions", @@ -161,7 +165,7 @@ const FIXTURES: &[Fixture] = &[ "../../../products/breg/fixtures/household-contact-actions/modules/household-contact-actions-core/module.yaml" )), ddl_sha256: "f82f2f8376df97fb184c04d31c8e42c291f7a03dbd909828e1bf61612106de35", - revision: "sha256:a75cbc6e65d24415a55a5a949b01bfbbe68c3588ff2749b8ae7f68cd2934aa42", + revision: "sha256:c432a662014b64d65be228e667b5b48b8b164f661aabe6711e44c07c365ce1c8", }, ]; diff --git a/crates/registry-breg/tests/golden/membership-revision.txt b/crates/registry-breg/tests/golden/membership-revision.txt index e95543f33c..69e7c1ff86 100644 --- a/crates/registry-breg/tests/golden/membership-revision.txt +++ b/crates/registry-breg/tests/golden/membership-revision.txt @@ -1 +1 @@ -sha256:e3b01116bfd0a84ff1482f9db8f19befc314af06073cded1666853dba3b26891 +sha256:abf7076e7ca40d96d8f750f0e2e015d4a56b46ade222d94ae7a0cfae45b344bd From 2decc453e43d8e1bbe6d82f79b8bc7b4f23cd385 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 03:10:22 +0000 Subject: [PATCH 23/96] test(breg): cover compatible ask wants while advancing the feed Assert that the feed refuses a form want missing its required form, mirrors a subsequent answer want with an additive member, and checkpoints that page. CI run 47020138056 job 143959749903 supplied the red baseline. Formatting and diff checks passed locally. Focused PostgreSQL verification is pending the integrated build slot. Signed-off-by: Jeremi Joslin --- .../tests/support/proposal_review_asks.rs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/crates/registry-breg/tests/support/proposal_review_asks.rs b/crates/registry-breg/tests/support/proposal_review_asks.rs index 1392ac90af..9d042615e2 100644 --- a/crates/registry-breg/tests/support/proposal_review_asks.rs +++ b/crates/registry-breg/tests/support/proposal_review_asks.rs @@ -806,30 +806,36 @@ async fn matching_an_action_input_does_not_make_a_caller_the_proposal_subject() } #[tokio::test] -async fn ask_feed_refuses_a_form_id_on_an_answer_want_and_keeps_moving() { +async fn ask_feed_skips_a_form_want_missing_its_form_and_mirrors_an_additive_answer_want() { let authority = Authority::start(false, true).await; let fixture = fixture(&authority).await; let id = submitted(&fixture, "ask-feed-want-contract").await; let binding = retained_binding(&fixture, id).await; accept(&fixture, id, &binding).await; - let (malformed, event) = announce(&authority, &binding); - authority - .state - .asks - .lock() - .unwrap() - .replies - .get_mut(&malformed) - .unwrap() - .1["wants"] = json!([{"kind":"answer","formId":"extra-details"}]); - let (valid, last) = announce(&authority, &binding); + let (missing_form, refused_event) = announce(&authority, &binding); + let (additive_answer, last) = announce(&authority, &binding); + { + let mut asks = authority.state.asks.lock().unwrap(); + asks.replies.get_mut(&missing_form).unwrap().1["wants"] = json!([{"kind":"form"}]); + asks.replies.get_mut(&additive_answer).unwrap().1["wants"] = + json!([{"kind":"answer","formId":"extra-details"}]); + } assert!(worker(&fixture, &authority).await.unwrap()); - let receipt = fixture.database.admin.query_one("SELECT state,error_code FROM registry_internal.registry_proposal_review_ask_feed_events WHERE event_id=$1", &[&event]).await.unwrap(); + let receipt = fixture.database.admin.query_one("SELECT state,error_code FROM registry_internal.registry_proposal_review_ask_feed_events WHERE event_id=$1", &[&refused_event]).await.unwrap(); assert_eq!(receipt.get::<_, String>(0), "refused"); assert_eq!(receipt.get::<_, String>(1), "ask-protocol-refused"); - let mirrored = fixture.database.admin.query_one("SELECT ask_id FROM registry_internal.registry_proposal_review_asks WHERE proposal_id=$1", &[&id]).await.unwrap(); - assert_eq!(mirrored.get::<_, Uuid>(0), valid); + let mirrored = fixture + .database + .admin + .query_one( + "SELECT ask_id,wants FROM registry_internal.registry_proposal_review_asks WHERE proposal_id=$1", + &[&id], + ) + .await + .unwrap(); + assert_eq!(mirrored.get::<_, Uuid>(0), additive_answer); + assert_eq!(mirrored.get::<_, Value>(1), json!([{"kind":"answer"}])); let checkpoint = fixture .database .admin From 5e183063b9ff8ed818efbc8f2d86ed2b2943cd0b Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 03:37:19 +0000 Subject: [PATCH 24/96] fix(breg): stabilize review form citation constraint names Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/review_store/asks.rs | 7 +- .../fixtures/v0.51.0-review-ask-files.sql | 186 ++++++++++++++++++ .../tests/schema_fingerprint_rehearsal.rs | 57 +++++- 3 files changed, 247 insertions(+), 3 deletions(-) create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-review-ask-files.sql diff --git a/crates/registry-breg/src/review_store/asks.rs b/crates/registry-breg/src/review_store/asks.rs index 805ce97c85..e6be49718e 100644 --- a/crates/registry-breg/src/review_store/asks.rs +++ b/crates/registry-breg/src/review_store/asks.rs @@ -85,6 +85,7 @@ pub(super) async fn install(client: &impl GenericClient) -> Result<(), MutationE CREATE INDEX IF NOT EXISTS registry_proposal_form_entries_form ON registry_internal.registry_proposal_form_entries (action_id,proposal_id,submission_version,form_id); + -- Keep the ask-files automatic constraint names stable on fresh installs. CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_form_entries ( authority text NOT NULL, review_request_id uuid NOT NULL, @@ -94,10 +95,12 @@ pub(super) async fn install(client: &impl GenericClient) -> Result<(), MutationE submission_version bigint NOT NULL, entry_id uuid NOT NULL, PRIMARY KEY (action_id,proposal_id,submission_version,entry_id), - FOREIGN KEY (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) + CONSTRAINT breg_ask_form_answer_fkey + FOREIGN KEY (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) REFERENCES registry_internal.registry_proposal_review_ask_answers (authority,review_request_id,ask_id,action_id,proposal_id,submission_version), - FOREIGN KEY (action_id,proposal_id,submission_version,entry_id) + CONSTRAINT breg_ask_form_entry_fkey + FOREIGN KEY (action_id,proposal_id,submission_version,entry_id) REFERENCES registry_internal.registry_proposal_form_entries ); CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_files ( diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-review-ask-files.sql b/crates/registry-breg/tests/fixtures/v0.51.0-review-ask-files.sql new file mode 100644 index 0000000000..19f7004a53 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-review-ask-files.sql @@ -0,0 +1,186 @@ +-- SPDX-License-Identifier: Apache-2.0 +-- The v0.51.0 ask-files table and its transitive CREATE TABLE dependencies. +-- Taken from the Proposal, attachment, and Review stores at the v0.51.0 tag. +-- The current installer supplies the rest of the managed schema. + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_state ( + action_id text NOT NULL CHECK (action_id <> ''), + proposal_id uuid NOT NULL UNIQUE, + owner_reference text NOT NULL CHECK (owner_reference <> ''), + state text NOT NULL CHECK (state IN + ('draft','submitted','cancelled','applied','rejected')), + submission_version bigint NOT NULL CHECK (submission_version BETWEEN 1 AND 4294967295), + workflow_revision bigint NOT NULL CHECK (workflow_revision > 0), + action_revision text NOT NULL DEFAULT '', + action_title text, + input jsonb CHECK (input IS NULL OR jsonb_typeof(input) = 'object'), + input_targets jsonb NOT NULL DEFAULT '[]' CHECK (jsonb_typeof(input_targets) = 'array'), + blocked_reason text + CONSTRAINT registry_proposal_state_blocked_reason_values + CHECK (blocked_reason IS NULL OR blocked_reason IN + ('package-changed','application-refused','application-rebase')), + detail_erased_at timestamptz, + created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + PRIMARY KEY (action_id, proposal_id), + CONSTRAINT registry_proposal_state_detail_erasure_terminal CHECK ( + detail_erased_at IS NULL OR state IN ('cancelled','applied','rejected') + ) +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_submissions ( + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL CHECK (submission_version BETWEEN 1 AND 4294967295), + input_revision bigint NOT NULL CHECK (input_revision > 0), + contract_fingerprint text NOT NULL CHECK (contract_fingerprint ~ '^sha256:[0-9a-f]{64}$'), + effect_digest text NOT NULL CHECK (effect_digest ~ '^sha256:[0-9a-f]{64}$'), + snapshot jsonb, + erased_at timestamptz, + created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + PRIMARY KEY (action_id, proposal_id, submission_version), + FOREIGN KEY (action_id, proposal_id) + REFERENCES registry_internal.registry_proposal_state, + CHECK ((snapshot IS NULL) = (erased_at IS NOT NULL)), + CHECK (snapshot IS NULL OR jsonb_typeof(snapshot) = 'object') +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_additions ( + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL CHECK (submission_version BETWEEN 1 AND 4294967295), + addition_id uuid NOT NULL, + slot_id text NOT NULL, + sha256 text CHECK (sha256 ~ '^[0-9a-f]{64}$'), + content_type text, + byte_size bigint CHECK (byte_size BETWEEN 1 AND 16777216), + added_at timestamptz, + added_by text, + erased_at timestamptz, + PRIMARY KEY (action_id, proposal_id, submission_version, addition_id), + FOREIGN KEY (action_id,proposal_id) REFERENCES registry_internal.registry_proposal_state, + CHECK ((erased_at IS NULL AND sha256 IS NOT NULL AND content_type IS NOT NULL + AND byte_size IS NOT NULL AND added_at IS NOT NULL AND added_by IS NOT NULL) + OR (erased_at IS NOT NULL AND sha256 IS NULL AND content_type IS NULL + AND byte_size IS NULL AND added_at IS NULL AND added_by IS NULL)) +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_submissions ( + action_id text NOT NULL CHECK (action_id <> ''), + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL CHECK (submission_version BETWEEN 1 AND 4294967295), + proposal_digest text NOT NULL CHECK (proposal_digest ~ '^sha256:[0-9a-f]{64}$'), + job_id uuid NOT NULL UNIQUE, + authority text NOT NULL CHECK (authority <> '' AND octet_length(authority) <= 128), + producer_id text NOT NULL CHECK (producer_id <> '' AND octet_length(producer_id) <= 128), + policy_id text NOT NULL CHECK (policy_id <> '' AND octet_length(policy_id) <= 128), + expected_policy jsonb NOT NULL CHECK (jsonb_typeof(expected_policy) = 'object'), + idempotency_key text NOT NULL UNIQUE CHECK ( + idempotency_key <> '' AND octet_length(idempotency_key) <= 128 + ), + create_request jsonb NOT NULL CHECK ( + jsonb_typeof(create_request) = 'object' + AND octet_length(create_request::text) <= 98304 + ), + expected_submission_digest text NOT NULL + CHECK (expected_submission_digest ~ '^sha256:[0-9a-f]{64}$'), + on_approved_mode text NOT NULL CHECK (on_approved_mode IN ('manual','automatic')), + executor text CHECK (executor IS NULL OR (executor <> '' AND octet_length(executor) <= 128)), + state text NOT NULL CHECK (state IN + ('pending','submitting','accepted','uncertain','cancelling','cancelled','failed')), + accepted_binding jsonb CHECK ( + accepted_binding IS NULL OR ( + jsonb_typeof(accepted_binding) = 'object' + AND octet_length(accepted_binding::text) <= 8192 + ) + ), + attempt_count integer NOT NULL DEFAULT 0 CHECK (attempt_count BETWEEN 0 AND 1000), + withdrawn boolean NOT NULL DEFAULT false, + recovery_deadline timestamptz NOT NULL + DEFAULT (transaction_timestamp()+interval '30 days'), + result_poll_attempts integer NOT NULL DEFAULT 0 + CHECK (result_poll_attempts BETWEEN 0 AND 1000), + next_result_poll_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + next_attempt_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + lease_until timestamptz, + last_error_code text CHECK ( + last_error_code IS NULL OR + (last_error_code <> '' AND octet_length(last_error_code) <= 128) + ), + created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + PRIMARY KEY (action_id, proposal_id, submission_version), + FOREIGN KEY (action_id, proposal_id, submission_version) + REFERENCES registry_internal.registry_proposal_submissions, + CHECK ((on_approved_mode = 'manual' AND executor IS NULL) + OR (on_approved_mode = 'automatic' AND executor IS NOT NULL)), + CHECK ((state IN ('accepted','cancelling') AND accepted_binding IS NOT NULL) + OR state NOT IN ('accepted','cancelling')) +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_asks ( + authority text NOT NULL, + review_request_id uuid NOT NULL, + ask_id uuid NOT NULL, + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL, + text text CHECK (text IS NULL OR octet_length(text) BETWEEN 1 AND 2000), + wants jsonb NOT NULL CHECK (jsonb_typeof(wants)='array' AND jsonb_array_length(wants)<=8), + asked_at timestamptz NOT NULL, + asked_at_wire text NOT NULL CHECK (octet_length(asked_at_wire)<=64), + due_at timestamptz, + due_at_wire text CHECK (due_at_wire IS NULL OR octet_length(due_at_wire)<=64), + state text NOT NULL CHECK (state IN ('open','answered','expired','closed')), + answered_at timestamptz, + closed_at timestamptz, + detail_erased_at timestamptz, + PRIMARY KEY (authority,review_request_id,ask_id), + UNIQUE (authority,review_request_id,ask_id,action_id,proposal_id,submission_version), + FOREIGN KEY (action_id,proposal_id,submission_version) + REFERENCES registry_internal.registry_proposal_review_submissions +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_answers ( + authority text NOT NULL, + review_request_id uuid NOT NULL, + ask_id uuid NOT NULL, + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL, + text text CHECK (text IS NULL OR octet_length(text)<=2000), + answered_by text, + answered_at timestamptz NOT NULL, + delivery_key text NOT NULL UNIQUE CHECK (octet_length(delivery_key) BETWEEN 1 AND 128), + delivery_state text NOT NULL CHECK (delivery_state IN ('pending','delivered','refused','superseded')), + attempt_count integer NOT NULL DEFAULT 0 CHECK (attempt_count BETWEEN 0 AND 1000), + next_attempt_at timestamptz NOT NULL DEFAULT transaction_timestamp(), + lease_until timestamptz, + claim_token uuid, + delivery_deadline timestamptz NOT NULL CHECK (delivery_deadline>answered_at), + delivered_at timestamptz, + last_error_code text CHECK (last_error_code IS NULL OR octet_length(last_error_code) BETWEEN 1 AND 128), + detail_erased_at timestamptz, + PRIMARY KEY (authority,review_request_id,ask_id), + UNIQUE (authority,review_request_id,ask_id,action_id,proposal_id,submission_version), + FOREIGN KEY (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) + REFERENCES registry_internal.registry_proposal_review_asks + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) +); + +CREATE TABLE IF NOT EXISTS registry_internal.registry_proposal_review_ask_files ( + authority text NOT NULL, + review_request_id uuid NOT NULL, + ask_id uuid NOT NULL, + action_id text NOT NULL, + proposal_id uuid NOT NULL, + submission_version bigint NOT NULL, + addition_id uuid NOT NULL, + PRIMARY KEY (action_id,proposal_id,submission_version,addition_id), + FOREIGN KEY (authority,review_request_id,ask_id,action_id,proposal_id,submission_version) + REFERENCES registry_internal.registry_proposal_review_ask_answers + (authority,review_request_id,ask_id,action_id,proposal_id,submission_version), + FOREIGN KEY (action_id,proposal_id,submission_version,addition_id) + REFERENCES registry_internal.registry_proposal_additions + (action_id,proposal_id,submission_version,addition_id) +); diff --git a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs index 576fd70639..f01436c06e 100644 --- a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs +++ b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs @@ -44,7 +44,7 @@ const SOURCE_REVISION: &str = "rehearsal-source-revision"; // and ask citation tables with the form entry index, and the message table // with each side's read position on the Proposal state row. const PORTABLE_SCHEMA_FINGERPRINT: &str = - "sha256:e0aa036bd82f0274b567be71a63f573cb2dc16e19de231c65f4eed701c081688"; + "sha256:d3858a514b78489cb2438f3f5ba3fea6a31f150a4b6922651a1d497aa3eb62b2"; const FIXTURE_JOURNEYS: &[u8] = br#"apiVersion: id.registrystack.org/formats/breg/journeys/v1 kind: BRegJourneys journeys: [] @@ -92,6 +92,61 @@ async fn rehearsal_rolls_back_and_matches_committed_schema_test_preparation() { database.cleanup().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn fresh_schema_matches_install_over_v051_review_ask_files() { + let registry = compiled_registry(SOURCE_REVISION); + let database = TestDatabase::create(1).await; + let config = runtime_config(&database, ENVIRONMENT, INSTANCE); + let fresh = rehearse_schema_fingerprint_with_connection_config_for_test( + &config, + ®istry, + &database.migration_config, + ) + .await + .expect("fresh schema rehearsal succeeds"); + + let (mut migration, migration_task) = database.connect_migration().await; + let transaction = migration.transaction().await.unwrap(); + transaction + .batch_execute(include_str!("fixtures/v0.51.0-review-ask-files.sql")) + .await + .expect("v0.51.0 review ask-files schema installs"); + let ask_files_oid = + "SELECT 'registry_internal.registry_proposal_review_ask_files'::regclass::oid"; + let predecessor_table: u32 = transaction + .query_one(ask_files_oid, &[]) + .await + .unwrap() + .get(0); + + install_compiled_schema(&transaction, ®istry, &database.runtime_role) + .await + .expect("current installer succeeds over the retained v0.51.0 review ask-files schema"); + let upgraded = managed_schema_fingerprint( + &transaction, + &database.runtime_role, + &ExpectedManagedCatalog::compiled(®istry), + ) + .await + .expect("upgraded managed catalog verifies"); + let upgraded_table: u32 = transaction + .query_one(ask_files_oid, &[]) + .await + .unwrap() + .get(0); + + transaction.rollback().await.unwrap(); + drop(migration); + migration_task.abort(); + database.cleanup().await; + + assert_eq!( + upgraded_table, predecessor_table, + "the ask-files table is retained" + ); + assert_eq!(upgraded, fresh, "fresh and upgraded managed catalogs agree"); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn catalog_verification_refuses_non_portable_text_collation() { let registry = compiled_registry(SOURCE_REVISION); From 702709b2829b2c78cd9fa3161f16fafc20732c87 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 03:58:49 +0000 Subject: [PATCH 25/96] chore(identifiers): refresh the BReg Action contract source digest Signed-off-by: Jeremi Joslin --- products/identifiers/generated/catalog.v1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/identifiers/generated/catalog.v1.json b/products/identifiers/generated/catalog.v1.json index 52eb431fcd..b5c52c944a 100644 --- a/products/identifiers/generated/catalog.v1.json +++ b/products/identifiers/generated/catalog.v1.json @@ -5820,7 +5820,7 @@ "description": "Base Registry Engine portable Action contract export schema, reproduced from the canonical compiled project.", "source": { "path": "crates/registry-breg/src/artifacts.rs", - "sha256": "c0aa8c1c7d6d833c0a252463b61b652dae7d92989ec4d12898c31fc3d04ad089" + "sha256": "41495fb1acc96da8abc4169a653d790b83ef453698d171cfe6f3c78689b4de34" }, "artifact": { "path": "products/breg/generated/facility/generated/action-contracts.schema.json", From b104ce734c6a3f504003a22a42a042b8f87ff063 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:09:18 +0000 Subject: [PATCH 26/96] docs(breg): clarify authority to set Record references Signed-off-by: Jeremi Joslin --- .../src/content/docs/configure/breg-access.mdx | 18 ++++++++++++++---- docs/site/src/content/docs/security/breg.mdx | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/site/src/content/docs/configure/breg-access.mdx b/docs/site/src/content/docs/configure/breg-access.mdx index 9785156213..4aea995352 100644 --- a/docs/site/src/content/docs/configure/breg-access.mdx +++ b/docs/site/src/content/docs/configure/breg-access.mdx @@ -868,7 +868,7 @@ the reason `disclosure-condition`. ### What a condition does not hide -Four limits are inherent to what a write has to check, and a fifth follows from how history works. +Three limits are inherent to what a write has to check, and a fourth follows from how history works. Design around them. - A Proposal's inputs stay visible to its reviewers. A reviewer sees what the author typed, even for @@ -891,12 +891,22 @@ Design around them. - A refused write can reveal that a condition matches. The `403 write.outside-boundary` a bound profile meets tells it that a condition holds for this record. A `null` it read is then known to be withheld rather than unset. -- A write that sets a reference can reveal that a withheld record exists, because the database - checks that the target is there. - `withhold: history` on a record the caller can read answers its revisions as not found. A client that expects the current revision to appear in the history sees it missing. -{/* Evidence: crates/registry-breg/src/disclosure.rs; +To set a reference in a direct write, your access profile needs a `get` or `reference` grant on the +target Record type. +This applies to Create, Patch, Batch items and Import rows. +You can name an active Record within the target grant's row boundaries, including any membership +boundaries. +BReg also applies any `withhold: record` condition that binds the profile. +A `reference` grant authorises only naming targets in direct writes. +See [Name referenced records](#name-referenced-records). + +{/* Evidence: crates/registry-breg/src/disclosure.rs, record_guard_sql; + crates/registry-breg/src/generated_ddl.rs, disclosure_record_policies; + crates/registry-breg/src/access.rs, validate_reference_targets; + crates/registry-breg/src/mutation/reference_reach.rs, require_readable_references; crates/registry-breg/src/compiler/disclosure.rs and compiler/disclosure/reach.rs; crates/registry-breg/tests/disclosure_compile.rs; crates/registry-breg/tests/disclosure/fields.rs, history.rs, proposals.rs, records.rs and diff --git a/docs/site/src/content/docs/security/breg.mdx b/docs/site/src/content/docs/security/breg.mdx index 9133d1b93d..9afaba0d8f 100644 --- a/docs/site/src/content/docs/security/breg.mdx +++ b/docs/site/src/content/docs/security/breg.mdx @@ -1664,13 +1664,12 @@ Each lists the condition, the consequence, the mitigation, and the related matri ### `BREG-RES-27`: a disclosure condition does not hide every trace -- Condition: a disclosure condition binds a profile that reviews, writes, or references the Records - it withholds. +- Condition: a disclosure condition binds a profile that reviews or writes the Records it withholds. - Consequence: the condition hides values, not every effect of their existence. A Proposal's reviewers see its inputs, even for a field their own profile would not read. Their review reads and attachment downloads write no subject-log entry. A `409 mutation.conflict` on a unique value confirms that a hidden Record or a withheld value - exists, and a reference write confirms that its target exists. + exists. A `403 write.outside-boundary` tells a bound writer that a condition matches the Record. A `history` condition answers the revisions of a readable Record as not found. An automatic Proposal cannot change a Record a `record` condition matches, or set a `record` mark, @@ -1689,7 +1688,18 @@ Each lists the condition, the consequence, the mitigation, and the related matri marked roots out. - Related: `BREG-RES-12`, `BREG-RES-14`. -{/* Evidence: crates/registry-breg/tests/disclosure/writes.rs, +To set a reference in a direct write, the same access profile needs an admitted `get` or `reference` +grant on the target Record type. +BReg checks that the target is active and within the grant's row boundaries, including any membership +boundaries. +BReg also applies any `withhold: record` condition that binds the profile. +A `reference` grant authorises only naming targets in direct writes. +See [Referenced records in direct writes](#referenced-records-in-direct-writes). + +{/* Evidence: crates/registry-breg/src/access.rs, validate_reference_targets; + crates/registry-breg/src/mutation/reference_reach.rs, require_readable_references; + crates/registry-breg/src/generated_ddl.rs, disclosure_record_policies; + crates/registry-breg/tests/disclosure/writes.rs, known_limit_an_automatic_proposal_cannot_set_a_record_mark_even_for_an_exempt_submitter, known_limit_an_automatic_proposal_cannot_patch_a_record_a_record_condition_hides; crates/registry-breg/tests/disclosure_compile.rs, From 1b6466d8b1cdecc21b0b76c7c4d38932a1d4bf14 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:12:53 +0000 Subject: [PATCH 27/96] fix(breg): scope membership refusal metrics to BReg Signed-off-by: Jeremi Joslin --- crates/registry-adapter/src/metrics.rs | 2 +- crates/registry-breg/src/metrics.rs | 10 +-- crates/registry-casework/src/metrics.rs | 2 +- crates/registry-coordinator/src/metrics.rs | 4 +- crates/registry-documents/src/metrics.rs | 2 +- .../tests/refusal_golden.rs | 2 +- .../src/observability.rs | 12 +++ .../src/observability/golden-scrape.txt | 1 - .../registry-evidence-oid4vci/src/service.rs | 2 +- .../registry-evidence-oid4vp/src/metrics.rs | 2 +- .../tests/refusal_recording.rs | 9 +- crates/registry-evidence/src/observability.rs | 12 +++ .../src/observability/golden-scrape.txt | 1 - .../src/inbound/refusal_tests.rs | 3 +- crates/registry-messaging/src/metrics.rs | 2 +- .../src/refusal.rs | 86 +++++++++++++++---- crates/registry-render/src/server.rs | 2 +- crates/registry-scheduling/src/metrics.rs | 2 +- .../src/content/docs/security/evidence.mdx | 2 +- products/evidence/OPERATOR-CONTRACT.md | 2 +- 20 files changed, 113 insertions(+), 47 deletions(-) diff --git a/crates/registry-adapter/src/metrics.rs b/crates/registry-adapter/src/metrics.rs index 86981d488a..feb38b56be 100644 --- a/crates/registry-adapter/src/metrics.rs +++ b/crates/registry-adapter/src/metrics.rs @@ -409,7 +409,7 @@ mod tests { .lines() .filter(|line| line.starts_with("adapter_request_refusals_total{check=\"")) .count(); - assert_eq!(declared, registry_platform_authcommon::FailedCheck::COUNT); + assert_eq!(declared, registry_platform_authcommon::FailedCheck::shared().count()); } /// The refusal line a scope refusal writes, driven through the recording diff --git a/crates/registry-breg/src/metrics.rs b/crates/registry-breg/src/metrics.rs index 482b7821c8..4536b48a49 100644 --- a/crates/registry-breg/src/metrics.rs +++ b/crates/registry-breg/src/metrics.rs @@ -54,7 +54,7 @@ use axum::{ Router, }; -use registry_platform_authcommon::RefusalRecorder; +use registry_platform_authcommon::{FailedCheck, RefusalRecorder}; use registry_platform_metrics::{ sample_error_class, Exposition, HistogramSnapshot, MetricKind, ScrapeDeadline, SumCountOrder, CLASS_NO_TIME_LEFT, CLASS_POOL, CONTENT_TYPE as METRICS_MEDIA_TYPE, @@ -185,15 +185,16 @@ pub struct Metrics { /// The process-wide refusal recorder: the one counter family and the one log /// budget that every refused request in this process shares, whichever router -/// served it. It is built once, from a closed label space the enum owns, so -/// construction cannot fail. +/// served it. It is built once with the shared checks and BReg's membership +/// check, so the closed label space is valid by construction. pub(crate) fn process_refusal_recorder() -> &'static Arc { static RECORDER: OnceLock> = OnceLock::new(); RECORDER.get_or_init(|| Arc::new(new_refusal_recorder())) } fn new_refusal_recorder() -> RefusalRecorder { - RefusalRecorder::new("breg").expect("the refusal counter's closed label space is valid") + RefusalRecorder::with_additional_checks("breg", &[FailedCheck::Membership]) + .expect("the refusal counter's closed label space is valid") } impl Default for Metrics { @@ -1334,7 +1335,6 @@ mod tests { #[test] fn the_refusal_counter_declares_every_check_and_publishes_it_at_zero() { - use registry_platform_authcommon::FailedCheck; let rendered = Metrics::default().render(None); for check in FailedCheck::ALL { assert!( diff --git a/crates/registry-casework/src/metrics.rs b/crates/registry-casework/src/metrics.rs index b7f0f8c6e5..d38225842e 100644 --- a/crates/registry-casework/src/metrics.rs +++ b/crates/registry-casework/src/metrics.rs @@ -320,7 +320,7 @@ mod tests { "# HELP casework_request_refusals_total Requests refused, by the check that failed.\n\ # TYPE casework_request_refusals_total counter\n", ); - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { let value = u8::from(counted == Some(check)); text.push_str(&format!( "casework_request_refusals_total{{check=\"{}\"}} {value}\n", diff --git a/crates/registry-coordinator/src/metrics.rs b/crates/registry-coordinator/src/metrics.rs index 5f033c5a89..f8558251ef 100644 --- a/crates/registry-coordinator/src/metrics.rs +++ b/crates/registry-coordinator/src/metrics.rs @@ -586,7 +586,7 @@ mod tests { sample.as_str() ) })); - expected.extend(FailedCheck::ALL.map(|check| { + expected.extend(FailedCheck::shared().map(|check| { format!( "coordinator_request_refusals_total{{check=\"{}\"}}", check.as_str() @@ -672,7 +672,7 @@ mod tests { let refusals_by_check: String = std::iter::once( "# HELP coordinator_request_refusals_total Requests refused, by the check that failed.\n# TYPE coordinator_request_refusals_total counter\n".to_owned(), ) - .chain(FailedCheck::ALL.map(|check| { + .chain(FailedCheck::shared().map(|check| { format!( "coordinator_request_refusals_total{{check=\"{}\"}} {}\n", check.as_str(), diff --git a/crates/registry-documents/src/metrics.rs b/crates/registry-documents/src/metrics.rs index 63a7f92c94..2475268f1d 100644 --- a/crates/registry-documents/src/metrics.rs +++ b/crates/registry-documents/src/metrics.rs @@ -577,7 +577,7 @@ mod tests { fn the_refusal_counter_lists_every_check_from_zero_and_counts_by_check() { let metrics = Metrics::default(); let text = metrics.render(&Sampled::default()); - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { assert!( text.contains(&format!( "documents_request_refusals_total{{check=\"{}\"}} 0", diff --git a/crates/registry-documents/tests/refusal_golden.rs b/crates/registry-documents/tests/refusal_golden.rs index b7dc6bf3e8..7e9c7036a8 100644 --- a/crates/registry-documents/tests/refusal_golden.rs +++ b/crates/registry-documents/tests/refusal_golden.rs @@ -715,7 +715,7 @@ async fn every_refusal_is_counted_and_logged_under_the_check_it_failed() { /// The sum of every series of `documents_request_refusals_total`. async fn counted_in_total(prepared: &Prepared) -> u64 { let mut total = 0; - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { total += counted(prepared, check).await; } total diff --git a/crates/registry-evidence-oid4vci/src/observability.rs b/crates/registry-evidence-oid4vci/src/observability.rs index fee05577f8..b6fca91e13 100644 --- a/crates/registry-evidence-oid4vci/src/observability.rs +++ b/crates/registry-evidence-oid4vci/src/observability.rs @@ -677,6 +677,18 @@ mod tests { response.assert_text_contains("evidence_oid4vci_store_capacity 256"); } + #[test] + fn startup_exposition_keeps_the_shared_refusal_series() { + let rendered = Metrics::new(256).render(); + let series: Vec<_> = rendered + .lines() + .filter(|line| line.starts_with("evidence_oid4vci_request_refusals_total{")) + .collect(); + assert!(series.contains(&"evidence_oid4vci_request_refusals_total{check=\"scope\"} 0")); + assert!(!series.iter().any(|line| line.contains("check=\"membership\""))); + assert_eq!(series.len(), 45); + } + #[tokio::test] async fn metrics_mark_matches_the_declared_posture() { use registry_platform_config::Posture; diff --git a/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt b/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt index d38f376003..67cf00d65c 100644 --- a/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt +++ b/crates/registry-evidence-oid4vci/src/observability/golden-scrape.txt @@ -146,7 +146,6 @@ evidence_oid4vci_request_refusals_total{check="task-grant-scope"} 0 evidence_oid4vci_request_refusals_total{check="task-grant-lifetime"} 0 evidence_oid4vci_request_refusals_total{check="task-grant-status"} 0 evidence_oid4vci_request_refusals_total{check="row-boundary"} 0 -evidence_oid4vci_request_refusals_total{check="membership"} 0 evidence_oid4vci_request_refusals_total{check="ownership"} 0 evidence_oid4vci_request_refusals_total{check="visibility"} 0 evidence_oid4vci_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-evidence-oid4vci/src/service.rs b/crates/registry-evidence-oid4vci/src/service.rs index 641d086755..62ea82488a 100644 --- a/crates/registry-evidence-oid4vci/src/service.rs +++ b/crates/registry-evidence-oid4vci/src/service.rs @@ -6235,7 +6235,7 @@ mod tests { let (cases, services) = refusal_cases().await; for (index, service) in services.iter().enumerate() { - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { let expected = cases .iter() .filter(|(_, case_check, _, case_index)| { diff --git a/crates/registry-evidence-oid4vp/src/metrics.rs b/crates/registry-evidence-oid4vp/src/metrics.rs index 1581282d6e..84118b97e1 100644 --- a/crates/registry-evidence-oid4vp/src/metrics.rs +++ b/crates/registry-evidence-oid4vp/src/metrics.rs @@ -203,7 +203,7 @@ mod tests { let metrics = Metrics::new().expect("the metrics declare"); let store = SessionStore::new(4, 1024, system_clock()); let scrape = metrics.render(&store).expect("the scrape renders"); - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { let series = format!( "evidence_oid4vp_request_refusals_total{{check=\"{}\"}} ", check.as_str() diff --git a/crates/registry-evidence-oid4vp/tests/refusal_recording.rs b/crates/registry-evidence-oid4vp/tests/refusal_recording.rs index 946b2369ac..eb253c5978 100644 --- a/crates/registry-evidence-oid4vp/tests/refusal_recording.rs +++ b/crates/registry-evidence-oid4vp/tests/refusal_recording.rs @@ -54,10 +54,7 @@ fn count(service: &VerifierService, check: FailedCheck) -> u64 { } fn total(service: &VerifierService) -> u64 { - FailedCheck::ALL - .iter() - .map(|check| count(service, *check)) - .sum() + FailedCheck::shared().map(|check| count(service, check)).sum() } /// What a caller sent that must never reach a log line. @@ -121,8 +118,8 @@ async fn each_refusal_is_counted_and_logged_under_its_check() { let harness = Harness::new(&Options::default()).await; let (server, service) = harness.server().await; - // Nothing is counted before a refusal, and every member is declared. - for check in FailedCheck::ALL { + // Nothing is counted before a refusal, and every shared check is declared. + for check in FailedCheck::shared() { assert_eq!(count(&service, check), 0); } let issuer = harness.idp.issuer().to_string(); diff --git a/crates/registry-evidence/src/observability.rs b/crates/registry-evidence/src/observability.rs index 1fc379293d..fc53e6727e 100644 --- a/crates/registry-evidence/src/observability.rs +++ b/crates/registry-evidence/src/observability.rs @@ -946,6 +946,18 @@ async fn metrics_route_absent() -> Response { mod tests { use super::*; + #[test] + fn startup_exposition_keeps_the_shared_refusal_series() { + let rendered = Metrics::default().render(); + let series: Vec<_> = rendered + .lines() + .filter(|line| line.starts_with("evidence_request_refusals_total{")) + .collect(); + assert!(series.contains(&"evidence_request_refusals_total{check=\"scope\"} 0")); + assert!(!series.iter().any(|line| line.contains("check=\"membership\""))); + assert_eq!(series.len(), 45); + } + #[test] fn every_status_class_is_kebab_case() { assert_eq!(StatusCategory::of(StatusCode::OK).as_str(), "success"); diff --git a/crates/registry-evidence/src/observability/golden-scrape.txt b/crates/registry-evidence/src/observability/golden-scrape.txt index 32d2052afe..89d3c341d6 100644 --- a/crates/registry-evidence/src/observability/golden-scrape.txt +++ b/crates/registry-evidence/src/observability/golden-scrape.txt @@ -113,7 +113,6 @@ evidence_request_refusals_total{check="task-grant-scope"} 0 evidence_request_refusals_total{check="task-grant-lifetime"} 0 evidence_request_refusals_total{check="task-grant-status"} 0 evidence_request_refusals_total{check="row-boundary"} 0 -evidence_request_refusals_total{check="membership"} 0 evidence_request_refusals_total{check="ownership"} 0 evidence_request_refusals_total{check="visibility"} 0 evidence_request_refusals_total{check="action-guard"} 0 diff --git a/crates/registry-mcp-edge/src/inbound/refusal_tests.rs b/crates/registry-mcp-edge/src/inbound/refusal_tests.rs index 8645718c78..3042d8d3af 100644 --- a/crates/registry-mcp-edge/src/inbound/refusal_tests.rs +++ b/crates/registry-mcp-edge/src/inbound/refusal_tests.rs @@ -286,8 +286,7 @@ impl Run { } fn record(&mut self, name: &'static str, server: &ResourceServer, answer: Value) { - let counted = FailedCheck::ALL - .iter() + let counted = FailedCheck::shared() .filter_map(|check| { let count = server .refusal_recorder() diff --git a/crates/registry-messaging/src/metrics.rs b/crates/registry-messaging/src/metrics.rs index 887c5d0666..e9b327d9b3 100644 --- a/crates/registry-messaging/src/metrics.rs +++ b/crates/registry-messaging/src/metrics.rs @@ -612,7 +612,7 @@ messaging_metrics_sample_failures_total{sample=\"dispatch-queue\"} 0 let mut text = String::from( "# HELP messaging_request_refusals_total Requests refused, by the check that failed.\n# TYPE messaging_request_refusals_total counter\n", ); - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { text.push_str(&format!( "messaging_request_refusals_total{{check=\"{}\"}} 0\n", check.as_str() diff --git a/crates/registry-platform-authcommon/src/refusal.rs b/crates/registry-platform-authcommon/src/refusal.rs index 4397cb25ed..26ceb638d5 100644 --- a/crates/registry-platform-authcommon/src/refusal.rs +++ b/crates/registry-platform-authcommon/src/refusal.rs @@ -153,7 +153,7 @@ failed_checks! { TaskGrantStatus => "task-grant-status", /// The target row is outside the caller's row boundary. RowBoundary => "row-boundary", - /// The target key failed a membership check. + /// The target key failed a BReg membership check. Membership => "membership", /// The target exists and belongs to another caller. Ownership => "ownership", @@ -166,6 +166,15 @@ failed_checks! { } impl FailedCheck { + /// The checks published by every refusal recorder, in declaration order. + pub fn shared() -> impl Iterator { + Self::ALL.into_iter().filter(|check| check.is_shared()) + } + + fn is_shared(self) -> bool { + self != Self::Membership + } + /// The refusal class of this check. Exhaustive, so a new member cannot /// compile without a class. #[must_use] @@ -388,8 +397,8 @@ mod recorder { /// State is one counter family and a fixed array of slots, one per /// [`FailedCheck`]. Nothing is keyed by a value a caller sends. /// - /// The counter, not the log line, is the alert and diagnosis signal. Every - /// refusal is counted. The log admits at most + /// The counter is the alert and diagnosis signal. The recorder counts + /// every refusal under its declared checks. The log admits at most /// [`REFUSAL_LOG_LINES_PER_WINDOW`] lines per check per /// [`REFUSAL_LOG_WINDOW`], process-wide, so unauthenticated traffic can /// spend a check's lines before an honest client's refusal arrives. The @@ -401,11 +410,19 @@ mod recorder { } impl RefusalRecorder { - /// `product` is the metric prefix, for example "breg" or - /// "evidence_oid4vci". + /// Publish the shared checks, using `product` as the metric prefix. pub fn new(product: &'static str) -> Result { + Self::with_additional_checks(product, &[]) + } + + /// Publish the shared checks and the checks owned by this product. + pub fn with_additional_checks( + product: &'static str, + additional_checks: &[FailedCheck], + ) -> Result { let labels: Vec<[&str; 1]> = FailedCheck::ALL - .iter() + .into_iter() + .filter(|check| check.is_shared() || additional_checks.contains(check)) .map(|check| [check.as_str()]) .collect(); let declared: Vec<&[&str]> = labels.iter().map(<[&str; 1]>::as_slice).collect(); @@ -419,8 +436,9 @@ mod recorder { }) } - /// Count the refusal. Returns the line to write when the limiter - /// admits one. + /// Count the refusal under a declared check. Returns the line to write + /// when the limiter admits one. An undeclared check reports a wiring + /// error at most once per window. #[must_use] pub fn record(&self, check: FailedCheck) -> Option { self.record_at(check, Instant::now()) @@ -432,22 +450,21 @@ mod recorder { // The slot state is plain counters, so a poisoned lock is safe to reuse. let mut slots = self.slots.lock().unwrap_or_else(PoisonError::into_inner); let slot = &mut slots[check as usize]; + let expired = slot + .window_start + .is_none_or(|start| now.saturating_duration_since(start) >= REFUSAL_LOG_WINDOW); if counted.is_err() { - // Labels come from the closed enum, so this is a defect. It is - // reported once per window, not swallowed. - if slot - .window_start - .is_none_or(|start| now.saturating_duration_since(start) >= REFUSAL_LOG_WINDOW) - { + // A check outside this recorder's declared label set is a + // wiring error. Report it once per window. + if expired { + slot.window_start = Some(now); tracing::error!( failed_check = label, "a refusal was rejected by its closed label space" ); } + return None; } - let expired = slot - .window_start - .is_none_or(|start| now.saturating_duration_since(start) >= REFUSAL_LOG_WINDOW); if expired { let suppressed = slot.suppressed; *slot = Slot { @@ -739,11 +756,41 @@ mod recorder_tests { impl crate::RefusalTraceId for ServerTraceId {} #[test] - fn a_new_recorder_exposes_every_check_at_zero() { + fn a_default_recorder_only_exposes_shared_checks() { let recorder = RefusalRecorder::new("breg").unwrap(); let mut out = Exposition::new(); recorder.counter().write(&mut out).unwrap(); let text = out.finish(); + assert!(text.contains("breg_request_refusals_total{check=\"scope\"} 0")); + assert!(!text.contains("check=\"membership\"")); + assert_eq!(text.lines().filter(|l| l.starts_with("breg_")).count(), 45); + } + + #[test] + fn an_unregistered_check_reports_a_wiring_error_once_per_window() { + let recorder = RefusalRecorder::new("evidence").unwrap(); + let now = Instant::now(); + let output = captured(|| { + for time in [now, now, now + REFUSAL_LOG_WINDOW] { + assert!(recorder.record_at(FailedCheck::Membership, time).is_none()); + } + }); + assert_eq!( + output + .matches("a refusal was rejected by its closed label space") + .count(), + 2 + ); + assert_eq!(recorder.counter().get(&["membership"]), None); + } + + #[test] + fn a_recorder_with_product_checks_exposes_them_at_zero() { + let recorder = + RefusalRecorder::with_additional_checks("breg", &[FailedCheck::Membership]).unwrap(); + let mut out = Exposition::new(); + recorder.counter().write(&mut out).unwrap(); + let text = out.finish(); assert!(text.contains("# TYPE breg_request_refusals_total counter")); for check in FailedCheck::ALL { let line = format!( @@ -852,7 +899,8 @@ mod recorder_tests { #[test] fn every_member_is_counted_and_logged_under_its_own_label() { - let recorder = RefusalRecorder::new("breg").unwrap(); + let recorder = + RefusalRecorder::with_additional_checks("breg", &[FailedCheck::Membership]).unwrap(); for check in FailedCheck::ALL { let label = check.as_str(); let output = captured(|| { diff --git a/crates/registry-render/src/server.rs b/crates/registry-render/src/server.rs index 69282dafe8..6d7100ae22 100644 --- a/crates/registry-render/src/server.rs +++ b/crates/registry-render/src/server.rs @@ -3782,7 +3782,7 @@ pub(crate) mod tests { assert!(text.contains( "# HELP render_request_refusals_total Requests refused, by the check that failed.\n# TYPE render_request_refusals_total counter\n" )); - for check in registry_platform_authcommon::FailedCheck::ALL { + for check in FailedCheck::shared() { assert!( text.contains(&format!( "render_request_refusals_total{{check=\"{}\"}} 0", diff --git a/crates/registry-scheduling/src/metrics.rs b/crates/registry-scheduling/src/metrics.rs index 0a68a5758a..3caa5d4a06 100644 --- a/crates/registry-scheduling/src/metrics.rs +++ b/crates/registry-scheduling/src/metrics.rs @@ -461,7 +461,7 @@ mod tests { let text = metrics.render(&Sampled::default()); assert!(text.contains("# TYPE scheduling_request_refusals_total counter")); assert!(text.contains("scheduling_request_refusals_total{check=\"scope\"} 1")); - for check in FailedCheck::ALL { + for check in FailedCheck::shared() { assert!( text.contains(&format!( "scheduling_request_refusals_total{{check=\"{}\"}}", diff --git a/docs/site/src/content/docs/security/evidence.mdx b/docs/site/src/content/docs/security/evidence.mdx index f7cb680aeb..32f996dfa1 100644 --- a/docs/site/src/content/docs/security/evidence.mdx +++ b/docs/site/src/content/docs/security/evidence.mdx @@ -71,7 +71,7 @@ authorisation. Watch for them in operational logs and metrics instead. Evidence counts every refused request by the check that refused it, in `evidence_request_refusals_total{check}` on the private metrics listener. The `check` label is a -closed set of 46 names such as `credential-missing`, `token-signature`, `scope`, `access-profile`, +closed set of 45 names such as `credential-missing`, `token-signature`, `scope`, `access-profile`, `purpose`, `revision-pin` and `rate-limit`, every one published at zero, and no caller value becomes a label. An issuer key set that cannot be reached answers `503`, and counts under `key-source-unavailable`. Each refusal also writes one `request refused` log line with diff --git a/products/evidence/OPERATOR-CONTRACT.md b/products/evidence/OPERATOR-CONTRACT.md index 3be532f3ef..ed704378fc 100644 --- a/products/evidence/OPERATOR-CONTRACT.md +++ b/products/evidence/OPERATOR-CONTRACT.md @@ -1076,7 +1076,7 @@ series and one refusal counter are published: | `evidence_http_request_duration_seconds` | histogram | Duration of those requests | | `evidence_request_refusals_total{check}` | counter | Requests refused with `401`, `403` or `429`, by the check that refused them | -The refusal counter has one label, `check`. Its values are the closed set of 46 +The refusal counter has one label, `check`. Its values are the closed set of 45 failed-check names (for example `credential-missing`, `token-signature`, `scope`, `access-profile`, `purpose`, `revision-pin` and `rate-limit`), and every value is published at zero from startup. No caller value becomes a label. Each refusal From 0a1e2c56cb9ae0c3bb4c21457b3ff6c9a366a464 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:19:34 +0000 Subject: [PATCH 28/96] test(breg): cover subject metadata for Proposal readers Signed-off-by: Jeremi Joslin --- .../registry-breg/src/api/tests/immediate_action_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/registry-breg/src/api/tests/immediate_action_tests.rs b/crates/registry-breg/src/api/tests/immediate_action_tests.rs index 16134b50bd..e48a5d814a 100644 --- a/crates/registry-breg/src/api/tests/immediate_action_tests.rs +++ b/crates/registry-breg/src/api/tests/immediate_action_tests.rs @@ -1636,13 +1636,17 @@ async fn proposal_metadata_serves_party_entries_writable_inputs_and_reader_effec ); let action = &reader["actions"][0]; assert_eq!(action["routes"], json!({})); + assert_eq!(action["subject"], json!({"input":"holder"})); assert_eq!( action["resultEffects"], json!([{"effect":"issued","recordType":"licence","operation":"create"}]), "{action}" ); assert_eq!(action["writableInputs"], json!([])); - BRegMetadata::from_slice(&serde_json::to_vec(&reader).unwrap()).unwrap(); + let metadata = BRegMetadata::from_slice(&serde_json::to_vec(&reader).unwrap()).unwrap(); + assert_eq!(metadata.actions()[0].inputs().len(), 1); + assert_eq!(metadata.actions()[0].inputs()[0].identifier(), "holder"); + assert_eq!(metadata.actions()[0].subject_input(), Some("holder")); } async fn response_json(response: Response) -> Value { From 25f0b9e0b43b42c0203bb0e84912ab36667724b8 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:19:40 +0000 Subject: [PATCH 29/96] fix(breg): restore rehearsal of predecessor reference declarations Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/access.rs | 6 +- crates/registry-breg/src/compiler.rs | 33 +++++- crates/registry-breg/src/package.rs | 18 ++- .../package/SHA256SUMS | 15 +++ .../package/database/ddl.sql | 44 ++++++++ .../package/database/migration-plan.json | 1 + .../package/effective-model.json | 1 + .../package/inventories/access.json | 1 + .../package/inventories/events.json | 1 + .../package/inventories/physical-names.json | 1 + .../package/inventories/queries.json | 1 + .../package/inventories/routes.json | 1 + .../package/metadata/registry.json | 1 + .../package/openapi/openapi.json | 1 + .../package/package.json | 1 + .../package/schemas/category.schema.json | 1 + .../package/schemas/entry.schema.json | 1 + .../package/source/registry.yaml | 57 ++++++++++ .../package/tests/journeys.yaml | 14 +++ .../tests/schema_fingerprint_rehearsal.rs | 105 +++++++++++++++++- 20 files changed, 285 insertions(+), 19 deletions(-) create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/SHA256SUMS create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/ddl.sql create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/migration-plan.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/effective-model.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/access.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/events.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/physical-names.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/queries.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/routes.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/metadata/registry.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/openapi/openapi.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/package.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/category.schema.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/entry.schema.json create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/source/registry.yaml create mode 100644 crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/tests/journeys.yaml diff --git a/crates/registry-breg/src/access.rs b/crates/registry-breg/src/access.rs index d090730762..34635c893d 100644 --- a/crates/registry-breg/src/access.rs +++ b/crates/registry-breg/src/access.rs @@ -113,9 +113,11 @@ pub(crate) fn validate_access_requirements( /// profile can read. Without a `get` or `reference` grant on the target /// Record type every such write would be refused at run time, so the grant /// is required here. A `reference` grant serves nothing else, so one that no -/// write of its profile uses is refused too. +/// write of its profile uses is refused too. Predecessor rehearsal permits a +/// missing grant while reconstructing a schema under the archived authority. pub(crate) fn validate_reference_targets( entities: &BTreeMap, + require_target_grants: bool, errors: &mut Vec, ) { let mut named = BTreeSet::new(); @@ -148,7 +150,7 @@ pub(crate) fn validate_reference_targets( && (candidate.operations.contains(&Operation::Get) || candidate.operations.contains(&Operation::Reference)) }); - if !readable { + if require_target_grants && !readable { errors.push(Diagnostic::error( "breg.access.reference-target-ungranted", format!( diff --git a/crates/registry-breg/src/compiler.rs b/crates/registry-breg/src/compiler.rs index a84f6b52fc..973668e52b 100644 --- a/crates/registry-breg/src/compiler.rs +++ b/crates/registry-breg/src/compiler.rs @@ -244,6 +244,33 @@ pub fn compile_project_with_assets( modules: &[RegistryModule], assets: &[ModuleAssetSource], profile: CompileProfile, +) -> Result { + compile_with_reference_target_requirement(project, modules, assets, profile, true) +} + +/// Reconstruct the schema of a verified predecessor for migration rehearsal. +/// A v0.51.0 package can declare writable references without target grants. +#[cfg(feature = "tooling")] +pub(crate) fn compile_verified_predecessor_for_rehearsal( + project: &RegistryProject, + modules: &[RegistryModule], + assets: &[ModuleAssetSource], +) -> Result { + compile_with_reference_target_requirement( + project, + modules, + assets, + CompileProfile::Production, + false, + ) +} + +fn compile_with_reference_target_requirement( + project: &RegistryProject, + modules: &[RegistryModule], + assets: &[ModuleAssetSource], + profile: CompileProfile, + require_reference_target_grants: bool, ) -> Result { let mut diagnostics = Vec::new(); let mut findings = Vec::new(); @@ -339,7 +366,11 @@ pub fn compile_project_with_assets( &mut diagnostics, ); crate::access::validate_access_requirements(&sources, &mut diagnostics); - crate::access::validate_reference_targets(&sources, &mut diagnostics); + crate::access::validate_reference_targets( + &sources, + require_reference_target_grants, + &mut diagnostics, + ); crate::membership::validate(project, &action_sources, &sources, &mut diagnostics); crate::proposal_subject::validate_field_writes( project, diff --git a/crates/registry-breg/src/package.rs b/crates/registry-breg/src/package.rs index 232c9a9a16..b60edf7e5f 100644 --- a/crates/registry-breg/src/package.rs +++ b/crates/registry-breg/src/package.rs @@ -5010,8 +5010,12 @@ fn project_rehearsal_baseline( let (sources, assets) = capture_compiler_inputs(manifest, loaded, PackageSourceMode::Predecessor)?; if !sources.has_historical_membership() { - return compile_captured_package_sources(manifest, &sources, &assets) - .map(|(registry, _)| registry); + return crate::compiler::compile_verified_predecessor_for_rehearsal( + &sources.project, + &sources.modules, + &assets, + ) + .map_err(|_| PackageError::Derivation); } validate_predecessor_module_locks(&sources, &assets)?; @@ -5433,21 +5437,13 @@ fn compile_package_sources( mode: PackageSourceMode, ) -> Result<(CompiledRegistry, bool)> { let (sources, assets) = capture_compiler_inputs(manifest, loaded, mode)?; - compile_captured_package_sources(manifest, &sources, &assets) -} - -fn compile_captured_package_sources( - manifest: &PackageManifest, - sources: &ParsedPackageSources, - assets: &[ModuleAssetSource], -) -> Result<(CompiledRegistry, bool)> { if sources.has_historical_membership() { return Err(PackageError::Derivation); } let compiled = compile_project_with_assets( &sources.project, &sources.modules, - assets, + &assets, CompileProfile::Production, ) .map_err(|_| PackageError::Derivation)?; diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/SHA256SUMS b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/SHA256SUMS new file mode 100644 index 0000000000..8048190472 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/SHA256SUMS @@ -0,0 +1,15 @@ +231f9b5bf3fce34d03b94f4c7469d04e634864a57f85f2b22ff41ff111fe98c2 database/ddl.sql +1872670a4b4f6a2761877597f1e677715451ec449afc9159356f5c0e744de198 database/migration-plan.json +dcdf1f9af83cef41567f887808163c04a85e1bc76e2622433ef4d1c31802efeb effective-model.json +9e9e0afc5fbbb8b65552729c9e74e0cfd37087b0ebb26f82a5f434dbfa0fc9a9 inventories/access.json +7263162aa981e58eb0b8fd4ba058a1b17ff622c1e8784820b8ec1f407e9bd384 inventories/events.json +0c555a61a985021bdcdedfdef81156079962659de269c782263af19e8279f334 inventories/physical-names.json +ede4e9f3f991500b3e38fa652047cbdf3eabcc5168373f65acb8f1770c1c262b inventories/queries.json +e17e0adccd7e52b3d6579afc74483f5159cd320ddbc0c484c70dacf34239c5a2 inventories/routes.json +64ddb25ba9ea8800af3b108765b900ac54369b60da6158269c6529b76bce2ca3 metadata/registry.json +41eef0f04f9ba4606aba7dcb71036be68a5e1773a341a3dd5623814703084de5 openapi/openapi.json +72eaea44c13c0d8dbcbf28a5afcc955411fc12d8aa1a3c8abf99d8a466950eae package.json +a6542b2f94ec89880a609577351ca881466e06874cef4a985c8e17e1f6ac6b76 schemas/category.schema.json +cbdf09590e36cff2afecc0e3d536ed33779a4657ba624ec44d37ecae3c1a8619 schemas/entry.schema.json +e9e13030735f24824b4eb2be56c394692afc91956090aceb2e655f69c84d0eb8 source/registry.yaml +253493af5c5fd85d65bc3fa645ba4f0b0f56c4b154c7a77525b677e0213d4f5b tests/journeys.yaml diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/ddl.sql b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/ddl.sql new file mode 100644 index 0000000000..7aa2de6fed --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/ddl.sql @@ -0,0 +1,44 @@ +CREATE SCHEMA IF NOT EXISTS registry_data; +CREATE SCHEMA IF NOT EXISTS registry_source; +CREATE SCHEMA IF NOT EXISTS registry_derived; +CREATE SCHEMA IF NOT EXISTS registry_context; +CREATE OR REPLACE FUNCTION registry_context.evaluation_date() + RETURNS date + LANGUAGE sql + STABLE + SECURITY INVOKER + AS $breg_function$ + SELECT NULLIF(current_setting('registry.evaluation_date', true), '')::date + $breg_function$; +CREATE TABLE registry_data."breg_e_category_284c16a2a34063e5" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), "breg_f_category_name_b74daabde89a5552" varchar(64) COLLATE pg_catalog.pg_c_utf8); +CREATE TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), "breg_f_entry_category_0a2a03f0519a4bb7" uuid, "breg_f_entry_name_b223a4d2b68b84ee" varchar(64) COLLATE pg_catalog.pg_c_utf8); +ALTER TABLE registry_data."breg_e_category_284c16a2a34063e5" ADD CONSTRAINT "breg_rk_category_e09350e5c007cb8e" UNIQUE (record_id, record_lifecycle); +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" ADD COLUMN record_reference_lifecycle text COLLATE pg_catalog.pg_c_utf8 + GENERATED ALWAYS AS (CASE WHEN record_lifecycle = 'active' THEN 'active'::text ELSE NULL::text END) STORED; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" ADD CONSTRAINT "breg_r_entry_category_5aba7f6cb64640e7" FOREIGN KEY ("breg_f_entry_category_0a2a03f0519a4bb7") REFERENCES registry_data."breg_e_category_284c16a2a34063e5" (record_id) ON DELETE RESTRICT; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" NO FORCE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_category_284c16a2a34063e5" NO FORCE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" ADD CONSTRAINT "breg_ar_entry_category_7b190379404e320b" FOREIGN KEY ("breg_f_entry_category_0a2a03f0519a4bb7", record_reference_lifecycle) REFERENCES registry_data."breg_e_category_284c16a2a34063e5" (record_id, record_lifecycle) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" FORCE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_category_284c16a2a34063e5" FORCE ROW LEVEL SECURITY; +CREATE INDEX "breg_ri_entry_category_ff9998a3c15186b6" ON registry_data."breg_e_entry_c691cfb82ab6e25e" ("breg_f_entry_category_0a2a03f0519a4bb7"); +ALTER TABLE registry_data."breg_e_category_284c16a2a34063e5" ENABLE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_category_284c16a2a34063e5" FORCE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" ENABLE ROW LEVEL SECURITY; +ALTER TABLE registry_data."breg_e_entry_c691cfb82ab6e25e" FORCE ROW LEVEL SECURITY; +CREATE POLICY "registry_rls_insert_c20605ed93691b2b174e27bc" ON registry_data."breg_e_entry_c691cfb82ab6e25e" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active'); +COMMENT ON POLICY "registry_rls_insert_c20605ed93691b2b174e27bc" ON registry_data."breg_e_entry_c691cfb82ab6e25e" IS 'breg/policy/v1/aac8da39bc88f49c906e0a58432a7340b49909bce3d0a0caab365c86f4847071'; +CREATE POLICY "registry_create_returning_rls_93972995e60731bc7464c338" ON registry_data."breg_e_entry_c691cfb82ab6e25e" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active' AND 'entry' = NULLIF(current_setting('registry.created_entity_id', true), '') AND record_id = NULLIF(current_setting('registry.created_record_id', true), '')::uuid); +COMMENT ON POLICY "registry_create_returning_rls_93972995e60731bc7464c338" ON registry_data."breg_e_entry_c691cfb82ab6e25e" IS 'breg/policy/v1/a7736c35bb0a78bc4f0a557b10ee5d4199921da7e15134436d10f2c4c0ea78d3'; +CREATE POLICY "registry_rls_select_a949aa044b11815c56813b65" ON registry_data."breg_e_entry_c691cfb82ab6e25e" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'reader' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active')); +COMMENT ON POLICY "registry_rls_select_a949aa044b11815c56813b65" ON registry_data."breg_e_entry_c691cfb82ab6e25e" IS 'breg/policy/v1/db3a8229a6ca7c86cba13bd0889ac61c2bb486fd1fcb5bc88dfce541bf639627'; +CREATE VIEW registry_source."category" + WITH (security_invoker=true) + AS SELECT record_id AS "id", "breg_f_category_name_b74daabde89a5552" AS "name" + FROM registry_data."breg_e_category_284c16a2a34063e5" + WHERE record_lifecycle = 'active'; +CREATE VIEW registry_source."entry" + WITH (security_invoker=true) + AS SELECT record_id AS "id", "breg_f_entry_name_b223a4d2b68b84ee" AS "name", "breg_f_entry_category_0a2a03f0519a4bb7" AS "category" + FROM registry_data."breg_e_entry_c691cfb82ab6e25e" + WHERE record_lifecycle = 'active'; diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/migration-plan.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/migration-plan.json new file mode 100644 index 0000000000..42b657adae --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/database/migration-plan.json @@ -0,0 +1 @@ +{"statements":[{"id":"schema.registry_data","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_data"},{"id":"schema.registry_source","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_source"},{"id":"schema.registry_derived","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_derived"},{"id":"schema.registry_context","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_context"},{"id":"function.registry_context.evaluation_date","kind":"function","sql":"CREATE OR REPLACE FUNCTION registry_context.evaluation_date()\n RETURNS date\n LANGUAGE sql\n STABLE\n SECURITY INVOKER\n AS $breg_function$\n SELECT NULLIF(current_setting('registry.evaluation_date', true), '')::date\n $breg_function$"},{"id":"entity.category.table","kind":"table","sql":"CREATE TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_category_name_b74daabde89a5552\" varchar(64) COLLATE pg_catalog.pg_c_utf8)"},{"id":"entity.entry.table","kind":"table","sql":"CREATE TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_entry_category_0a2a03f0519a4bb7\" uuid, \"breg_f_entry_name_b223a4d2b68b84ee\" varchar(64) COLLATE pg_catalog.pg_c_utf8)"},{"id":"entity.category.reference-lifecycle.key","kind":"constraint","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" ADD CONSTRAINT \"breg_rk_category_e09350e5c007cb8e\" UNIQUE (record_id, record_lifecycle)"},{"id":"entity.entry.reference-lifecycle.column","kind":"column","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD COLUMN record_reference_lifecycle text COLLATE pg_catalog.pg_c_utf8\n GENERATED ALWAYS AS (CASE WHEN record_lifecycle = 'active' THEN 'active'::text ELSE NULL::text END) STORED"},{"id":"entity.entry.field.category.reference","kind":"reference","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD CONSTRAINT \"breg_r_entry_category_5aba7f6cb64640e7\" FOREIGN KEY (\"breg_f_entry_category_0a2a03f0519a4bb7\") REFERENCES registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id) ON DELETE RESTRICT"},{"id":"entity.entry.field.category.active-reference","kind":"reference","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD CONSTRAINT \"breg_ar_entry_category_7b190379404e320b\" FOREIGN KEY (\"breg_f_entry_category_0a2a03f0519a4bb7\", record_reference_lifecycle) REFERENCES registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id, record_lifecycle) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT;\nALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.index.reference:category","kind":"index","sql":"CREATE INDEX \"breg_ri_entry_category_ff9998a3c15186b6\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" (\"breg_f_entry_category_0a2a03f0519a4bb7\")"},{"id":"entity.category.rls.enable","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" ENABLE ROW LEVEL SECURITY"},{"id":"entity.category.rls.force","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.rls.enable","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ENABLE ROW LEVEL SECURITY"},{"id":"entity.entry.rls.force","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.policy.registry_rls_insert_c20605ed93691b2b174e27bc","kind":"policy","sql":"CREATE POLICY \"registry_rls_insert_c20605ed93691b2b174e27bc\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_insert_c20605ed93691b2b174e27bc\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/aac8da39bc88f49c906e0a58432a7340b49909bce3d0a0caab365c86f4847071'"},{"id":"entity.entry.policy.registry_create_returning_rls_93972995e60731bc7464c338","kind":"policy","sql":"CREATE POLICY \"registry_create_returning_rls_93972995e60731bc7464c338\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active' AND 'entry' = NULLIF(current_setting('registry.created_entity_id', true), '') AND record_id = NULLIF(current_setting('registry.created_record_id', true), '')::uuid);\nCOMMENT ON POLICY \"registry_create_returning_rls_93972995e60731bc7464c338\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/a7736c35bb0a78bc4f0a557b10ee5d4199921da7e15134436d10f2c4c0ea78d3'"},{"id":"entity.entry.policy.registry_rls_select_a949aa044b11815c56813b65","kind":"policy","sql":"CREATE POLICY \"registry_rls_select_a949aa044b11815c56813b65\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'reader' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_a949aa044b11815c56813b65\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/db3a8229a6ca7c86cba13bd0889ac61c2bb486fd1fcb5bc88dfce541bf639627'"},{"id":"entity.category.source-view","kind":"view","sql":"CREATE VIEW registry_source.\"category\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_category_name_b74daabde89a5552\" AS \"name\"\n FROM registry_data.\"breg_e_category_284c16a2a34063e5\"\n WHERE record_lifecycle = 'active'"},{"id":"entity.entry.source-view","kind":"view","sql":"CREATE VIEW registry_source.\"entry\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_entry_name_b223a4d2b68b84ee\" AS \"name\", \"breg_f_entry_category_0a2a03f0519a4bb7\" AS \"category\"\n FROM registry_data.\"breg_e_entry_c691cfb82ab6e25e\"\n WHERE record_lifecycle = 'active'"}]} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/effective-model.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/effective-model.json new file mode 100644 index 0000000000..2a86fc7810 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/effective-model.json @@ -0,0 +1 @@ +{"accessProfiles":[{"display":{},"id":"editor"},{"display":{},"id":"reader"}],"datasets":[{"display":{},"id":"records"}],"defaultLanguage":"en","eventDeliveryInventory":{"deliveries":[]},"metadataInventory":{"recordTypes":[{"entries":[{"accessProfile":"editor","operation":"create","readableFields":[],"responseRecordType":"entry","routeId":"records.entry.create"},{"accessProfile":"reader","operation":"list","readableFields":["name"],"responseRecordType":"entry","routeId":"records.entry.list"}],"id":"entry","route":"entries","schemaPath":"/v1/schemas/entry"}],"registryId":"reference-rehearsal","version":"1"},"moduleClosure":[],"moduleOrder":[],"physicalNames":{"entities":{"category":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_category_e09350e5c007cb8e"},"fields":{"name":"breg_f_category_name_b74daabde89a5552"},"indexes":{},"policies":{},"table":"breg_e_category_284c16a2a34063e5"},"entry":{"constraints":{"active-reference:category":"breg_ar_entry_category_7b190379404e320b","reference:category":"breg_r_entry_category_5aba7f6cb64640e7"},"fields":{"category":"breg_f_entry_category_0a2a03f0519a4bb7","name":"breg_f_entry_name_b223a4d2b68b84ee"},"indexes":{"reference:category":"breg_ri_entry_category_ff9998a3c15186b6"},"policies":{"editor":"breg_p_entry_editor_5d13998f2140ec0a","reader":"breg_p_entry_reader_9153097a6905bab0"},"table":"breg_e_entry_c691cfb82ab6e25e"}}},"queryInventory":{"operations":[{"allowCount":false,"filterFields":[],"id":"records.entry.reader.list","kind":"list","maxPageSize":100,"processingFields":["name"],"profileId":"reader","projectionFields":["name"],"recordType":"entry","routeId":"records.entry.list","sortFields":[],"stableTieBreaker":"record_id"}]},"recordTypes":{"category":{"accessProfiles":{},"apiName":"Category","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:971b32921711e92e732d820de6b8c350b4a156ab221e03cda35dacf416c2233b","derivedFields":{},"derivedRelations":{},"display":{},"fields":{"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"name","physicalName":"breg_f_category_name_b74daabde89a5552","relationship":null,"required":false}},"hooks":{},"id":"category","indexes":{},"lookups":{},"mutationMode":"create-only","physicalTable":"breg_e_category_284c16a2a34063e5","primaryDataset":"records","readPaths":{},"route":"categories","sourceRelation":{"recordType":"category","sqlName":"category","storedFields":["name"]},"storedFields":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"name","physicalName":"breg_f_category_name_b74daabde89a5552","required":false,"sqlName":"name"}],"tombstone":false},"entry":{"accessProfiles":{"editor":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"editor","operations":["create"],"principalClaim":"principal","readableFields":[],"requiredPurposes":[],"requiredScopes":["records:write"],"revisionAccess":false,"rowBoundaries":[],"sortableFields":[],"writableFields":["category","name"]},"reader":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"reader","operations":["list"],"principalClaim":"principal","readableFields":["name"],"requiredPurposes":[],"requiredScopes":["records:read"],"revisionAccess":false,"rowBoundaries":[],"sortableFields":[],"writableFields":[]}},"apiName":"Entry","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:782116b67d9710b99d2c120618f7cde3cf9320c8c605a62ab2812c0c92d0b2d1","derivedFields":{},"derivedRelations":{},"display":{},"fields":{"category":{"classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"category","type":"reference"},"id":"category","physicalName":"breg_f_entry_category_0a2a03f0519a4bb7","relationship":null,"required":false},"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"name","physicalName":"breg_f_entry_name_b223a4d2b68b84ee","relationship":null,"required":false}},"hooks":{},"id":"entry","indexes":{"reference:category":["category"]},"lookups":{},"mutationMode":"create-only","physicalTable":"breg_e_entry_c691cfb82ab6e25e","primaryDataset":"records","readPaths":{},"relationships":{"category":{"cardinality":"optional-one","fieldId":"category","inverse":false,"inverseName":null,"name":"category","readPath":null,"sourceRecordType":"entry","targetRecordType":"category"}},"route":"entries","sourceRelation":{"recordType":"entry","sqlName":"entry","storedFields":["name","category"]},"storedFields":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"name","physicalName":"breg_f_entry_name_b223a4d2b68b84ee","required":false,"sqlName":"name"},{"apiName":"category","classification":"internal","fieldType":{"onDelete":"restrict","target":"category","type":"reference"},"id":"category","physicalName":"breg_f_entry_category_0a2a03f0519a4bb7","required":false,"sqlName":"category"}],"tombstone":false}},"registryId":"reference-rehearsal","version":"1"} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/access.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/access.json new file mode 100644 index 0000000000..d2393f08a7 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/access.json @@ -0,0 +1 @@ +{"entries":[{"defaultProfileId":"editor","operation":"create","profileIds":["editor"],"recordType":"entry","routeId":"records.entry.create"},{"defaultProfileId":"reader","operation":"list","profileIds":["reader"],"recordType":"entry","routeId":"records.entry.list"}]} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/events.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/events.json new file mode 100644 index 0000000000..f2eb5d89c8 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/events.json @@ -0,0 +1 @@ +{"deliveries":[]} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/physical-names.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/physical-names.json new file mode 100644 index 0000000000..bc88f8e8f5 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/physical-names.json @@ -0,0 +1 @@ +{"entities":{"category":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_category_e09350e5c007cb8e"},"fields":{"name":"breg_f_category_name_b74daabde89a5552"},"indexes":{},"policies":{},"table":"breg_e_category_284c16a2a34063e5"},"entry":{"constraints":{"active-reference:category":"breg_ar_entry_category_7b190379404e320b","reference:category":"breg_r_entry_category_5aba7f6cb64640e7"},"fields":{"category":"breg_f_entry_category_0a2a03f0519a4bb7","name":"breg_f_entry_name_b223a4d2b68b84ee"},"indexes":{"reference:category":"breg_ri_entry_category_ff9998a3c15186b6"},"policies":{"editor":"breg_p_entry_editor_5d13998f2140ec0a","reader":"breg_p_entry_reader_9153097a6905bab0"},"table":"breg_e_entry_c691cfb82ab6e25e"}}} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/queries.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/queries.json new file mode 100644 index 0000000000..57a8c61f31 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/queries.json @@ -0,0 +1 @@ +{"operations":[{"allowCount":false,"filterFields":[],"id":"records.entry.reader.list","kind":"list","maxPageSize":100,"processingFields":["name"],"profileId":"reader","projectionFields":["name"],"recordType":"entry","routeId":"records.entry.list","sortFields":[],"stableTieBreaker":"record_id"}]} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/routes.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/routes.json new file mode 100644 index 0000000000..6b02f5d87f --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/inventories/routes.json @@ -0,0 +1 @@ +{"routes":[{"accessProfiles":["reader"],"defaultAccessProfile":"reader","id":"records.entry.list","method":"GET","operation":"list","path":"/v1/records/entries","queryKind":"list","recordType":"entry"},{"accessProfiles":["editor"],"defaultAccessProfile":"editor","id":"records.entry.create","method":"POST","operation":"create","path":"/v1/records/entries","recordType":"entry"}]} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/metadata/registry.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/metadata/registry.json new file mode 100644 index 0000000000..d1a7e131a7 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/metadata/registry.json @@ -0,0 +1 @@ +{"recordTypes":[{"entries":[{"accessProfile":"editor","operation":"create","readableFields":[],"responseRecordType":"entry","routeId":"records.entry.create"},{"accessProfile":"reader","operation":"list","readableFields":["name"],"responseRecordType":"entry","routeId":"records.entry.list"}],"id":"entry","route":"entries","schemaPath":"/v1/schemas/entry"}],"registryId":"reference-rehearsal","version":"1"} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/openapi/openapi.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/openapi/openapi.json new file mode 100644 index 0000000000..73b9549504 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/openapi/openapi.json @@ -0,0 +1 @@ +{"components":{"schemas":{"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.rejected","proposal.review-result-mismatch","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"category":{"$id":"urn:breg:record-type:category","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"required":[],"type":"object","x-registry-mutationMode":"create-only"},"entry":{"$id":"urn:breg:record-type:entry","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"category":{"anyOf":[{"format":"uuid","type":"string"},{"type":"null"}]},"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"required":[],"type":"object","x-registry-mutationMode":"create-only"},"entry-create-input":{"$id":"urn:breg:record-type:entry:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"category":{"anyOf":[{"format":"uuid","type":"string"},{"type":"null"}]},"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"required":[],"type":"object","x-registry-mutationMode":"create-only"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"reference-rehearsal","version":"1"},"openapi":"3.1.0","paths":{"/v1/records/entries":{"get":{"operationId":"records.entry.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"records"},"recordTypeId":{"const":"entry"},"registryId":{"const":"reference-rehearsal"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"records"},"recordTypeId":{"const":"entry"},"registryId":{"const":"reference-rehearsal"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"reader","requiredFilters":[],"selectableProperties":["name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"entry","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.entry.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/entry-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"records"},"recordTypeId":{"const":"entry"},"registryId":{"const":"reference-rehearsal"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"records"},"recordTypeId":{"const":"entry"},"registryId":{"const":"reference-rehearsal"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["editor"],"x-registry-operation":"create","x-registry-recordType":"entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"entry","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/package.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/package.json new file mode 100644 index 0000000000..c52bd72969 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/package.json @@ -0,0 +1 @@ +{"apiVersion":"id.registrystack.org/formats/breg/package/v2","kind":"BRegPackage","manifest":{"compiler":{"id":"breg","profile":"production","sourceRevision":"v0.51.0-reference-rehearsal-fixture"},"engineFeatures":["statistical_release_store","caller_scoped_idempotency","record_timer_store"],"files":[{"path":"database/ddl.sql","role":"generated_ddl","sha256":"sha256:231f9b5bf3fce34d03b94f4c7469d04e634864a57f85f2b22ff41ff111fe98c2","size":6777},{"path":"database/migration-plan.json","role":"migration_plan","sha256":"sha256:1872670a4b4f6a2761877597f1e677715451ec449afc9159356f5c0e744de198","size":8353},{"path":"effective-model.json","role":"governed_model","sha256":"sha256:dcdf1f9af83cef41567f887808163c04a85e1bc76e2622433ef4d1c31802efeb","size":5349},{"path":"inventories/access.json","role":"access_inventory","sha256":"sha256:9e9e0afc5fbbb8b65552729c9e74e0cfd37087b0ebb26f82a5f434dbfa0fc9a9","size":267},{"path":"inventories/events.json","role":"event_inventory","sha256":"sha256:7263162aa981e58eb0b8fd4ba058a1b17ff622c1e8784820b8ec1f407e9bd384","size":17},{"path":"inventories/physical-names.json","role":"physical_name_inventory","sha256":"sha256:0c555a61a985021bdcdedfdef81156079962659de269c782263af19e8279f334","size":736},{"path":"inventories/queries.json","role":"query_inventory","sha256":"sha256:ede4e9f3f991500b3e38fa652047cbdf3eabcc5168373f65acb8f1770c1c262b","size":296},{"path":"inventories/routes.json","role":"route_inventory","sha256":"sha256:e17e0adccd7e52b3d6579afc74483f5159cd320ddbc0c484c70dacf34239c5a2","size":380},{"path":"metadata/registry.json","role":"caller_safe_metadata","sha256":"sha256:64ddb25ba9ea8800af3b108765b900ac54369b60da6158269c6529b76bce2ca3","size":406},{"path":"openapi/openapi.json","role":"generated_openapi","sha256":"sha256:41eef0f04f9ba4606aba7dcb71036be68a5e1773a341a3dd5623814703084de5","size":41834},{"path":"schemas/category.schema.json","role":"entity_json_schema","sha256":"sha256:a6542b2f94ec89880a609577351ca881466e06874cef4a985c8e17e1f6ac6b76","size":292},{"path":"schemas/entry.schema.json","role":"entity_json_schema","sha256":"sha256:cbdf09590e36cff2afecc0e3d536ed33779a4657ba624ec44d37ecae3c1a8619","size":362},{"path":"source/registry.yaml","role":"source_project","sha256":"sha256:e9e13030735f24824b4eb2be56c394692afc91956090aceb2e655f69c84d0eb8","size":1633},{"path":"tests/journeys.yaml","role":"fixture_journeys","sha256":"sha256:253493af5c5fd85d65bc3fa645ba4f0b0f56c4b154c7a77525b677e0213d4f5b","size":398}],"migrationPlan":{"statements":[{"id":"schema.registry_data","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_data"},{"id":"schema.registry_source","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_source"},{"id":"schema.registry_derived","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_derived"},{"id":"schema.registry_context","kind":"schema","sql":"CREATE SCHEMA IF NOT EXISTS registry_context"},{"id":"function.registry_context.evaluation_date","kind":"function","sql":"CREATE OR REPLACE FUNCTION registry_context.evaluation_date()\n RETURNS date\n LANGUAGE sql\n STABLE\n SECURITY INVOKER\n AS $breg_function$\n SELECT NULLIF(current_setting('registry.evaluation_date', true), '')::date\n $breg_function$"},{"id":"entity.category.table","kind":"table","sql":"CREATE TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_category_name_b74daabde89a5552\" varchar(64) COLLATE pg_catalog.pg_c_utf8)"},{"id":"entity.entry.table","kind":"table","sql":"CREATE TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" (record_id uuid NOT NULL, record_revision bigint NOT NULL DEFAULT 1 CHECK (record_revision > 0), record_lifecycle text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT 'active' CHECK (record_lifecycle IN ('active', 'tombstoned')), created_at timestamptz NOT NULL DEFAULT transaction_timestamp(), updated_at timestamptz NOT NULL DEFAULT transaction_timestamp(), active_package_revision text COLLATE pg_catalog.pg_c_utf8 NOT NULL DEFAULT NULLIF(current_setting('registry.active_package_revision', true), '') CHECK (active_package_revision <> ''), PRIMARY KEY (record_id), \"breg_f_entry_category_0a2a03f0519a4bb7\" uuid, \"breg_f_entry_name_b223a4d2b68b84ee\" varchar(64) COLLATE pg_catalog.pg_c_utf8)"},{"id":"entity.category.reference-lifecycle.key","kind":"constraint","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" ADD CONSTRAINT \"breg_rk_category_e09350e5c007cb8e\" UNIQUE (record_id, record_lifecycle)"},{"id":"entity.entry.reference-lifecycle.column","kind":"column","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD COLUMN record_reference_lifecycle text COLLATE pg_catalog.pg_c_utf8\n GENERATED ALWAYS AS (CASE WHEN record_lifecycle = 'active' THEN 'active'::text ELSE NULL::text END) STORED"},{"id":"entity.entry.field.category.reference","kind":"reference","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD CONSTRAINT \"breg_r_entry_category_5aba7f6cb64640e7\" FOREIGN KEY (\"breg_f_entry_category_0a2a03f0519a4bb7\") REFERENCES registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id) ON DELETE RESTRICT"},{"id":"entity.entry.field.category.active-reference","kind":"reference","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" NO FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ADD CONSTRAINT \"breg_ar_entry_category_7b190379404e320b\" FOREIGN KEY (\"breg_f_entry_category_0a2a03f0519a4bb7\", record_reference_lifecycle) REFERENCES registry_data.\"breg_e_category_284c16a2a34063e5\" (record_id, record_lifecycle) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE RESTRICT;\nALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FORCE ROW LEVEL SECURITY;\nALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.index.reference:category","kind":"index","sql":"CREATE INDEX \"breg_ri_entry_category_ff9998a3c15186b6\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" (\"breg_f_entry_category_0a2a03f0519a4bb7\")"},{"id":"entity.category.rls.enable","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" ENABLE ROW LEVEL SECURITY"},{"id":"entity.category.rls.force","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_category_284c16a2a34063e5\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.rls.enable","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" ENABLE ROW LEVEL SECURITY"},{"id":"entity.entry.rls.force","kind":"row_security","sql":"ALTER TABLE registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FORCE ROW LEVEL SECURITY"},{"id":"entity.entry.policy.registry_rls_insert_c20605ed93691b2b174e27bc","kind":"policy","sql":"CREATE POLICY \"registry_rls_insert_c20605ed93691b2b174e27bc\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR INSERT WITH CHECK ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active');\nCOMMENT ON POLICY \"registry_rls_insert_c20605ed93691b2b174e27bc\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/aac8da39bc88f49c906e0a58432a7340b49909bce3d0a0caab365c86f4847071'"},{"id":"entity.entry.policy.registry_create_returning_rls_93972995e60731bc7464c338","kind":"policy","sql":"CREATE POLICY \"registry_create_returning_rls_93972995e60731bc7464c338\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'editor' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND record_lifecycle = 'active' AND 'entry' = NULLIF(current_setting('registry.created_entity_id', true), '') AND record_id = NULLIF(current_setting('registry.created_record_id', true), '')::uuid);\nCOMMENT ON POLICY \"registry_create_returning_rls_93972995e60731bc7464c338\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/a7736c35bb0a78bc4f0a557b10ee5d4199921da7e15134436d10f2c4c0ea78d3'"},{"id":"entity.entry.policy.registry_rls_select_a949aa044b11815c56813b65","kind":"policy","sql":"CREATE POLICY \"registry_rls_select_a949aa044b11815c56813b65\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" FOR SELECT USING ((NULLIF(current_setting('registry.access_profile', true), '') = 'reader' AND NULLIF(current_setting('registry.principal', true), '') IS NOT NULL AND jsonb_typeof(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 'array' AND jsonb_array_length(NULLIF(current_setting('registry.row_boundaries', true), '')::jsonb) = 0) AND (record_lifecycle = 'active'));\nCOMMENT ON POLICY \"registry_rls_select_a949aa044b11815c56813b65\" ON registry_data.\"breg_e_entry_c691cfb82ab6e25e\" IS 'breg/policy/v1/db3a8229a6ca7c86cba13bd0889ac61c2bb486fd1fcb5bc88dfce541bf639627'"},{"id":"entity.category.source-view","kind":"view","sql":"CREATE VIEW registry_source.\"category\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_category_name_b74daabde89a5552\" AS \"name\"\n FROM registry_data.\"breg_e_category_284c16a2a34063e5\"\n WHERE record_lifecycle = 'active'"},{"id":"entity.entry.source-view","kind":"view","sql":"CREATE VIEW registry_source.\"entry\"\n WITH (security_invoker=true)\n AS SELECT record_id AS \"id\", \"breg_f_entry_name_b223a4d2b68b84ee\" AS \"name\", \"breg_f_entry_category_0a2a03f0519a4bb7\" AS \"category\"\n FROM registry_data.\"breg_e_entry_c691cfb82ab6e25e\"\n WHERE record_lifecycle = 'active'"}]},"packageId":"reference-rehearsal","schemaFingerprint":"sha256:e412288aa02f5f0aa0acee3e1c10cbcf93429695620b7ff92f6ad853c5bb15ff","sources":{"fixtureJourneys":"tests/journeys.yaml","modules":[],"project":"source/registry.yaml"}}} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/category.schema.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/category.schema.json new file mode 100644 index 0000000000..37855f7d3c --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/category.schema.json @@ -0,0 +1 @@ +{"$id":"urn:breg:record-type:category","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"required":[],"type":"object","x-registry-mutationMode":"create-only"} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/entry.schema.json b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/entry.schema.json new file mode 100644 index 0000000000..3c383183b9 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/schemas/entry.schema.json @@ -0,0 +1 @@ +{"$id":"urn:breg:record-type:entry","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"category":{"anyOf":[{"format":"uuid","type":"string"},{"type":"null"}]},"name":{"anyOf":[{"maxLength":64,"minLength":0,"type":"string"},{"type":"null"}]}},"required":[],"type":"object","x-registry-mutationMode":"create-only"} \ No newline at end of file diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/source/registry.yaml b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/source/registry.yaml new file mode 100644 index 0000000000..6624e83dbd --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/source/registry.yaml @@ -0,0 +1,57 @@ +{ + "apiVersion": "id.registrystack.org/formats/breg/project/v1alpha1", + "kind": "BRegProject", + "project": { + "id": "reference-rehearsal", + "version": "1", + "defaultLanguage": "en", + "canonicalBaseIri": "https://reference.example.test" + }, + "package": {"sourceRevision": "v0.51.0-reference-rehearsal-fixture"}, + "datasets": {"records": {}}, + "recordTypes": { + "category": { + "primaryDataset": "records", + "route": "categories", + "mutationMode": "create-only", + "fields": [ + {"id": "name", "type": "string", "maximumLength": 64, "classification": "internal"} + ] + }, + "entry": { + "primaryDataset": "records", + "route": "entries", + "mutationMode": "create-only", + "fields": [ + {"id": "name", "type": "string", "maximumLength": 64, "classification": "internal"}, + {"id": "category", "type": "reference", "target": "category", "classification": "internal"} + ] + } + }, + "accessProfiles": { + "editor": { + "principalClaim": "principal", + "requiredScopes": ["records:write"], + "permissions": {"records": [ + { + "recordType": "entry", + "operations": ["create"], + "writableFields": ["category", "name"], + "rowBoundaries": "unrestricted" + } + ]} + }, + "reader": { + "principalClaim": "principal", + "requiredScopes": ["records:read"], + "permissions": {"records": [ + { + "recordType": "entry", + "operations": ["list"], + "readableFields": ["name"], + "rowBoundaries": "unrestricted" + } + ]} + } + } +} diff --git a/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/tests/journeys.yaml b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/tests/journeys.yaml new file mode 100644 index 0000000000..2200486f35 --- /dev/null +++ b/crates/registry-breg/tests/fixtures/v0.51.0-reference-predecessor/package/tests/journeys.yaml @@ -0,0 +1,14 @@ +apiVersion: id.registrystack.org/formats/breg/journeys/v1 +kind: BRegJourneys +journeys: + - id: empty-entries + steps: + - id: list-entries + actor: reader + recordType: entry + accessProfile: reader + claims: + principal: synthetic-reader + scopes: [records:read] + request: {type: list} + expect: {outcome: success, status: 200, count: 0} diff --git a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs index f01436c06e..9b83350408 100644 --- a/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs +++ b/crates/registry-breg/tests/schema_fingerprint_rehearsal.rs @@ -8,14 +8,17 @@ mod postgres_harness; use postgres_harness::TestDatabase; use registry_breg::compiler::{compile_project, CompileProfile}; -use registry_breg::contract::parse_project_json; +use registry_breg::contract::{parse_project_json, parse_project_yaml}; +use registry_breg::diagnostics::DiagnosticSeverity; use registry_breg::package::{ - prepare_package, PackageBuildRequest, PackageError, PackageMigrationPlanInput, - PackageSourceFile, PreparedPackage, + load_package, load_predecessor_rehearsal_baseline, prepare_package, PackageBuildRequest, + PackageError, PackageLoadContext, PackageMigrationPlanInput, PackageSourceFile, + PreparedPackage, }; use registry_breg::postgres::{ - install_compiled_schema, managed_schema_fingerprint, verify_catalog_identity_for_catalog, - ExpectedManagedCatalog, ExpectedRegistryIdentity, PostgresKernelError, + install_compiled_schema, managed_schema_fingerprint, rehearse_successor_migration, + verify_catalog_identity_for_catalog, ExpectedManagedCatalog, ExpectedRegistryIdentity, + PostgresKernelError, SuccessorMigrationRehearsal, }; use registry_breg::runtime_config::{parse_runtime_config, RuntimeConfig}; use registry_breg::startup::{ @@ -23,6 +26,8 @@ use registry_breg::startup::{ rehearse_schema_fingerprint_with_connection_config_for_test, StartupError, }; use registry_breg::CompiledRegistry; +use serde_json::{json, Value}; +use std::path::Path; const ENVIRONMENT: &str = "production"; const INSTANCE: &str = "rehearsal-instance"; @@ -92,6 +97,96 @@ async fn rehearsal_rolls_back_and_matches_committed_schema_test_preparation() { database.cleanup().await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn successor_rehearses_over_a_v051_writable_reference() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/v0.51.0-reference-predecessor/package"); + let context = PackageLoadContext { + posture: registry_platform_config::Posture::Production, + }; + let prior_source = std::fs::read(root.join("source/registry.yaml")).unwrap(); + let prior_project = parse_project_yaml(&prior_source).expect("archived source parses"); + for profile in [CompileProfile::Authoring, CompileProfile::Production] { + let failure = compile_project(&prior_project, &[], profile) + .expect_err("current authoring requires target authority"); + let errors = failure + .diagnostics() + .iter() + .filter(|diagnostic| diagnostic.severity == DiagnosticSeverity::Error) + .map(|diagnostic| diagnostic.code.as_str()) + .collect::>(); + assert_eq!(errors, ["breg.access.reference-target-ungranted"]); + } + assert_eq!( + load_package(&root, &context).err(), + Some(PackageError::Derivation) + ); + + let (prior, predecessor) = load_predecessor_rehearsal_baseline(&root, &context) + .expect("the verified v0.51.0 package can be reconstructed for rehearsal"); + + let mut successor: Value = serde_json::from_slice(&prior_source).unwrap(); + successor["package"]["sourceRevision"] = json!(SOURCE_REVISION); + successor["accessProfiles"]["editor"]["permissions"]["records"] + .as_array_mut() + .unwrap() + .push(json!({ + "recordType": "category", + "operations": ["reference"], + "rowBoundaries": "unrestricted" + })); + let successor_source = serde_json::to_vec(&successor).unwrap(); + let project = parse_project_json(&successor_source).expect("successor source parses"); + let registry = compile_project(&project, &[], CompileProfile::Production) + .expect("the successor declares explicit target authority"); + let database = TestDatabase::create(1).await; + let fingerprint = rehearse_schema_fingerprint_with_connection_config_for_test( + &runtime_config(&database, ENVIRONMENT, INSTANCE), + ®istry, + &database.migration_config, + ) + .await + .expect("the successor schema measures on the disposable database"); + let candidate = prepare_package(PackageBuildRequest { + from_package_digest: Some(prior.package_digest().to_owned()), + compiler_source_revision: SOURCE_REVISION.to_owned(), + schema_fingerprint: fingerprint, + project: PackageSourceFile { + path: "source/registry.json".to_owned(), + bytes: successor_source, + }, + modules: vec![], + fixture_journeys: PackageSourceFile { + path: "tests/journeys.yaml".to_owned(), + bytes: std::fs::read(root.join("tests/journeys.yaml")).unwrap(), + }, + migration_plan: PackageMigrationPlanInput::SuccessorFromBaseline { + prior_baseline: Box::new(prior.migration_baseline().clone()), + }, + }) + .expect("the current compiler prepares the successor against the verified baseline"); + let outcome = rehearse_successor_migration( + &database.migration_config, + &database.migration_role, + &database.runtime_role, + SuccessorMigrationRehearsal { + predecessor: &predecessor, + predecessor_schema_fingerprint: prior.schema_fingerprint(), + candidate: &candidate, + }, + ) + .await; + assert!(managed_schemas_empty_by_restrict(&database).await); + database.cleanup().await; + outcome.expect("successor rehearsal reaches the candidate's measured fingerprint"); + + let build = tempfile::tempdir().unwrap(); + let package = build.path().join("package"); + candidate.publish_to_directory(&package).unwrap(); + load_package(&package, &context) + .expect("the explicitly authorized successor verifies strictly"); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn fresh_schema_matches_install_over_v051_review_ask_files() { let registry = compiled_registry(SOURCE_REVISION); From 0248050e85b57b651a8185e14b94a5569df1fa31 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:23:17 +0000 Subject: [PATCH 30/96] fix(breg): enforce Proposal subject-field write validation Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/proposal_subject.rs | 140 ++++++++++++------ .../tests/proposal_party_compiler.rs | 45 ++++++ 2 files changed, 143 insertions(+), 42 deletions(-) diff --git a/crates/registry-breg/src/proposal_subject.rs b/crates/registry-breg/src/proposal_subject.rs index cbce0d9b7d..35df9ce4f0 100644 --- a/crates/registry-breg/src/proposal_subject.rs +++ b/crates/registry-breg/src/proposal_subject.rs @@ -7,7 +7,8 @@ use std::collections::{BTreeMap, BTreeSet}; use crate::contract::{ ActionExecutionSource, ActionPlanSource, ActionSource, BoundaryOperator, EntitySource, - FieldTypeSource, MembershipRowBoundarySource, Operation, RegistryProject, RowBoundarySource, + FieldTypeSource, Operation, ProjectAccessProfileSource, ProposalOperation, RegistryProject, + RowBoundarySource, }; use crate::diagnostics::Diagnostic; @@ -16,7 +17,7 @@ fn refuse(location: &str, record_type: &str, field: &str, errors: &mut Vec, + principal_claim: &str, ) -> bool { - (!rows.is_empty() || !memberships.is_empty()) + (!rows.is_empty() || has_memberships) && !rows.iter().any(|row| { row.field == field && row.operator == BoundaryOperator::Equals - && Some(row.claim.as_str()) == principal_claim + && row.claim == principal_claim }) } @@ -95,34 +96,61 @@ fn plan_sets_field(action: &ActionSource, record_type: &str, field: &str) -> boo } } +fn plan_target_grants<'a>( + profile: &'a ProjectAccessProfileSource, + record_type: &'a str, +) -> impl Iterator { + let actions = profile.permissions.actions.iter().filter_map(move |grant| { + let target = grant + .targets + .iter() + .find(|target| target.entity == record_type)?; + Some(( + "actions", + grant.action.as_str(), + target.row_boundaries.as_slice(), + !target.membership_row_boundaries.is_empty(), + )) + }); + // Submit freezes the plan under its own target grant and can enqueue + // automatic application. Draft edits cannot freeze a plan, and recovery + // uses the plan already frozen by Submit. + let proposals = profile + .permissions + .proposals + .iter() + .filter(|grant| grant.operations.contains(&ProposalOperation::Submit)) + .filter_map(move |grant| { + let target = grant + .targets + .iter() + .find(|target| target.record_type == record_type)?; + Some(( + "proposals", + grant.action.as_str(), + target.row_boundaries.as_slice(), + !target.membership_row_boundaries.is_empty(), + )) + }); + actions.chain(proposals) +} + /// Refuse a bounded grant that can set a field a Proposal subject is read -/// from: a direct Create, Batch, Import or Patch of it, or an Action whose -/// plan sets it with no person deciding. Unrestricted grants, grants bounded -/// on the field by their own principal, and reviewed or manually applied -/// Proposal Actions stay admitted. +/// from: a direct Create, Batch, Import or Patch of it, or an Action or +/// Proposal Submit grant whose plan sets it with no person deciding. +/// Unrestricted grants, grants bounded on the field by their own principal, +/// and reviewed or manually applied Proposal Actions stay admitted. pub(crate) fn validate_field_writes( project: &RegistryProject, actions: &BTreeMap, entities: &BTreeMap, errors: &mut Vec, ) { - let principal_claim = |profile: &str| { - project - .access_profiles - .iter() - .find(|candidate| candidate.id == profile) - .map(|candidate| candidate.principal_claim.as_str()) - }; for (record_type, field) in subject_fields(actions) { let Some(entity) = entities.get(&record_type) else { continue; }; for grant in &entity.access_profiles { - let memberships = grant - .membership_boundaries - .iter() - .map(|boundary| boundary.entry()) - .collect::>(); let writes = grant.operations.iter().any(|operation| { matches!( operation, @@ -132,9 +160,9 @@ pub(crate) fn validate_field_writes( if writes && bounded_off_field( &grant.row_boundaries, - &memberships, + !grant.membership_boundaries.is_empty(), &field, - principal_claim(&grant.id), + &grant.principal_claim, ) { refuse( @@ -149,26 +177,18 @@ pub(crate) fn validate_field_writes( } } for profile in &project.access_profiles { - for grant in &profile.permissions.actions { - let Some(target) = grant - .targets - .iter() - .find(|target| target.entity == record_type) - else { - continue; - }; - if bounded_off_field( - &target.row_boundaries, - &target.membership_row_boundaries, - &field, - Some(profile.principal_claim.as_str()), - ) && actions.get(&grant.action).is_some_and(|collected| { - plan_sets_field(&collected.source, &record_type, &field) - }) { + for (surface, action, rows, has_memberships) in + plan_target_grants(profile, &record_type) + { + if bounded_off_field(rows, has_memberships, &field, &profile.principal_claim) + && actions.get(action).is_some_and(|collected| { + plan_sets_field(&collected.source, &record_type, &field) + }) + { refuse( &format!( - "accessProfiles[id={}].permissions.actions[action={}].targets[recordType={record_type}]", - profile.id, grant.action + "accessProfiles[id={}].permissions.{surface}[action={action}].targets[recordType={record_type}]", + profile.id ), &record_type, &field, @@ -179,3 +199,39 @@ pub(crate) fn validate_field_writes( } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn plan_targets_include_action_and_proposal_write_permissions() { + let target = serde_json::json!({"recordType":"entry","rowBoundaries":"unrestricted"}); + let profile = serde_json::from_value(serde_json::json!({ + "id":"editor", "principalClaim":"sub", "requiredScopes":["entry:edit"], + "permissions": { + "actions":[ + {"action":"update-entry", "operations":["invoke"], "targets":[target.clone()]}, + {"action":"propose-change", "operations":["start"], "targets":[target.clone()]} + ], + "proposals":[ + {"action":"propose-change", "operations":["submit"], "targets":[target.clone()]}, + {"action":"previous-change", "operations":["get","list"], "targets":[target.clone()]}, + {"action":"review-draft", "operations":["get","edit"], "targets":[target]} + ] + } + })) + .expect("profile parses"); + + assert_eq!( + plan_target_grants(&profile, "entry") + .map(|(surface, action, ..)| (surface, action)) + .collect::>(), + [ + ("actions", "update-entry"), + ("actions", "propose-change"), + ("proposals", "propose-change"), + ] + ); + } +} diff --git a/crates/registry-breg/tests/proposal_party_compiler.rs b/crates/registry-breg/tests/proposal_party_compiler.rs index 44a20f5b26..76ee94a261 100644 --- a/crates/registry-breg/tests/proposal_party_compiler.rs +++ b/crates/registry-breg/tests/proposal_party_compiler.rs @@ -3,6 +3,7 @@ //! A Proposal grant is bound to a party: the owner who filed it or the //! subject it is about. The Action names where the subject comes from. +use registry_breg::contract::parse_module_json; use registry_breg::model::{CompiledActionExecution, ProposalOperation, ProposalParty}; use registry_breg::{compile_project, parse_project_json, CompileFailure, CompileProfile}; use serde_json::{json, Value}; @@ -423,6 +424,50 @@ fn a_bounded_writer_cannot_choose_who_a_subject_field_names() { .expect("a writer bounded on the subject field by its own principal compiles"); } +#[test] +fn module_writers_can_be_bounded_by_their_own_principal_claim() { + for collection in ["recordTypes", "extendRecordTypes"] { + let rows = json!([{"field":"holder","claim":"module_principal","operator":"equals"}]); + let mut project = field_subject_with_editor(rows.clone()); + project["accessProfiles"] + .as_object_mut() + .unwrap() + .remove("editor"); + project["modules"] = json!({"core":{"version":"1"}}); + + let mut record = if collection == "recordTypes" { + project["recordTypes"] + .as_object_mut() + .unwrap() + .remove("licence") + .unwrap() + } else { + json!({}) + }; + record["accessProfiles"] = json!({"module-editor": { + "principalClaim":"module_principal", "requiredScopes":["licence:edit"], + "actorKind":"human", "operations":["get","patch"], + "readableFields":["holder"], "writableFields":["holder"], "rowBoundaries":rows + }}); + let mut module = json!({ + "apiVersion":"id.registrystack.org/formats/breg/module/v1alpha1", + "kind":"BRegModule", "id":"core", "version":"1" + }); + module[collection] = json!({"licence":record}); + + let project = parse_project_json(&serde_json::to_vec(&project).unwrap()).unwrap(); + let module = parse_module_json(&serde_json::to_vec(&module).unwrap()).unwrap(); + let compiled = compile_project(&project, &[module], CompileProfile::Authoring) + .unwrap_or_else(|failure| { + panic!("a principal-bound module grant in {collection} compiles: {failure:?}") + }); + assert_eq!( + compiled.entities()["licence"].access_profiles["module-editor"].principal_claim, + "module_principal" + ); + } +} + #[test] fn a_bounded_immediate_action_cannot_set_a_subject_field() { let mut project = field_subject_with_editor(json!("unrestricted")); From 27bf73590b1884c76eb78dd0fe271cc1090755f0 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:31:16 +0000 Subject: [PATCH 31/96] fix(metrics): satisfy pinned rustfmt Signed-off-by: Jeremi Joslin --- crates/registry-adapter/src/metrics.rs | 5 ++++- crates/registry-evidence-oid4vci/src/observability.rs | 4 +++- crates/registry-evidence-oid4vp/tests/refusal_recording.rs | 4 +++- crates/registry-evidence/src/observability.rs | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/registry-adapter/src/metrics.rs b/crates/registry-adapter/src/metrics.rs index feb38b56be..cf1ddda37c 100644 --- a/crates/registry-adapter/src/metrics.rs +++ b/crates/registry-adapter/src/metrics.rs @@ -409,7 +409,10 @@ mod tests { .lines() .filter(|line| line.starts_with("adapter_request_refusals_total{check=\"")) .count(); - assert_eq!(declared, registry_platform_authcommon::FailedCheck::shared().count()); + assert_eq!( + declared, + registry_platform_authcommon::FailedCheck::shared().count() + ); } /// The refusal line a scope refusal writes, driven through the recording diff --git a/crates/registry-evidence-oid4vci/src/observability.rs b/crates/registry-evidence-oid4vci/src/observability.rs index b6fca91e13..e4e064d32a 100644 --- a/crates/registry-evidence-oid4vci/src/observability.rs +++ b/crates/registry-evidence-oid4vci/src/observability.rs @@ -685,7 +685,9 @@ mod tests { .filter(|line| line.starts_with("evidence_oid4vci_request_refusals_total{")) .collect(); assert!(series.contains(&"evidence_oid4vci_request_refusals_total{check=\"scope\"} 0")); - assert!(!series.iter().any(|line| line.contains("check=\"membership\""))); + assert!(!series + .iter() + .any(|line| line.contains("check=\"membership\""))); assert_eq!(series.len(), 45); } diff --git a/crates/registry-evidence-oid4vp/tests/refusal_recording.rs b/crates/registry-evidence-oid4vp/tests/refusal_recording.rs index eb253c5978..6a25afc65f 100644 --- a/crates/registry-evidence-oid4vp/tests/refusal_recording.rs +++ b/crates/registry-evidence-oid4vp/tests/refusal_recording.rs @@ -54,7 +54,9 @@ fn count(service: &VerifierService, check: FailedCheck) -> u64 { } fn total(service: &VerifierService) -> u64 { - FailedCheck::shared().map(|check| count(service, check)).sum() + FailedCheck::shared() + .map(|check| count(service, check)) + .sum() } /// What a caller sent that must never reach a log line. diff --git a/crates/registry-evidence/src/observability.rs b/crates/registry-evidence/src/observability.rs index fc53e6727e..0de7196d00 100644 --- a/crates/registry-evidence/src/observability.rs +++ b/crates/registry-evidence/src/observability.rs @@ -954,7 +954,9 @@ mod tests { .filter(|line| line.starts_with("evidence_request_refusals_total{")) .collect(); assert!(series.contains(&"evidence_request_refusals_total{check=\"scope\"} 0")); - assert!(!series.iter().any(|line| line.contains("check=\"membership\""))); + assert!(!series + .iter() + .any(|line| line.contains("check=\"membership\""))); assert_eq!(series.len(), 45); } From 72be8e47ae247b8b4a5cd8489281d1d96d2ece66 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:31:26 +0000 Subject: [PATCH 32/96] test(docs): pin the messaged Proposal lifecycle transition Signed-off-by: Jeremi Joslin --- docs/site/scripts/generate-breg-configuration.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/site/scripts/generate-breg-configuration.test.mjs b/docs/site/scripts/generate-breg-configuration.test.mjs index ddbf48e288..554fcd1444 100644 --- a/docs/site/scripts/generate-breg-configuration.test.mjs +++ b/docs/site/scripts/generate-breg-configuration.test.mjs @@ -41,8 +41,8 @@ test('BReg reference includes module extensions, hook conditions, and runtime de assert.deepEqual(module.get('recordTypes.*.hooks[].phase').values, ['after', 'before']); assert.ok(project.has('accessProfiles.*.permissions.proposals[].targets[].recordType')); assert.deepEqual(project.get('actions.*.execution.proposal.hooks[].transitions[]').values, - ['added', 'answered', 'applied', 'asked', 'cancelled', 'edited', 'rebased', 'rejected', 'retried', - 'review-returned', 'revised', 'started', 'submitted']); + ['added', 'answered', 'applied', 'asked', 'cancelled', 'edited', 'messaged', 'rebased', 'rejected', + 'retried', 'review-returned', 'revised', 'started', 'submitted']); for (const path of ['changed[]', 'beforeEquals.*', 'afterEquals.*']) { assert.ok(module.has(`recordTypes.*.hooks[].when.${path}`), path); } From 3e3f6e86dabb8c90bc0c6ff3c24b8e8f97b07e2a Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:34:31 +0000 Subject: [PATCH 33/96] docs: align refusal label counts with recorder declarations Signed-off-by: Jeremi Joslin --- crates/registry-scheduling/src/metrics.rs | 2 +- docs/site/src/content/docs/operate/adapter.mdx | 4 ++-- docs/site/src/content/docs/operate/coordinator.mdx | 2 +- docs/site/src/content/docs/operate/documents.mdx | 2 +- docs/site/src/content/docs/operate/messaging.mdx | 2 +- docs/site/src/content/docs/operate/scheduling.mdx | 2 +- .../src/content/docs/reference/messaging-configuration.mdx | 2 +- docs/site/src/content/docs/security/casework.mdx | 2 +- docs/site/src/content/docs/security/coordinator.mdx | 2 +- docs/site/src/content/docs/security/documents.mdx | 2 +- docs/site/src/content/docs/security/index.mdx | 2 +- docs/site/src/content/docs/security/messaging.mdx | 2 +- docs/site/src/content/docs/security/render.mdx | 2 +- docs/site/src/content/docs/security/scheduling.mdx | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/registry-scheduling/src/metrics.rs b/crates/registry-scheduling/src/metrics.rs index 3caa5d4a06..2e1475c276 100644 --- a/crates/registry-scheduling/src/metrics.rs +++ b/crates/registry-scheduling/src/metrics.rs @@ -14,7 +14,7 @@ //! and problem details never become labels. //! //! The refusal counter, `scheduling_request_refusals_total`, is labelled by -//! the check a request failed. The check is a closed set of 46 names, never a +//! the check a request failed. The check is a closed set of 45 names, never a //! value a caller sent. //! //! The outbox and hook-delivery series are gauges sampled from the store when diff --git a/docs/site/src/content/docs/operate/adapter.mdx b/docs/site/src/content/docs/operate/adapter.mdx index 7be099317b..13d12f204e 100644 --- a/docs/site/src/content/docs/operate/adapter.mdx +++ b/docs/site/src/content/docs/operate/adapter.mdx @@ -1001,7 +1001,7 @@ Facade series: | --- | --- | --- | --- | | `adapter_http_requests_total` | counter | `route` (route template, or `unmatched`), `method`, `status` (`1xx`, `2xx`, `3xx`, `4xx`, `5xx`, `other`) | Answered facade requests. | | `adapter_upstream_failures_total` | counter | `class` (`upstream`, `upstream.http`, `upstream.timeout`, `upstream.connection`, `upstream.malformed`, `upstream.too-large`, `upstream.redirect`, `breaker.open`, `throttle.rejected`, `credential.rejected`, `egress.refused`) | Calls to the source that failed, by error class. It counts failed exchanges, status polls, bounded-wait polls and recovery checks. | -| `adapter_request_refusals_total` | counter | `check` (the 46 shared failed-check labels, all present at zero, for example `credential-missing`, `token-signature`, `scope`, `operation`, `ownership`, `visibility`) | Facade and payment requests refused, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. | +| `adapter_request_refusals_total` | counter | `check` (the 45 shared failed-check labels, all present at zero, for example `credential-missing`, `token-signature`, `scope`, `operation`, `ownership`, `visibility`) | Facade and payment requests refused, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. | | `adapter_journal_write_failures_total` | counter | none | Audit journal writes that failed, so the exchange answered an internal error. Custody and rendering failures are not counted here. | | `adapter_retention_sweep_failures_total` | counter | `store` (`journal`, `idempotency`, `other`) | Retention sweep batches that failed and were left to the next tick. | @@ -1013,7 +1013,7 @@ Job host series: | `adapter_job_last_successful_pass_age_seconds` | gauge | none | Seconds since a pass in this process settled its page. Absent until the first such pass. | | `adapter_job_pass_failures_total` | counter | `reason` (`page-fault`, `destination-stop`, `refusal-limit`, `store-unreachable`) | Passes that did not settle, and passes that could not reach the store. A pass that finds another process holding the lease is not a failure and is not counted. | | `adapter_job_hook_refusals_total` | counter | `reason` (`not-found`, `method`, `unauthenticated`, `rate-limited`, `unavailable`, `body-timeout`, `body-too-large`, `body-unreadable`) | Hook requests the ingress refused. | -| `adapter_job_request_refusals_total` | counter | `check` (the 46 shared failed-check labels, all present at zero. The hook ingress records `credential-missing`, `credential-malformed`, `shared-secret` and `rate-limit`) | Hook requests refused for a credential or the rate limit, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. Present when the host is built with `job-hook`. | +| `adapter_job_request_refusals_total` | counter | `check` (the 45 shared failed-check labels, all present at zero. The hook ingress records `credential-missing`, `credential-malformed`, `shared-secret` and `rate-limit`) | Hook requests refused for a credential or the rate limit, by the check that failed. Each refusal also writes one `request refused` log line carrying `failed_check` and no caller value, at most five lines per check per minute. Present when the host is built with `job-hook`. | | `adapter_job_gauge_sample_failures_total` | counter | none | Item count reads that failed or timed out. | When the store cannot be read at scrape time, `adapter_job_items` carries no samples and diff --git a/docs/site/src/content/docs/operate/coordinator.mdx b/docs/site/src/content/docs/operate/coordinator.mdx index d75192b251..a078e06c91 100644 --- a/docs/site/src/content/docs/operate/coordinator.mdx +++ b/docs/site/src/content/docs/operate/coordinator.mdx @@ -805,7 +805,7 @@ The metrics are Prometheus text (`text/plain; version=0.0.4`, served with `Cache | `coordinator_runs_finished_total` | counter | `state`: `finished`, `failed`, `cancelled`, `cancelled-after-effect`, `expired` | | `coordinator_step_attempts_total` | counter | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent`, `unavailable` | | `coordinator_authentication_refusals_total` | counter | `reason`: `refused`, `policy`, `unavailable` | -| `coordinator_request_refusals_total` | counter | `check`: the closed set of 46 failed checks, every value published at zero | +| `coordinator_request_refusals_total` | counter | `check`: the closed set of 45 failed checks, every value published at zero | | `coordinator_metrics_sample_failures_total` | counter | `sample`: `dispatch-queue`, `run-holds` | | `coordinator_dispatch_jobs` | gauge | `state`: `pending`, `leased`, `unknown` | | `coordinator_runs_attention` | gauge | `reason`: `definition-refused`, `other` | diff --git a/docs/site/src/content/docs/operate/documents.mdx b/docs/site/src/content/docs/operate/documents.mdx index 1a91d1d898..c6db0ca572 100644 --- a/docs/site/src/content/docs/operate/documents.mdx +++ b/docs/site/src/content/docs/operate/documents.mdx @@ -697,7 +697,7 @@ answers the series below and nothing else. The document listener does not route | `documents_hook_oldest_overdue_age_seconds` | none | Gauge of how many seconds the oldest pending hook delivery is past its due time. Zero when none is overdue | | `documents_worker_last_success_age_seconds` | `worker`: `cleanup` | Gauge of seconds since the cleanup pass last finished without leaving an orphaned object unconfirmed | | `documents_metrics_sample_failures_total` | `sample`: `verification-jobs`, `erasure-jobs`, `hook-deliveries` | Scrapes in which that queue could not be read | -| `documents_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `documents_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | Every state is listed, with a zero when no row is in it. Watch the `dead-lettered` state of each gauge, the work that gave up and needs a person. Replay a verification or erasure job as diff --git a/docs/site/src/content/docs/operate/messaging.mdx b/docs/site/src/content/docs/operate/messaging.mdx index 372e41e911..128c83992a 100644 --- a/docs/site/src/content/docs/operate/messaging.mdx +++ b/docs/site/src/content/docs/operate/messaging.mdx @@ -673,7 +673,7 @@ The series are: | `messaging_provider_attempts_total` | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent` | Provider attempts, by class | | `messaging_provider_callbacks_total` | `outcome`: `unverified`, `unreadable`, `ignored`, `applied`, `unchanged`, `unmatched`, `ambiguous`, `unavailable` | Provider callbacks, by what became of them | | `messaging_limit_refusals_total` | `limit`: `rate`, `daily`, `pacing`, `callback` | Submissions, attempts, and callbacks a limit refused | -| `messaging_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `messaging_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | | `messaging_retention_runs_total` | `outcome`: `erased`, `idle`, `failed` | Retention sweeps this process ran | | `messaging_metrics_sample_failures_total` | `sample`: `dispatch-queue` | Scrapes in which the database read failed, since the process started | | `messaging_dispatch_jobs` | `state`: `pending`, `leased`, `unknown` | Gauge read from the database at each scrape | diff --git a/docs/site/src/content/docs/operate/scheduling.mdx b/docs/site/src/content/docs/operate/scheduling.mdx index df5bcf5dd1..03487f5312 100644 --- a/docs/site/src/content/docs/operate/scheduling.mdx +++ b/docs/site/src/content/docs/operate/scheduling.mdx @@ -481,7 +481,7 @@ the series below and nothing else. The public listener does not route `/metrics` | `scheduling_hook_oldest_pending_age_seconds` | none | Gauge of how many seconds ago the oldest pending hook delivery's event was captured. Zero when none is pending | | `scheduling_worker_last_success_age_seconds` | `worker`: `hold-expiry`, `retention` | Gauge of seconds since the worker last finished a pass | | `scheduling_metrics_sample_failures_total` | `queue`: `outbox`, `hook-deliveries` | Scrapes in which that queue could not be read | -| `scheduling_request_refusals_total` | `check`: the closed set of 46 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | +| `scheduling_request_refusals_total` | `check`: the closed set of 45 failed checks, every value published at zero | Requests refused, by the check that failed. Each refusal also writes one `request refused` log line with `failed_check`, at most five per check per minute, with `suppressed` counting what a window held back. Neither carries a token, claim, client, subject or identifier | Every state is listed, with a zero when no row is in it. Watch `scheduling_outbox_items{state="dead-lettered"}` and diff --git a/docs/site/src/content/docs/reference/messaging-configuration.mdx b/docs/site/src/content/docs/reference/messaging-configuration.mdx index 9fc0049693..ea63e0f0f5 100644 --- a/docs/site/src/content/docs/reference/messaging-configuration.mdx +++ b/docs/site/src/content/docs/reference/messaging-configuration.mdx @@ -149,7 +149,7 @@ The metrics are Prometheus text, and every label is closed: | `messaging_provider_callbacks_total` | counter | `outcome` | | `messaging_provider_attempts_total` | counter | `outcome`: `accepted`, `transient`, `permanent`, `maybe-sent` | | `messaging_limit_refusals_total` | counter | `limit`: `rate`, `daily`, `pacing`, `callback` | -| `messaging_request_refusals_total` | counter | `check`: the closed set of 46 failed checks, every value published at zero | +| `messaging_request_refusals_total` | counter | `check`: the closed set of 45 failed checks, every value published at zero | | `messaging_retention_runs_total` | counter | `outcome`: `erased`, `idle`, `failed` | | `messaging_dispatch_jobs` | gauge | `state`: `pending`, `leased`, `unknown` | diff --git a/docs/site/src/content/docs/security/casework.mdx b/docs/site/src/content/docs/security/casework.mdx index f33b370fea..a2532fcea8 100644 --- a/docs/site/src/content/docs/security/casework.mdx +++ b/docs/site/src/content/docs/security/casework.mdx @@ -223,7 +223,7 @@ grants in [Registry Casework task grants](../../reference/casework-task-grants/) - Casework counts every refused request by the check that refused it, in `casework_request_refusals_total{check}` on the private metrics listener ([metrics](../../operate/casework/#scrape-metrics-and-the-running-version)). - The `check` label is a closed set of 46 names, every one published at zero, and no caller value + The `check` label is a closed set of 45 names, every one published at zero, and no caller value becomes a label. Refusals the caller cannot tell apart are told apart there. A review or administration request refused for its role, its profile's stage eligibility, an diff --git a/docs/site/src/content/docs/security/coordinator.mdx b/docs/site/src/content/docs/security/coordinator.mdx index 85ed3138a5..fc8dd41863 100644 --- a/docs/site/src/content/docs/security/coordinator.mdx +++ b/docs/site/src/content/docs/security/coordinator.mdx @@ -70,7 +70,7 @@ Deployment steps are in [Deploy Registry Coordinator](../../operate/coordinator/ The signed timestamp bounds how long a captured completion can be replayed. - Coordinator counts every refused request by the check that refused it, in `coordinator_request_refusals_total{check}` on the private metrics listener. - The `check` label is a closed set of 46 names, every one published at zero, and no caller value + The `check` label is a closed set of 45 names, every one published at zero, and no caller value becomes a label. The counter covers a refused credential, a policy denial after authentication, a refused signed event delivery or completion callback, an unavailable access-token verifier key source, and a diff --git a/docs/site/src/content/docs/security/documents.mdx b/docs/site/src/content/docs/security/documents.mdx index d2cc74e5b5..9c19416504 100644 --- a/docs/site/src/content/docs/security/documents.mdx +++ b/docs/site/src/content/docs/security/documents.mdx @@ -52,7 +52,7 @@ and the restore drill is in Members it does not know, such as `x5c` or `ext`, are ignored. - The Document Store counts every refused request by the check that refused it, in `documents_request_refusals_total{check}` on the private metrics listener. - The `check` label is a closed set of 46 names such as `credential-missing`, `token-signature`, + The `check` label is a closed set of 45 names such as `credential-missing`, `token-signature`, `scope`, `actor-kind`, `access-profile`, `operation`, `ownership` and `visibility`, every one published at zero, and no caller value becomes a label. The counter covers a missing or refused credential, a token that resolves to no access profile, a diff --git a/docs/site/src/content/docs/security/index.mdx b/docs/site/src/content/docs/security/index.mdx index a6613c326e..e594322b83 100644 --- a/docs/site/src/content/docs/security/index.mdx +++ b/docs/site/src/content/docs/security/index.mdx @@ -222,7 +222,7 @@ Registry Evidence is stricter. It accepts only a declared `uri` key source, and ## Refused requests Services that use the shared refusal recorder count the checks they record in -`_request_refusals_total{check}`. Its 46 check labels start at zero. +`_request_refusals_total{check}`. Its 45 shared check labels start at zero. The recorder emits `request refused` logs with `failed_check` and no caller values. It writes at most five such lines per check per minute. In production, refusals that look the same to the caller can count under different checks. diff --git a/docs/site/src/content/docs/security/messaging.mdx b/docs/site/src/content/docs/security/messaging.mdx index d65e635a4a..51efccdc56 100644 --- a/docs/site/src/content/docs/security/messaging.mdx +++ b/docs/site/src/content/docs/security/messaging.mdx @@ -58,7 +58,7 @@ fetched, read or used, is `503 service.unavailable` with `Retry-After: 5`; the c is wrong, so a caller should retry rather than rotate it. Messaging counts every refused request by the check that refused it, in `messaging_request_refusals_total{check}` on the private metrics listener. The `check` label is a -closed set of 46 names such as `token-signature`, `scope`, `actor-kind`, `access-profile`, +closed set of 45 names such as `token-signature`, `scope`, `actor-kind`, `access-profile`, `delivery-signature` and `visibility`, every one published at zero, and no caller value becomes a label. A verifier that cannot reach its key source counts under `key-source-unavailable`. Each refusal also writes one `request refused` log line with `failed_check` and the request's trace id diff --git a/docs/site/src/content/docs/security/render.mdx b/docs/site/src/content/docs/security/render.mdx index 33f64cf063..02583d2d35 100644 --- a/docs/site/src/content/docs/security/render.mdx +++ b/docs/site/src/content/docs/security/render.mdx @@ -257,7 +257,7 @@ returns 503. See [Diagnose a refused call](../../operate/advanced/connect-an-oid Render counts every refused request by the check that refused it, in `render_request_refusals_total{check}`. The series is served on the private metrics listener when `metricsListener` is set. Without it the counter still counts and the log line is the only signal. -The `check` label is a closed set of 46 names, every one published at zero, and no caller value +The `check` label is a closed set of 45 names, every one published at zero, and no caller value becomes a label. The counter covers a missing or malformed credential, a shared API key mismatch, a token the verifier refuses, a key source Render cannot reach or use, a missing scope, the shared key presented to the seal diff --git a/docs/site/src/content/docs/security/scheduling.mdx b/docs/site/src/content/docs/security/scheduling.mdx index b1356f29cf..ee594067b7 100644 --- a/docs/site/src/content/docs/security/scheduling.mdx +++ b/docs/site/src/content/docs/security/scheduling.mdx @@ -64,7 +64,7 @@ callers holding bearer tokens from a configured issuer. - The operator's view of a refusal: Scheduling counts every refused request by the check that refused it, in `scheduling_request_refusals_total{check}` on the private metrics listener ([metrics](../../operate/scheduling/#watch-the-metrics)). - The `check` label is a closed set of 46 names, every one published at zero, and no caller value + The `check` label is a closed set of 45 names, every one published at zero, and no caller value becomes a label. An answer replayed from a stored receipt is not counted again. Each refusal also writes one `request refused` log line with `failed_check` and the request's From fdc9772a883396343ba777784d9c3d4236dba017 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:41:23 +0000 Subject: [PATCH 34/96] test(adapter): expect only shared refusal labels Signed-off-by: Jeremi Joslin --- crates/registry-adapter/tests/facade_refusals.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/registry-adapter/tests/facade_refusals.rs b/crates/registry-adapter/tests/facade_refusals.rs index b418ddb0a1..bf07ca61c8 100644 --- a/crates/registry-adapter/tests/facade_refusals.rs +++ b/crates/registry-adapter/tests/facade_refusals.rs @@ -340,7 +340,11 @@ async fn every_refusal_keeps_its_answer_and_is_counted_and_logged_under_its_chec expected.values().sum::(), "no other check was counted: {counted:?}" ); - assert_eq!(counted.len(), 46, "every check is declared at zero"); + assert_eq!(counted.len(), 45, "every shared check is declared"); + assert!( + !counted.contains_key("membership"), + "membership is a BReg-only check" + ); let stderr = served.wait_for_stderr("\"request refused\"", STDERR_WAIT); std::thread::sleep(Duration::from_millis(300)); From a316cc3ab32d95372cac0bf40708d7675f7d7d83 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:50:50 +0000 Subject: [PATCH 35/96] docs: align BReg refusal counts and release history Signed-off-by: Jeremi Joslin --- docs/site/src/content/docs/operate/breg-monitor.mdx | 2 +- products/platform/CHANGELOG.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/site/src/content/docs/operate/breg-monitor.mdx b/docs/site/src/content/docs/operate/breg-monitor.mdx index 48a651b2e5..6a39484330 100644 --- a/docs/site/src/content/docs/operate/breg-monitor.mdx +++ b/docs/site/src/content/docs/operate/breg-monitor.mdx @@ -162,7 +162,7 @@ curl -s http://127.0.0.1:9464/metrics ``` After one readiness probe and two requests without a token, the scrape held these samples (help -text and histogram lines omitted, and the other 44 `breg_request_refusals_total` checks showing 0): +text and histogram lines omitted, and the other 45 `breg_request_refusals_total` checks showing 0): ```text breg_http_requests_total{route="/ready",method="GET",status="success"} 1 diff --git a/products/platform/CHANGELOG.md b/products/platform/CHANGELOG.md index 748029e7da..8938654842 100644 --- a/products/platform/CHANGELOG.md +++ b/products/platform/CHANGELOG.md @@ -91,6 +91,9 @@ - Publish the `ghcr.io/registrystack/registry-session` container image and its candidate-bound security evidence from v0.52.0. +- The default refusal recorder publishes 45 shared checks. Only BReg adds + `membership` as an admission check, for a total of 46. + ## 0.51.0 - 2026-12-03 - `rstack dev check` refuses incompatible owner reports and mismatched identity facts. @@ -149,7 +152,6 @@ The runner pins the checked numeric address in the generated product URLs. Verified TLS remains the default. Production and `provision` keep their existing transport rules. -- The closed set of refusal checks includes `membership` in the admission class. ## 0.50.0 - 2026-12-01 From 143cb22598e07e24b20eb8010ce54794c89ffe44 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 04:55:25 +0000 Subject: [PATCH 36/96] fix(breg): create development package artifacts privately Give local rehearsal receipts and package construction owner-only creation modes. Publish completed deployment packages with readable directories and files for the runtime user. Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/package.rs | 117 ++++++++++++------ crates/registry-bregctl/src/lib.rs | 62 +++++++--- .../registry-bregctl/src/package_lifecycle.rs | 34 +++-- crates/registry-bregctl/src/test_lifecycle.rs | 39 ++++-- crates/registry-bregctl/tests/cli.rs | 114 ++++++++++++++++- .../registry-platform-config/src/package.rs | 64 ++++++++-- 6 files changed, 344 insertions(+), 86 deletions(-) diff --git a/crates/registry-breg/src/package.rs b/crates/registry-breg/src/package.rs index b60edf7e5f..036b5c9d75 100644 --- a/crates/registry-breg/src/package.rs +++ b/crates/registry-breg/src/package.rs @@ -19,8 +19,10 @@ use std::io::{Read, Write}; use std::path::{Component, Path, PathBuf}; use registry_platform_canonical_json::{canonicalize_json, parse_json_strict}; +#[cfg(all(test, feature = "tooling"))] +use registry_platform_config::package::write_sum_file; use registry_platform_config::package::{ - plan_package, write_sum_file, PackageLimits as SharedPackageLimits, + plan_package, write_sum_file_with_mode, PackageLimits as SharedPackageLimits, VerifiedPackage as SharedVerifiedPackage, REVISION_FILE, SUM_FILE, }; use serde::{Deserialize, Serialize}; @@ -968,12 +970,32 @@ impl PreparedPackage { } /// Publish inside the shared Registry Stack package envelope, optionally - /// with a `REVISION` file. A package carries no environment, so every - /// directory and file is written owner-only. + /// with a `REVISION` file. The deployment package is readable by a + /// separate runtime user. pub fn publish_to_directory_with_revision( &self, destination: &Path, revision: Option<&str>, + ) -> Result { + self.publish(destination, revision, 0o755, 0o644) + } + + /// Publish a local package with owner-only Unix permissions. Package + /// bytes and digest are independent of the permissions used to write it. + pub fn publish_private_to_directory_with_revision( + &self, + destination: &Path, + revision: Option<&str>, + ) -> Result { + self.publish(destination, revision, 0o700, 0o600) + } + + fn publish( + &self, + destination: &Path, + revision: Option<&str>, + directory_mode: u32, + file_mode: u32, ) -> Result { let manifest_bytes = self.manifest_bytes()?; reject_symlink_components(destination)?; @@ -985,30 +1007,46 @@ impl PreparedPackage { if !parent.is_dir() { return Err(PackageError::UnsafePath); } - fs::create_dir(destination).map_err(|_| PackageError::Closure)?; - set_safe_directory_permissions(destination)?; + let directories = &mut fs::DirBuilder::new(); + #[cfg(unix)] + { + use std::os::unix::fs::DirBuilderExt as _; + + directories.mode(0o700); + } + directories + .create(destination) + .map_err(|_| PackageError::Closure)?; let publish = (|| { + // Keep the root private until even a package for a separate + // runtime user has a complete, verified envelope. + set_directory_permissions(destination, 0o700)?; + let mut created_directories = BTreeSet::new(); for (path, bytes) in &self.files { let relative = Path::new(path); - let full = destination.join(relative); - if let Some(parent) = full.parent() { - fs::create_dir_all(parent).map_err(|_| PackageError::Closure)?; - set_safe_directory_permissions(parent)?; + let parent = relative.parent().ok_or(PackageError::UnsafePath)?; + let mut directory = destination.to_path_buf(); + for component in parent.components() { + directory.push(component.as_os_str()); + if created_directories.insert(directory.clone()) { + directories + .create(&directory) + .map_err(|_| PackageError::Closure)?; + set_directory_permissions(&directory, directory_mode)?; + } } - write_new_file(&full, bytes)?; + write_new_file(&destination.join(relative), bytes, file_mode)?; } - write_new_file(&destination.join(MANIFEST_PATH), &manifest_bytes)?; - let package = write_sum_file( + write_new_file(&destination.join(MANIFEST_PATH), &manifest_bytes, file_mode)?; + let package = write_sum_file_with_mode( destination, revision, &shared_package_limits(), "bregctl package", + file_mode, ) .map_err(|_| PackageError::Closure)?; - set_safe_file_permissions(&destination.join(SUM_FILE))?; - if revision.is_some() { - set_safe_file_permissions(&destination.join(REVISION_FILE))?; - } + set_directory_permissions(destination, directory_mode)?; Ok(package) })(); if publish.is_err() { @@ -4108,41 +4146,42 @@ fn validate_build_bindings( Ok(()) } -fn write_new_file(path: &Path, bytes: &[u8]) -> Result<()> { +fn write_new_file( + path: &Path, + bytes: &[u8], + #[cfg_attr(not(unix), allow(unused_variables))] mode: u32, +) -> Result<()> { reject_symlink_components(path)?; - let mut file = OpenOptions::new() - .write(true) - .create_new(true) - .open(path) - .map_err(|_| PackageError::Closure)?; - file.write_all(bytes).map_err(|_| PackageError::Read)?; - file.sync_all().map_err(|_| PackageError::Read)?; - set_safe_file_permissions(path) -} - -#[cfg(unix)] -fn set_safe_directory_permissions(path: &Path) -> Result<()> { - use std::os::unix::fs::PermissionsExt; + let mut options = OpenOptions::new(); + options.write(true).create_new(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt as _; - fs::set_permissions(path, fs::Permissions::from_mode(0o755)) - .map_err(|_| PackageError::Permissions) -} + options.mode(0o600); + } + let mut file = options.open(path).map_err(|_| PackageError::Closure)?; + file.write_all(bytes).map_err(|_| PackageError::Read)?; + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt as _; -#[cfg(not(unix))] -fn set_safe_directory_permissions(_path: &Path) -> Result<()> { - Ok(()) + file.set_permissions(fs::Permissions::from_mode(mode)) + .map_err(|_| PackageError::Permissions)?; + } + file.sync_all().map_err(|_| PackageError::Read) } #[cfg(unix)] -fn set_safe_file_permissions(path: &Path) -> Result<()> { +fn set_directory_permissions(path: &Path, mode: u32) -> Result<()> { use std::os::unix::fs::PermissionsExt; - fs::set_permissions(path, fs::Permissions::from_mode(0o644)) + fs::set_permissions(path, fs::Permissions::from_mode(mode)) .map_err(|_| PackageError::Permissions) } #[cfg(not(unix))] -fn set_safe_file_permissions(_path: &Path) -> Result<()> { +fn set_directory_permissions(_path: &Path, _mode: u32) -> Result<()> { Ok(()) } diff --git a/crates/registry-bregctl/src/lib.rs b/crates/registry-bregctl/src/lib.rs index 73187eeeb0..996b8020d9 100644 --- a/crates/registry-bregctl/src/lib.rs +++ b/crates/registry-bregctl/src/lib.rs @@ -6742,8 +6742,14 @@ fn package(args: &PackageArgs, posture: DeclaredPosture) -> Result Result unreachable!("clap requires exactly one schema-test credential source"), }; - let output = test_lifecycle::preflight_output(output).map_err(test_lifecycle_failure)?; + let output = + test_lifecycle::preflight_output(output, OutputModes::for_posture(posture.posture).file) + .map_err(test_lifecycle_failure)?; let candidate = capture_candidate(&args.candidate, "test", true, posture, false)?; let outcome = match test_lifecycle::run( posture, @@ -12652,8 +12660,33 @@ fn ensure_source_entry_identity( )) } +#[derive(Clone, Copy)] +struct OutputModes { + directory: u32, + file: u32, +} + +impl OutputModes { + // Public authoring exports keep the process umask. + const INHERITED: Self = Self { + directory: 0o777, + file: 0o666, + }; + const PRIVATE: Self = Self { + directory: 0o700, + file: 0o600, + }; + + fn for_posture(posture: Posture) -> Self { + match posture { + Posture::Development => Self::PRIVATE, + Posture::Production => Self::INHERITED, + } + } +} + fn write_source_files(output: &Path, files: &BTreeMap>) -> Result<(), Diagnostic> { - write_files_with_before_publish(output, files, |_| Ok(())) + write_files_with_before_publish(output, files, OutputModes::INHERITED, |_| Ok(())) } fn write_artifacts(output: &Path, artifacts: &[GeneratedArtifact]) -> Result<(), Diagnostic> { @@ -12661,7 +12694,7 @@ fn write_artifacts(output: &Path, artifacts: &[GeneratedArtifact]) -> Result<(), .iter() .map(|artifact| (artifact.path.clone(), artifact.bytes.clone())) .collect(); - write_files_with_before_publish(output, &files, |_| Ok(())) + write_files_with_before_publish(output, &files, OutputModes::INHERITED, |_| Ok(())) } #[cfg(test)] @@ -12675,12 +12708,13 @@ fn write_artifacts_with_before_publish( .values() .map(|artifact| (artifact.path.clone(), artifact.bytes.clone())) .collect(); - write_files_with_before_publish(output, &files, before_publish) + write_files_with_before_publish(output, &files, OutputModes::INHERITED, before_publish) } fn write_files_with_before_publish( output: &Path, files: &BTreeMap>, + modes: OutputModes, before_publish: impl FnOnce(&Path) -> Result<(), Diagnostic>, ) -> Result<(), Diagnostic> { // Only the shape of the path is judged here. Whether the destination is @@ -12744,16 +12778,13 @@ fn write_files_with_before_publish( return Err(diagnostic("output.destination.invalid", "output", &message)); } - let staged = create_staging_directory(parent)?; + let staged = create_staging_directory(parent, modes.directory)?; let result = (|| { let root = parent.open_directory(&staged).map_err(|_| write_failed())?; for (relative_path, bytes) in files { - let (directory, name) = artifact_destination(&root, relative_path)?; - // The staged tree keeps the process umask that the previous - // pathname-based writer applied, so published output permissions - // are unchanged. + let (directory, name) = artifact_destination(&root, relative_path, modes.directory)?; let mut file = directory - .create_new(&name, 0o666) + .create_new(&name, modes.file) .map_err(|_| write_failed())?; file.write_all(bytes).map_err(|_| write_failed())?; file.sync_all().map_err(|_| write_failed())?; @@ -12775,7 +12806,7 @@ fn write_files_with_before_publish( /// Create a uniquely named staging directory as a child of `parent` and return /// its name, which stays valid relative to that descriptor. -fn create_staging_directory(parent: &SafeDir) -> Result { +fn create_staging_directory(parent: &SafeDir, mode: u32) -> Result { let stage_failed = || { diagnostic( "output.stage.failed", @@ -12786,7 +12817,7 @@ fn create_staging_directory(parent: &SafeDir) -> Result { for _ in 0..64 { let counter = STAGING_COUNTER.fetch_add(1, Ordering::Relaxed); let staged = OsString::from(format!(".bregctl-stage-{}-{counter}", std::process::id())); - match parent.create_directory(&staged, 0o777) { + match parent.create_directory(&staged, mode) { Ok(()) => return Ok(staged), Err(error) if error.kind() == io::ErrorKind::AlreadyExists => continue, Err(_) => return Err(stage_failed()), @@ -12801,6 +12832,7 @@ fn create_staging_directory(parent: &SafeDir) -> Result { fn artifact_destination( root: &SafeDir, artifact_path: &str, + directory_mode: u32, ) -> Result<(SafeDir, OsString), Diagnostic> { let unsafe_path = || { diagnostic( @@ -12838,7 +12870,7 @@ fn artifact_destination( })?; for part in names { directory = directory - .open_or_create_directory(part, 0o777) + .open_or_create_directory(part, directory_mode) .map_err(|_| { diagnostic( "output.write.failed", diff --git a/crates/registry-bregctl/src/package_lifecycle.rs b/crates/registry-bregctl/src/package_lifecycle.rs index b47c5dfb25..6d81323969 100644 --- a/crates/registry-bregctl/src/package_lifecycle.rs +++ b/crates/registry-bregctl/src/package_lifecycle.rs @@ -14,8 +14,10 @@ use registry_breg::fixtures::{ use registry_breg::package::{ PackageError, PackageFileRole, PreparedPackage, FIXTURE_JOURNEYS_PATH, }; +use registry_platform_config::Posture; use crate::safe_path::{EntryStat, SafeDir, SafeEntry}; +use crate::OutputModes; const TEST_RECEIPT_PATH: &str = "schema-test-receipt.json"; const PACKAGE_DIRECTORY: &str = "package"; @@ -72,12 +74,22 @@ pub(crate) fn run( test_receipt: ValidatedTestReceipt, build_directory: &Path, revision: Option<&str>, + posture: Posture, ) -> Result { - ensure_reviewer_evidence(build_directory, &test_receipt.bytes)?; - - let shared = prepared - .publish_to_directory_with_revision(&build_directory.join(PACKAGE_DIRECTORY), revision) - .map_err(PackageLifecycleError::Package)?; + ensure_reviewer_evidence( + build_directory, + &test_receipt.bytes, + OutputModes::for_posture(posture), + )?; + + let destination = build_directory.join(PACKAGE_DIRECTORY); + let shared = match posture { + Posture::Development => { + prepared.publish_private_to_directory_with_revision(&destination, revision) + } + Posture::Production => prepared.publish_to_directory_with_revision(&destination, revision), + } + .map_err(PackageLifecycleError::Package)?; Ok(PackageLifecycleOutcome { package_digest: shared.digest().to_owned(), registry_revision: prepared.registry().revision().to_owned(), @@ -217,6 +229,7 @@ fn receipt_fields(path: &Path, bytes: &[u8]) -> Result Result<(), PackageLifecycleError> { // Resolving once decides both outcomes: a build directory that is there // is compared through the descriptor this opens, and one that is not there @@ -259,7 +272,8 @@ fn ensure_reviewer_evidence( return Ok(()); } let files = BTreeMap::from([(TEST_RECEIPT_PATH.to_owned(), expected_test_receipt.to_vec())]); - super::write_source_files(build_directory, &files).map_err(|_| PackageLifecycleError::Output) + super::write_files_with_before_publish(build_directory, &files, modes, |_| Ok(())) + .map_err(|_| PackageLifecycleError::Output) } /// Read a bounded regular file through a held directory descriptor, for callers @@ -414,7 +428,7 @@ mod tests { // Swap once the build directory is resolved, so only the held // descriptor still names the real tree. let guard = tree.arm(); - let refused = ensure_reviewer_evidence(&build, b"receipt") + let refused = ensure_reviewer_evidence(&build, b"receipt", OutputModes::INHERITED) .expect_err("an already published package directory is refused"); drop(guard); @@ -439,7 +453,7 @@ mod tests { // Swap once the build directory is resolved and before its evidence // is read, which is where a racing process would land. let guard = tree.arm_directory_swap(); - let refused = ensure_reviewer_evidence(&build, b"receipt") + let refused = ensure_reviewer_evidence(&build, b"receipt", OutputModes::INHERITED) .expect_err("evidence from a directory the operator never named is refused"); drop(guard); @@ -481,7 +495,7 @@ mod tests { let tree = race_tree(); let build = tree.named("build"); - ensure_reviewer_evidence(&build, b"receipt") + ensure_reviewer_evidence(&build, b"receipt", OutputModes::PRIVATE) .expect("a build directory that is not there yet is the first run"); assert_eq!( @@ -504,7 +518,7 @@ mod tests { std::fs::write(decoy.join(TEST_RECEIPT_PATH), b"receipt").unwrap(); symlink(&decoy, &build).unwrap(); - let refused = ensure_reviewer_evidence(&build, b"receipt") + let refused = ensure_reviewer_evidence(&build, b"receipt", OutputModes::INHERITED) .expect_err("a build directory reached through a symbolic link is refused"); assert!(matches!(refused, PackageLifecycleError::Output)); diff --git a/crates/registry-bregctl/src/test_lifecycle.rs b/crates/registry-bregctl/src/test_lifecycle.rs index e2e04110f7..f2e7df70d7 100644 --- a/crates/registry-bregctl/src/test_lifecycle.rs +++ b/crates/registry-bregctl/src/test_lifecycle.rs @@ -90,6 +90,7 @@ pub(crate) struct SchemaMeasurement { #[derive(Debug)] pub(crate) struct OutputTarget { destination: SafeEntry, + file_mode: u32, } #[derive(Debug)] @@ -177,7 +178,10 @@ enum CredentialDocumentMode { } tagged_union!(CredentialDocumentMode); -pub(crate) fn preflight_output(path: &Path) -> Result { +pub(crate) fn preflight_output( + path: &Path, + file_mode: u32, +) -> Result { let refused = || TestLifecycleError::OutputPreflight { message: "the schema-test receipt output was refused".to_owned(), }; @@ -212,7 +216,7 @@ pub(crate) fn preflight_output(path: &Path) -> Result metadata, Err(_) => { @@ -232,7 +236,10 @@ pub(crate) fn preflight_output(path: &Path) -> Result TestLifecycleError { fn publish_receipt(target: &OutputTarget, bytes: &[u8]) -> Result<(), TestLifecycleError> { let parent = target.destination.parent(); - let (temporary, mut file) = create_temporary_file(parent)?; + let (temporary, mut file) = create_temporary_file(parent, target.file_mode)?; let result = (|| { file.write_all(bytes) .map_err(|_| TestLifecycleError::OutputCommit)?; @@ -705,14 +712,17 @@ fn publish_receipt(target: &OutputTarget, bytes: &[u8]) -> Result<(), TestLifecy result } -fn create_temporary_file(parent: &SafeDir) -> Result<(OsString, File), TestLifecycleError> { +fn create_temporary_file( + parent: &SafeDir, + mode: u32, +) -> Result<(OsString, File), TestLifecycleError> { for _ in 0..64 { let counter = TEST_OUTPUT_COUNTER.fetch_add(1, Ordering::Relaxed); let temporary = OsString::from(format!( ".bregctl-test-receipt-{}-{counter}.tmp", std::process::id() )); - match parent.create_new(&temporary, 0o666) { + match parent.create_new(&temporary, mode) { Ok(file) => return Ok((temporary, file)), Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue, Err(_) => return Err(TestLifecycleError::OutputCommit), @@ -911,7 +921,7 @@ mod tests { registry_breg::package::PackageError::UnsafePath ); let output_path = root.join("receipt.json"); - let output = preflight_output(&output_path).unwrap(); + let output = preflight_output(&output_path, crate::OutputModes::INHERITED.file).unwrap(); let errors = [ ( "prevalidate", @@ -1123,7 +1133,8 @@ bindings: fn output_publish_refuses_a_target_created_after_preflight_without_replacement() { let directory = TestDirectory::create(); let output = directory.path.join("receipt.json"); - let target = preflight_output(&output).expect("output preflights"); + let target = preflight_output(&output, crate::OutputModes::INHERITED.file) + .expect("output preflights"); assert!(!output.exists()); fs::write(&output, b"operator-owned").expect("racing output writes"); @@ -1178,7 +1189,8 @@ bindings: let output = directory.path.join("receipt.json"); let _fault = install_preflight_metadata_fault(); - let error = preflight_output(&output).expect_err("an unidentifiable receipt is refused"); + let error = preflight_output(&output, crate::OutputModes::INHERITED.file) + .expect_err("an unidentifiable receipt is refused"); assert!(matches!(error, TestLifecycleError::OutputPreflight { .. })); assert!( @@ -1195,7 +1207,8 @@ bindings: let linked = directory.path.join("linked"); fs::create_dir(&real).unwrap(); std::os::unix::fs::symlink(&real, &linked).unwrap(); - let message = |path: &Path| match preflight_output(path) { + let message = |path: &Path| match preflight_output(path, crate::OutputModes::INHERITED.file) + { Err(TestLifecycleError::OutputPreflight { message }) => message, _ => panic!("the output is refused"), }; @@ -1608,7 +1621,11 @@ journeys: let tree = race_tree(); let guard = tree.arm(); - let target = preflight_output(&tree.named("receipt.json")).unwrap(); + let target = preflight_output( + &tree.named("receipt.json"), + crate::OutputModes::INHERITED.file, + ) + .unwrap(); publish_receipt(&target, b"receipt").unwrap(); drop(guard); diff --git a/crates/registry-bregctl/tests/cli.rs b/crates/registry-bregctl/tests/cli.rs index 95a10256b3..d7de4ac72d 100644 --- a/crates/registry-bregctl/tests/cli.rs +++ b/crates/registry-bregctl/tests/cli.rs @@ -2391,6 +2391,17 @@ fn bregctl(arguments: &[&str]) -> Output { .expect("bregctl starts") } +#[cfg(unix)] +fn bregctl_with_umask(mask: &str, arguments: &[&str]) -> Output { + Command::new("/bin/sh") + .args(["-c", r#"umask "$1"; shift; exec "$@""#, "bregctl", mask]) + .arg(env!("CARGO_BIN_EXE_bregctl")) + .args(arguments) + .env_remove("REGISTRY_STACK_POSTURE") + .output() + .expect("bregctl starts") +} + #[test] fn examples_review_is_not_a_command() { let output = bregctl(&["examples", "review", "--help"]); @@ -8305,7 +8316,7 @@ fn package_bytes_do_not_depend_on_the_declared_posture() { .unwrap(); let package = |posture, output: &Path| { - let result = bregctl(&[ + let arguments = [ "--format", "json", "package", @@ -8316,7 +8327,13 @@ fn package_bytes_do_not_depend_on_the_declared_posture() { path(output), "--posture", posture, - ]); + "--revision", + "fixture-revision", + ]; + #[cfg(unix)] + let result = bregctl_with_umask("0077", &arguments); + #[cfg(not(unix))] + let result = bregctl(&arguments); assert!(result.status.success(), "{result:?}"); json_stdout(&result) }; @@ -8329,6 +8346,8 @@ fn package_bytes_do_not_depend_on_the_declared_posture() { production_report["packageDigest"] ); assert_eq!(tree(&development), tree(&production)); + #[cfg(unix)] + assert_artifact_modes(&production.join("package"), 0o755, 0o644); assert_eq!( development_report["posture"], json!({"source": "flag", "value": "development"}) @@ -8339,6 +8358,97 @@ fn package_bytes_do_not_depend_on_the_declared_posture() { ); } +#[cfg(unix)] +fn assert_artifact_modes(path: &Path, directory_mode: u32, file_mode: u32) { + use std::os::unix::fs::PermissionsExt as _; + + let metadata = fs::symlink_metadata(path).expect("artifact metadata reads"); + let mode = metadata.permissions().mode() & 0o777; + if metadata.is_dir() { + assert_eq!(mode, directory_mode, "{path:?}"); + for entry in fs::read_dir(path).expect("artifact directory reads") { + assert_artifact_modes( + &entry.expect("entry reads").path(), + directory_mode, + file_mode, + ); + } + } else { + assert!(metadata.is_file(), "{path:?}"); + assert_eq!(mode, file_mode, "{path:?}"); + } +} + +#[cfg(unix)] +#[test] +fn development_package_verifies_under_group_writable_umask() { + let project = packaging_project(); + let fingerprint = format!("sha256:{}", "2".repeat(64)); + let candidate = prepare_packaging_candidate(&project, &fingerprint); + let receipt = project.path().join("schema-test-receipt.json"); + fs::write( + &receipt, + schema_test_receipt_bytes(&candidate, &["package-record-list"]), + ) + .unwrap(); + let build = project.path().join("build"); + let published = bregctl_with_umask( + "0002", + &[ + "--format", + "json", + "package", + path(project.path()), + "--test-receipt", + path(&receipt), + "--output", + path(&build), + "--revision", + "development-revision", + "--posture", + "development", + ], + ); + let package_report = json_stdout(&published); + assert!( + published.status.success(), + "packaging failed with {:?}", + package_report["diagnostics"][0]["code"] + ); + assert!(published.stderr.is_empty()); + + let runtime = write_runtime_config( + project.path(), + &build.join("package"), + "127.0.0.1:1".parse().unwrap(), + ); + let verified = bregctl_with_umask( + "0002", + &[ + "--format", + "json", + "verify", + "--runtime-config", + path(&runtime), + "--posture", + "development", + ], + ); + let report = json_stdout(&verified); + assert!( + verified.status.success(), + "package verification failed with {:?}", + report["diagnostics"][0]["code"] + ); + assert!(verified.stderr.is_empty()); + assert_eq!(report["packageDigest"], package_report["packageDigest"]); + assert_eq!( + fs::read(build.join("package/REVISION")).unwrap(), + b"development-revision\n" + ); + assert_artifact_modes(&build, 0o700, 0o600); +} + #[test] fn production_package_publishes_the_unsigned_package_in_one_step() { let project = packaging_project(); diff --git a/crates/registry-platform-config/src/package.rs b/crates/registry-platform-config/src/package.rs index b230c4b426..7f1678d878 100644 --- a/crates/registry-platform-config/src/package.rs +++ b/crates/registry-platform-config/src/package.rs @@ -157,6 +157,30 @@ pub fn write_sum_file( revision: Option<&str>, limits: &PackageLimits, fix: &str, +) -> Result { + finish_package(root, revision, limits, fix, None) +} + +/// Finish a package with the given Unix mode for both envelope files. +/// Each file is created owner-only, then set to the exact mode through its +/// open descriptor before syncing. Other platforms use their standard file +/// creation permissions. +pub fn write_sum_file_with_mode( + root: &Path, + revision: Option<&str>, + limits: &PackageLimits, + fix: &str, + mode: u32, +) -> Result { + finish_package(root, revision, limits, fix, Some(mode)) +} + +fn finish_package( + root: &Path, + revision: Option<&str>, + limits: &PackageLimits, + fix: &str, + mode: Option, ) -> Result { let refuse = |kind| PackageError::new(root, fix, kind); check_root(root).map_err(refuse)?; @@ -182,7 +206,13 @@ pub fn write_sum_file( return Err(refuse(PackageErrorKind::Empty)); } if let Some(revision) = revision { - write_new(root, REVISION_FILE, format!("{revision}\n").as_bytes()).map_err(refuse)?; + write_new( + root, + REVISION_FILE, + format!("{revision}\n").as_bytes(), + mode, + ) + .map_err(refuse)?; walked.files.insert(REVISION_FILE.to_owned()); } check_file_count(walked.files.len(), limits).map_err(refuse)?; @@ -193,7 +223,7 @@ pub fn write_sum_file( total = add_bytes(total, length, limits).map_err(refuse)?; push_sum_line(&mut sums, &hex, path); } - write_new(root, SUM_FILE, sums.as_bytes()).map_err(refuse)?; + write_new(root, SUM_FILE, sums.as_bytes(), mode).map_err(refuse)?; verify_package(root, limits, fix) } @@ -248,7 +278,7 @@ pub fn write_package( }) })?; } - write_new(output, relative, bytes).map_err(refuse)?; + write_new(output, relative, bytes, None).map_err(refuse)?; } write_sum_file(output, revision, limits, fix) })(); @@ -948,16 +978,32 @@ fn same_file(left: &fs::Metadata, right: &fs::Metadata) -> bool { left.len() == right.len() && left.modified().ok() == right.modified().ok() } -fn write_new(root: &Path, relative: &str, bytes: &[u8]) -> Result<(), PackageErrorKind> { +fn write_new( + root: &Path, + relative: &str, + bytes: &[u8], + #[cfg_attr(not(unix), allow(unused_variables))] mode: Option, +) -> Result<(), PackageErrorKind> { let io = || PackageErrorKind::Io { path: relative.to_owned(), }; - let mut file = fs::OpenOptions::new() - .write(true) - .create_new(true) - .open(root.join(relative)) - .map_err(|_| io())?; + let mut options = fs::OpenOptions::new(); + options.write(true).create_new(true); + #[cfg(unix)] + if mode.is_some() { + use std::os::unix::fs::OpenOptionsExt as _; + + options.mode(0o600); + } + let mut file = options.open(root.join(relative)).map_err(|_| io())?; file.write_all(bytes).map_err(|_| io())?; + #[cfg(unix)] + if let Some(mode) = mode { + use std::os::unix::fs::PermissionsExt as _; + + file.set_permissions(fs::Permissions::from_mode(mode)) + .map_err(|_| io())?; + } file.sync_all().map_err(|_| io()) } From eed451e86bb20bc360758f7603862ba5b356e5a6 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 05:23:44 +0000 Subject: [PATCH 37/96] chore(breg): refresh ODRL examples for current project revisions Signed-off-by: Jeremi Joslin --- products/breg/examples/formats/odrl-coverage.json | 2 +- products/breg/examples/formats/odrl-policies.jsonld | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/products/breg/examples/formats/odrl-coverage.json b/products/breg/examples/formats/odrl-coverage.json index 25fdef6253..3433f328a0 100644 --- a/products/breg/examples/formats/odrl-coverage.json +++ b/products/breg/examples/formats/odrl-coverage.json @@ -1 +1 @@ -{"apiVersion":"id.registrystack.org/formats/breg/odrl-coverage/v1alpha1","audience":"operator-review","excludedSurfaces":["actions","proposals","statistics","lookups","read-paths","revisions","snapshots","mutations","counts","filters","sorting","spatial-queries","data-export","provenance"],"grants":[{"accessProfile":"directory-editor","operation":"create","reasons":["unsupported-operation","row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"get","reasons":["row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"list","reasons":["row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"patch","reasons":["unsupported-operation","row-boundaries"],"recordType":"contact","status":"omitted"}],"kind":"BRegOdrlCoverage","partial":true,"registryId":"local-directory","revision":"sha256:a8f3b5081ccbaa0243b7e36131a56fae4ef25f8b2c01ccd8afbcfc7c1386620b","scope":"record-operation-grants","selectedAccessProfile":null,"totals":{"considered":4,"exported":0,"omitted":4}} \ No newline at end of file +{"apiVersion":"id.registrystack.org/formats/breg/odrl-coverage/v1alpha1","audience":"operator-review","excludedSurfaces":["actions","proposals","statistics","lookups","read-paths","revisions","snapshots","mutations","counts","filters","sorting","spatial-queries","data-export","provenance"],"grants":[{"accessProfile":"directory-editor","operation":"create","reasons":["unsupported-operation","row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"get","reasons":["row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"list","reasons":["row-boundaries"],"recordType":"contact","status":"omitted"},{"accessProfile":"directory-editor","operation":"patch","reasons":["unsupported-operation","row-boundaries"],"recordType":"contact","status":"omitted"}],"kind":"BRegOdrlCoverage","partial":true,"registryId":"local-directory","revision":"sha256:4f8f16e6fb2c32d5b38797cc1c6aad84a3d875ca2b09b2ade66d3264219fa62f","scope":"record-operation-grants","selectedAccessProfile":null,"totals":{"considered":4,"exported":0,"omitted":4}} \ No newline at end of file diff --git a/products/breg/examples/formats/odrl-policies.jsonld b/products/breg/examples/formats/odrl-policies.jsonld index c8d612b39d..59f0ee44fe 100644 --- a/products/breg/examples/formats/odrl-policies.jsonld +++ b/products/breg/examples/formats/odrl-policies.jsonld @@ -1 +1 @@ -{"@context":{"dcterms":"http://purl.org/dc/terms/","odrl":"http://www.w3.org/ns/odrl/2/"},"@graph":[{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:profiles:directory-editor:policy","@type":"odrl:Set","https://id.registrystack.org/vocab/breg-odrl/partial":true,"odrl:permission":[{"odrl:action":{"@id":"http://www.w3.org/ns/odrl/2/read"},"odrl:constraint":[{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/accessProfile"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"directory-editor"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/authenticated"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":true}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/delegatedActor"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/operation"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"get"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/taskGrantPresent"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/tokenScopes"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"directory:write"}]}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/verifiedNonemptyClaims"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"registry_principal"}]}}],"odrl:target":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:record-types:entry:profiles:directory-editor:operations:get:projection","@type":"odrl:Asset","https://id.registrystack.org/vocab/breg-odrl/readableFields":{"@list":[{"@value":"active"},{"@value":"code"},{"@value":"recorded-on"}]},"https://id.registrystack.org/vocab/breg-odrl/recordType":"entry","odrl:partOf":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:record-types:entry"}}},{"odrl:action":{"@id":"http://www.w3.org/ns/odrl/2/read"},"odrl:constraint":[{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/accessProfile"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"directory-editor"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/authenticated"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":true}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/delegatedActor"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/operation"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"list"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/taskGrantPresent"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/tokenScopes"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"directory:write"}]}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/verifiedNonemptyClaims"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"registry_principal"}]}}],"odrl:target":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:record-types:entry:profiles:directory-editor:operations:list:projection","@type":"odrl:Asset","https://id.registrystack.org/vocab/breg-odrl/readableFields":{"@list":[{"@value":"active"},{"@value":"code"},{"@value":"recorded-on"}]},"https://id.registrystack.org/vocab/breg-odrl/recordType":"entry","odrl:partOf":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:record-types:entry"}}}],"odrl:profile":[{"@id":"https://id.registrystack.org/profiles/breg-odrl/v1"}],"odrl:uid":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:profiles:directory-editor:policy"}}],"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3Ac605b88ee0dd6158d870c23ac41a6c3822e13173a840a488986439ca276fef50:odrl:policies","http://purl.org/dc/terms/description":"Partial, non-enforcing projection of supported BReg record-operation grants; review coverage.json before use.","https://id.registrystack.org/vocab/breg-odrl/partial":true} \ No newline at end of file +{"@context":{"dcterms":"http://purl.org/dc/terms/","odrl":"http://www.w3.org/ns/odrl/2/"},"@graph":[{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:profiles:directory-editor:policy","@type":"odrl:Set","https://id.registrystack.org/vocab/breg-odrl/partial":true,"odrl:permission":[{"odrl:action":{"@id":"http://www.w3.org/ns/odrl/2/read"},"odrl:constraint":[{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/accessProfile"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"directory-editor"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/authenticated"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":true}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/delegatedActor"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/operation"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"get"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/taskGrantPresent"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/tokenScopes"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"directory:write"}]}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/verifiedNonemptyClaims"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"registry_principal"}]}}],"odrl:target":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:record-types:entry:profiles:directory-editor:operations:get:projection","@type":"odrl:Asset","https://id.registrystack.org/vocab/breg-odrl/readableFields":{"@list":[{"@value":"active"},{"@value":"code"},{"@value":"recorded-on"}]},"https://id.registrystack.org/vocab/breg-odrl/recordType":"entry","odrl:partOf":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:record-types:entry"}}},{"odrl:action":{"@id":"http://www.w3.org/ns/odrl/2/read"},"odrl:constraint":[{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/accessProfile"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"directory-editor"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/authenticated"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":true}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/delegatedActor"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/operation"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":"list"}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/taskGrantPresent"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/eq"},"odrl:rightOperand":{"@value":false}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/tokenScopes"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"directory:write"}]}},{"odrl:leftOperand":{"@id":"https://id.registrystack.org/vocab/breg-odrl/verifiedNonemptyClaims"},"odrl:operator":{"@id":"http://www.w3.org/ns/odrl/2/hasPart"},"odrl:rightOperand":{"@list":[{"@value":"registry_principal"}]}}],"odrl:target":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:record-types:entry:profiles:directory-editor:operations:list:projection","@type":"odrl:Asset","https://id.registrystack.org/vocab/breg-odrl/readableFields":{"@list":[{"@value":"active"},{"@value":"code"},{"@value":"recorded-on"}]},"https://id.registrystack.org/vocab/breg-odrl/recordType":"entry","odrl:partOf":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:record-types:entry"}}}],"odrl:profile":[{"@id":"https://id.registrystack.org/profiles/breg-odrl/v1"}],"odrl:uid":{"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:profiles:directory-editor:policy"}}],"@id":"urn:registrystack:breg:labelled-directory:revision:sha256%3A91ffd4b2956335708e4cca8302d19f43d9bbf84cd5670a5ab7165fd5021343d0:odrl:policies","http://purl.org/dc/terms/description":"Partial, non-enforcing projection of supported BReg record-operation grants; review coverage.json before use.","https://id.registrystack.org/vocab/breg-odrl/partial":true} \ No newline at end of file From 34d0c883777aac31b2ac7d795fea58317efebf1a Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 05:26:38 +0000 Subject: [PATCH 38/96] fix(breg): refresh canonical facility Proposal contracts Signed-off-by: Jeremi Joslin --- products/breg/generated/facility/compiled/actions.json | 2 +- products/breg/generated/facility/compiled/effective-model.json | 2 +- .../breg/generated/facility/generated/action-contracts.json | 2 +- .../action-schemas/correct-address.invoke.response.schema.json | 2 +- .../deactivate-facility.invoke.response.schema.json | 2 +- products/breg/generated/facility/generated/openapi.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/products/breg/generated/facility/compiled/actions.json b/products/breg/generated/facility/compiled/actions.json index 2b7521ab83..5eab81d679 100644 --- a/products/breg/generated/facility/compiled/actions.json +++ b/products/breg/generated/facility/compiled/actions.json @@ -1 +1 @@ -{"access":[{"actionId":"correct-address","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.correct-address.start"},{"actionId":"deactivate-facility","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.deactivate-facility.start"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.availability"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.invoke"}],"actions":[{"apiName":"correctAddress","commitEvidence":[],"definitionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"effects":[{"dependsOn":[],"id":"facility-address","mutations":[{"field":"address-line","kind":"set","value":{"kind":"literal","value":null}},{"field":"city","kind":"set","value":{"kind":"literal","value":null}},{"field":"postal-code","kind":"set","value":{"kind":"literal","value":null}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{"supporting-document":{"classification":"restricted","contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}},"permissions":[{"actorKind":"service","default":false,"operations":["get-review-status"],"ownership":null,"principalClaim":"registry_principal","profileId":"casework-review-status","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":["casework-service"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review-status"],"reviewAuthority":"casework","targets":[],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","apply"],"ownership":null,"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"ownership":"caller","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":["supporting-document"],"readableContextFields":[],"readableInputs":["address-line","city","facility","postal-code"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":["supporting-document"]},{"actorKind":null,"default":false,"operations":["get-review-context"],"ownership":null,"principalClaim":"registry_principal","profileId":"proposal-reviewer","readableAttachments":[],"readableContextFields":["changes","currentAddressLine","facilityId","supportingDocument"],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"reviewContext":{"fields":{"changes":{"fields":["address-line","city","postal-code"],"recordType":"facility","type":"changes"},"currentAddressLine":{"field":"address-line","input":"facility","type":"record"},"facilityId":{"input":"facility","type":"input"},"supportingDocument":{"slot":"supporting-document","type":"document"}},"id":"facility-address-context"},"systemApplyGrant":{"actionId":"correct-address","actionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","revision":"sha256:b09c24636b3d208832104a44747d02487181ee91ed74305e6fe0db2fba63c6f6","targets":[{"fields":[],"operation":"get","readFields":["address-line","status"],"recordType":"facility"},{"fields":["address-line","city","postal-code"],"operation":"patch","readFields":["address-line","city","postal-code"],"recordType":"facility"}]}}},"handler":{"abi":"registry.action-plan/v1","boundInputs":["address-line","city","facility","postal-code"],"capabilities":[],"entrypoint":"plan","id":"correct-address-plan","kind":"rhai","limits":{"maximumArrayItems":256,"maximumCallDepth":32,"maximumExpressionDepth":64,"maximumMapEntries":256,"maximumModules":0,"maximumOperations":10000,"maximumOutputBytes":8192,"maximumSourceBytes":65536,"maximumStringBytes":16384},"refusals":{"invalid-postal-code":"Postal code is invalid"},"rhaiVersion":"1.27.0","scriptSha256":"sha256:0270538e561991ed35b7fa004f47fd98b744e626bd395fec3f073d61bc02b830","sourceModule":null,"writes":[{"fieldTypes":{"address-line":{"maximumLength":240,"minimumLength":1,"type":"string"},"city":{"maximumLength":120,"minimumLength":1,"type":"string"},"postal-code":{"maximumLength":24,"minimumLength":1,"type":"string"}},"fields":["address-line","city","postal-code"],"id":"facility-address","operation":"patch","referenceSources":{},"requiredFields":["address-line","city","postal-code"],"targetFromInput":"facility","targetRecordType":"facility"}]},"id":"correct-address","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-address"],"route":"/v1/actions/correct-address/proposals","targetUses":[{"conditionRequired":true,"fields":["address-line","city","postal-code"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["address-line","status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"deactivateFacility","commitEvidence":[],"definitionRevision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"effects":[{"dependsOn":[],"id":"facility-status","mutations":[{"field":"status","kind":"set","value":{"kind":"literal","value":"inactive"}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"mode":"manual"},"attachments":{},"permissions":[{"actorKind":null,"default":false,"operations":["get","list","apply"],"ownership":null,"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"ownership":"caller","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":[],"readableContextFields":[],"readableInputs":["facility"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null}},"id":"deactivate-facility","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-status"],"route":"/v1/actions/deactivate-facility/proposals","targetUses":[{"conditionRequired":true,"fields":["status"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"registerFacility","commitEvidence":[],"definitionRevision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"effects":[{"dependsOn":[],"id":"facility","mutations":[{"field":"address-line","kind":"set","value":{"input":"address-line","kind":"from-input"}},{"field":"city","kind":"set","value":{"input":"city","kind":"from-input"}},{"field":"facility-code","kind":"set","value":{"input":"facility-code","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}},{"field":"postal-code","kind":"set","value":{"input":"postal-code","kind":"from-input"}},{"field":"status","kind":"set","value":{"kind":"literal","value":"active"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility"}},{"dependsOn":["facility"],"id":"assignment","mutations":[{"field":"facility","kind":"set","value":{"effect":"facility","kind":"from-effect","target_entity_id":"facility"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"operator","kind":"set","value":{"input":"operator","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility-assignment"}}],"execution":{"mode":"immediate"},"id":"register-facility","inputs":[{"apiName":"facilityCode","classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","required":true},{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true},{"apiName":"operatorId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"facility-registrar","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:register"],"results":["assignment","facility"],"targets":[{"operation":"create","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"facility","kind":"effect"}},{"operation":"create","recordType":"facility-assignment","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"assignment","kind":"effect"}},{"operation":"get","recordType":"operator","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"operator","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"equalsInput":"jurisdiction","field":"jurisdiction","input":"operator","recordType":"operator","revisionUnchanged":false},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"operator","recordType":"operator","revisionUnchanged":false}],"resultEffects":["assignment","facility"],"route":"/v1/actions/register-facility","targetUses":[{"conditionRequired":false,"fields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"operation":"create","recordType":"facility","source":{"effect":"facility","kind":"effect"}},{"conditionRequired":false,"fields":["facility","jurisdiction","operator"],"operation":"create","recordType":"facility-assignment","source":{"effect":"assignment","kind":"effect"}},{"conditionRequired":false,"fields":["jurisdiction","status"],"operation":"get","recordType":"operator","source":{"input":"operator","kind":"input"}}]}],"routes":[{"accessProfiles":["facility-correction-author"],"actionId":"correct-address","defaultAccessProfile":"facility-correction-author","id":"actions.correct-address.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/correct-address/proposals"},{"accessProfiles":["facility-correction-author"],"actionId":"deactivate-facility","defaultAccessProfile":"facility-correction-author","id":"actions.deactivate-facility.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/deactivate-facility/proposals"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/register-facility"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/register-facility/availability"}]} \ No newline at end of file +{"access":[{"actionId":"correct-address","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.correct-address.start"},{"actionId":"deactivate-facility","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.deactivate-facility.start"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.availability"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.invoke"}],"actions":[{"apiName":"correctAddress","commitEvidence":[],"definitionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"effects":[{"dependsOn":[],"id":"facility-address","mutations":[{"field":"address-line","kind":"set","value":{"kind":"literal","value":null}},{"field":"city","kind":"set","value":{"kind":"literal","value":null}},{"field":"postal-code","kind":"set","value":{"kind":"literal","value":null}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{"supporting-document":{"classification":"restricted","contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}},"permissions":[{"actorKind":"service","default":false,"operations":["get-review-status"],"principalClaim":"registry_principal","profileId":"casework-review-status","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":["casework-service"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review-status"],"reviewAuthority":"casework","targets":[],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","apply"],"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"party":"owner","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":["supporting-document"],"readableContextFields":[],"readableInputs":["address-line","city","facility","postal-code"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":["supporting-document"]},{"actorKind":null,"default":false,"operations":["get-review-context"],"principalClaim":"registry_principal","profileId":"proposal-reviewer","readableAttachments":[],"readableContextFields":["changes","currentAddressLine","facilityId","supportingDocument"],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"reviewContext":{"fields":{"changes":{"fields":["address-line","city","postal-code"],"recordType":"facility","type":"changes"},"currentAddressLine":{"field":"address-line","input":"facility","type":"record"},"facilityId":{"input":"facility","type":"input"},"supportingDocument":{"slot":"supporting-document","type":"document"}},"id":"facility-address-context"},"systemApplyGrant":{"actionId":"correct-address","actionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","revision":"sha256:b09c24636b3d208832104a44747d02487181ee91ed74305e6fe0db2fba63c6f6","targets":[{"fields":[],"operation":"get","readFields":["address-line","status"],"recordType":"facility"},{"fields":["address-line","city","postal-code"],"operation":"patch","readFields":["address-line","city","postal-code"],"recordType":"facility"}]}}},"handler":{"abi":"registry.action-plan/v1","boundInputs":["address-line","city","facility","postal-code"],"capabilities":[],"entrypoint":"plan","id":"correct-address-plan","kind":"rhai","limits":{"maximumArrayItems":256,"maximumCallDepth":32,"maximumExpressionDepth":64,"maximumMapEntries":256,"maximumModules":0,"maximumOperations":10000,"maximumOutputBytes":8192,"maximumSourceBytes":65536,"maximumStringBytes":16384},"refusals":{"invalid-postal-code":"Postal code is invalid"},"rhaiVersion":"1.27.0","scriptSha256":"sha256:0270538e561991ed35b7fa004f47fd98b744e626bd395fec3f073d61bc02b830","sourceModule":null,"writes":[{"fieldTypes":{"address-line":{"maximumLength":240,"minimumLength":1,"type":"string"},"city":{"maximumLength":120,"minimumLength":1,"type":"string"},"postal-code":{"maximumLength":24,"minimumLength":1,"type":"string"}},"fields":["address-line","city","postal-code"],"id":"facility-address","operation":"patch","referenceSources":{},"requiredFields":["address-line","city","postal-code"],"targetFromInput":"facility","targetRecordType":"facility"}]},"id":"correct-address","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-address"],"route":"/v1/actions/correct-address/proposals","targetUses":[{"conditionRequired":true,"fields":["address-line","city","postal-code"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["address-line","status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"deactivateFacility","commitEvidence":[],"definitionRevision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"effects":[{"dependsOn":[],"id":"facility-status","mutations":[{"field":"status","kind":"set","value":{"kind":"literal","value":"inactive"}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"mode":"manual"},"attachments":{},"permissions":[{"actorKind":null,"default":false,"operations":["get","list","apply"],"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"party":"owner","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":[],"readableContextFields":[],"readableInputs":["facility"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null}},"id":"deactivate-facility","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-status"],"route":"/v1/actions/deactivate-facility/proposals","targetUses":[{"conditionRequired":true,"fields":["status"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"registerFacility","commitEvidence":[],"definitionRevision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"effects":[{"dependsOn":[],"id":"facility","mutations":[{"field":"address-line","kind":"set","value":{"input":"address-line","kind":"from-input"}},{"field":"city","kind":"set","value":{"input":"city","kind":"from-input"}},{"field":"facility-code","kind":"set","value":{"input":"facility-code","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}},{"field":"postal-code","kind":"set","value":{"input":"postal-code","kind":"from-input"}},{"field":"status","kind":"set","value":{"kind":"literal","value":"active"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility"}},{"dependsOn":["facility"],"id":"assignment","mutations":[{"field":"facility","kind":"set","value":{"effect":"facility","kind":"from-effect","target_entity_id":"facility"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"operator","kind":"set","value":{"input":"operator","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility-assignment"}}],"execution":{"mode":"immediate"},"id":"register-facility","inputs":[{"apiName":"facilityCode","classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","required":true},{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true},{"apiName":"operatorId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"facility-registrar","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:register"],"results":["assignment","facility"],"targets":[{"operation":"create","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"facility","kind":"effect"}},{"operation":"create","recordType":"facility-assignment","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"assignment","kind":"effect"}},{"operation":"get","recordType":"operator","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"operator","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"equalsInput":"jurisdiction","field":"jurisdiction","input":"operator","recordType":"operator","revisionUnchanged":false},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"operator","recordType":"operator","revisionUnchanged":false}],"resultEffects":["assignment","facility"],"route":"/v1/actions/register-facility","targetUses":[{"conditionRequired":false,"fields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"operation":"create","recordType":"facility","source":{"effect":"facility","kind":"effect"}},{"conditionRequired":false,"fields":["facility","jurisdiction","operator"],"operation":"create","recordType":"facility-assignment","source":{"effect":"assignment","kind":"effect"}},{"conditionRequired":false,"fields":["jurisdiction","status"],"operation":"get","recordType":"operator","source":{"input":"operator","kind":"input"}}]}],"routes":[{"accessProfiles":["facility-correction-author"],"actionId":"correct-address","defaultAccessProfile":"facility-correction-author","id":"actions.correct-address.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/correct-address/proposals"},{"accessProfiles":["facility-correction-author"],"actionId":"deactivate-facility","defaultAccessProfile":"facility-correction-author","id":"actions.deactivate-facility.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/deactivate-facility/proposals"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/register-facility"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/register-facility/availability"}]} \ No newline at end of file diff --git a/products/breg/generated/facility/compiled/effective-model.json b/products/breg/generated/facility/compiled/effective-model.json index 81027f504b..56ad7092c9 100644 --- a/products/breg/generated/facility/compiled/effective-model.json +++ b/products/breg/generated/facility/compiled/effective-model.json @@ -1 +1 @@ -{"accessProfiles":[{"display":{},"id":"casework-review-status"},{"display":{},"id":"directory-editor"},{"display":{},"id":"facility-correction-applier"},{"display":{},"id":"facility-correction-author"},{"display":{},"id":"facility-reader"},{"display":{},"id":"facility-registrar"},{"display":{},"id":"operator-editor"},{"display":{},"id":"proposal-reviewer"}],"actionInventory":{"access":[{"actionId":"correct-address","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.correct-address.start"},{"actionId":"deactivate-facility","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.deactivate-facility.start"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.availability"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.invoke"}],"actions":[{"apiName":"correctAddress","commitEvidence":[],"definitionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"effects":[{"dependsOn":[],"id":"facility-address","mutations":[{"field":"address-line","kind":"set","value":{"kind":"literal","value":null}},{"field":"city","kind":"set","value":{"kind":"literal","value":null}},{"field":"postal-code","kind":"set","value":{"kind":"literal","value":null}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{"supporting-document":{"classification":"restricted","contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}},"permissions":[{"actorKind":"service","default":false,"operations":["get-review-status"],"ownership":null,"principalClaim":"registry_principal","profileId":"casework-review-status","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":["casework-service"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review-status"],"reviewAuthority":"casework","targets":[],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","apply"],"ownership":null,"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"ownership":"caller","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":["supporting-document"],"readableContextFields":[],"readableInputs":["address-line","city","facility","postal-code"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":["supporting-document"]},{"actorKind":null,"default":false,"operations":["get-review-context"],"ownership":null,"principalClaim":"registry_principal","profileId":"proposal-reviewer","readableAttachments":[],"readableContextFields":["changes","currentAddressLine","facilityId","supportingDocument"],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"reviewContext":{"fields":{"changes":{"fields":["address-line","city","postal-code"],"recordType":"facility","type":"changes"},"currentAddressLine":{"field":"address-line","input":"facility","type":"record"},"facilityId":{"input":"facility","type":"input"},"supportingDocument":{"slot":"supporting-document","type":"document"}},"id":"facility-address-context"},"systemApplyGrant":{"actionId":"correct-address","actionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","revision":"sha256:b09c24636b3d208832104a44747d02487181ee91ed74305e6fe0db2fba63c6f6","targets":[{"fields":[],"operation":"get","readFields":["address-line","status"],"recordType":"facility"},{"fields":["address-line","city","postal-code"],"operation":"patch","readFields":["address-line","city","postal-code"],"recordType":"facility"}]}}},"handler":{"abi":"registry.action-plan/v1","boundInputs":["address-line","city","facility","postal-code"],"capabilities":[],"entrypoint":"plan","id":"correct-address-plan","kind":"rhai","limits":{"maximumArrayItems":256,"maximumCallDepth":32,"maximumExpressionDepth":64,"maximumMapEntries":256,"maximumModules":0,"maximumOperations":10000,"maximumOutputBytes":8192,"maximumSourceBytes":65536,"maximumStringBytes":16384},"refusals":{"invalid-postal-code":"Postal code is invalid"},"rhaiVersion":"1.27.0","scriptSha256":"sha256:0270538e561991ed35b7fa004f47fd98b744e626bd395fec3f073d61bc02b830","sourceModule":null,"writes":[{"fieldTypes":{"address-line":{"maximumLength":240,"minimumLength":1,"type":"string"},"city":{"maximumLength":120,"minimumLength":1,"type":"string"},"postal-code":{"maximumLength":24,"minimumLength":1,"type":"string"}},"fields":["address-line","city","postal-code"],"id":"facility-address","operation":"patch","referenceSources":{},"requiredFields":["address-line","city","postal-code"],"targetFromInput":"facility","targetRecordType":"facility"}]},"id":"correct-address","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-address"],"route":"/v1/actions/correct-address/proposals","targetUses":[{"conditionRequired":true,"fields":["address-line","city","postal-code"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["address-line","status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"deactivateFacility","commitEvidence":[],"definitionRevision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"effects":[{"dependsOn":[],"id":"facility-status","mutations":[{"field":"status","kind":"set","value":{"kind":"literal","value":"inactive"}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"mode":"manual"},"attachments":{},"permissions":[{"actorKind":null,"default":false,"operations":["get","list","apply"],"ownership":null,"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"ownership":"caller","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":[],"readableContextFields":[],"readableInputs":["facility"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null}},"id":"deactivate-facility","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-status"],"route":"/v1/actions/deactivate-facility/proposals","targetUses":[{"conditionRequired":true,"fields":["status"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"registerFacility","commitEvidence":[],"definitionRevision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"effects":[{"dependsOn":[],"id":"facility","mutations":[{"field":"address-line","kind":"set","value":{"input":"address-line","kind":"from-input"}},{"field":"city","kind":"set","value":{"input":"city","kind":"from-input"}},{"field":"facility-code","kind":"set","value":{"input":"facility-code","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}},{"field":"postal-code","kind":"set","value":{"input":"postal-code","kind":"from-input"}},{"field":"status","kind":"set","value":{"kind":"literal","value":"active"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility"}},{"dependsOn":["facility"],"id":"assignment","mutations":[{"field":"facility","kind":"set","value":{"effect":"facility","kind":"from-effect","target_entity_id":"facility"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"operator","kind":"set","value":{"input":"operator","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility-assignment"}}],"execution":{"mode":"immediate"},"id":"register-facility","inputs":[{"apiName":"facilityCode","classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","required":true},{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true},{"apiName":"operatorId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"facility-registrar","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:register"],"results":["assignment","facility"],"targets":[{"operation":"create","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"facility","kind":"effect"}},{"operation":"create","recordType":"facility-assignment","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"assignment","kind":"effect"}},{"operation":"get","recordType":"operator","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"operator","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"equalsInput":"jurisdiction","field":"jurisdiction","input":"operator","recordType":"operator","revisionUnchanged":false},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"operator","recordType":"operator","revisionUnchanged":false}],"resultEffects":["assignment","facility"],"route":"/v1/actions/register-facility","targetUses":[{"conditionRequired":false,"fields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"operation":"create","recordType":"facility","source":{"effect":"facility","kind":"effect"}},{"conditionRequired":false,"fields":["facility","jurisdiction","operator"],"operation":"create","recordType":"facility-assignment","source":{"effect":"assignment","kind":"effect"}},{"conditionRequired":false,"fields":["jurisdiction","status"],"operation":"get","recordType":"operator","source":{"input":"operator","kind":"input"}}]}],"routes":[{"accessProfiles":["facility-correction-author"],"actionId":"correct-address","defaultAccessProfile":"facility-correction-author","id":"actions.correct-address.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/correct-address/proposals"},{"accessProfiles":["facility-correction-author"],"actionId":"deactivate-facility","defaultAccessProfile":"facility-correction-author","id":"actions.deactivate-facility.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/deactivate-facility/proposals"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/register-facility"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/register-facility/availability"}]},"datasets":[{"display":{"description":"Authoritative facility, operator, assignment, and directory records.","label":"Facility Registry"},"id":"facility-registry"}],"defaultLanguage":"en","display":{"description":"Facilities, operators, assignments, and an administrative directory.","label":"Facility Registry"},"eventDeliveryInventory":{"deliveries":[]},"metadataInventory":{"recordTypes":[{"entries":[{"accessProfile":"directory-editor","operation":"create","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.create"},{"accessProfile":"directory-editor","operation":"get","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.get"},{"accessProfile":"directory-editor","operation":"list","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.list"},{"accessProfile":"directory-editor","operation":"patch","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.patch"}],"id":"directory-entry","route":"directory-entries","schemaPath":"/v1/schemas/directory-entry"},{"entries":[{"accessProfile":"facility-reader","operation":"get","readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"responseRecordType":"facility","routeId":"records.facility.get"},{"accessProfile":"proposal-reviewer","operation":"get","readableFields":["address-line","city","postal-code"],"responseRecordType":"facility","routeId":"records.facility.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"responseRecordType":"facility","routeId":"records.facility.list"},{"accessProfile":"facility-reader","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.facility.path.operators"}],"id":"facility","route":"facilities","schemaPath":"/v1/schemas/facility"},{"entries":[{"accessProfile":"facility-reader","operation":"get","readableFields":["facility","jurisdiction","operator"],"responseRecordType":"facility-assignment","routeId":"records.facility-assignment.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["facility","jurisdiction","operator"],"responseRecordType":"facility-assignment","routeId":"records.facility-assignment.list"}],"id":"facility-assignment","route":"facility-assignments","schemaPath":"/v1/schemas/facility-assignment"},{"entries":[{"accessProfile":"operator-editor","operation":"create","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.create"},{"accessProfile":"facility-reader","operation":"get","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.get"},{"accessProfile":"operator-editor","operation":"get","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.list"},{"accessProfile":"operator-editor","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.list"},{"accessProfile":"operator-editor","operation":"patch","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.patch"}],"id":"operator","route":"operators","schemaPath":"/v1/schemas/operator"}],"registryId":"facility-registry","version":"0.1.0"},"moduleClosure":[],"moduleOrder":[],"physicalNames":{"entities":{"directory-entry":{"constraints":{},"fields":{"email":"breg_f_directory_entry_email_52312bfceceb72d2","jurisdiction":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","name":"breg_f_directory_entry_name_670ab7df6d39437e"},"indexes":{},"policies":{"directory-editor":"breg_p_directory_entry_directory_editor_38223c6ec8ba725e"},"table":"breg_e_directory_entry_7749c98ffacfd2fa"},"facility":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_facility_03fcee9becbbddde"},"fields":{"address-line":"breg_f_facility_address_line_9fdc255005a3f27d","city":"breg_f_facility_city_6448672b8c1dc624","facility-code":"breg_f_facility_facility_code_fcdd21b7440c580b","jurisdiction":"breg_f_facility_jurisdiction_3f30c6f43d727a01","name":"breg_f_facility_name_dd4952476d0a98c0","postal-code":"breg_f_facility_postal_code_ea103f5772628647","status":"breg_f_facility_status_9d25f0af6dd3af59"},"indexes":{},"policies":{"facility-reader":"breg_p_facility_facility_reader_7f2e27daae49a934","proposal-reviewer":"breg_p_facility_proposal_reviewer_f78b1d9607a4f6d4"},"table":"breg_e_facility_675cdbdae206c49c"},"facility-assignment":{"constraints":{"active-reference:facility":"breg_ar_facility_assignment_facility_a0769507dc779efd","active-reference:operator":"breg_ar_facility_assignment_operator_07b723ba3f193078","reference:facility":"breg_r_facility_assignment_facility_395a42a8ee07d1c8","reference:operator":"breg_r_facility_assignment_operator_77d7314e67a83fc3"},"fields":{"facility":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","jurisdiction":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","operator":"breg_f_facility_assignment_operator_a1c886577b591b54"},"indexes":{"by-facility":"breg_i_facility_assignment_by_facility_50c129597b44ca5e","by-operator":"breg_i_facility_assignment_by_operator_4dd9f29e7dd262f7"},"policies":{"facility-reader":"breg_p_facility_assignment_facility_reader_5aa4a0dfad5c32ff"},"table":"breg_e_facility_assignment_4204e7def2a858e1"},"operator":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_operator_1dd7541ac167e817"},"fields":{"jurisdiction":"breg_f_operator_jurisdiction_dbc56c1b79599a92","operator-code":"breg_f_operator_operator_code_3694ef0a22200362","status":"breg_f_operator_status_270775d5b9b0abba"},"indexes":{},"policies":{"facility-reader":"breg_p_operator_facility_reader_af71ef451ec4ddc5","operator-editor":"breg_p_operator_operator_editor_5c7dd402df93ea5d"},"table":"breg_e_operator_81bd5233dc15cfc8"}}},"queryInventory":{"operations":[{"allowCount":false,"filterFields":[],"id":"records.directory-entry.directory-editor.list","kind":"list","maxPageSize":100,"processingFields":["email","jurisdiction","name"],"profileId":"directory-editor","projectionFields":["email","jurisdiction","name"],"recordType":"directory-entry","routeId":"records.directory-entry.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[{"field":"facility","operators":["equals","in","is-null","is-not-null"]},{"field":"operator","operators":["equals","in","is-null","is-not-null"]}],"id":"records.facility-assignment.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["facility","jurisdiction","operator"],"profileId":"facility-reader","projectionFields":["facility","jurisdiction","operator"],"recordType":"facility-assignment","routeId":"records.facility-assignment.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.facility.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"profileId":"facility-reader","projectionFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"recordType":"facility","routeId":"records.facility.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.facility.facility-reader.path.operators","kind":"list","maxPageSize":100,"processingFields":["facility","jurisdiction","operator","operator-code","status"],"profileId":"facility-reader","projectionFields":["jurisdiction","operator-code","status"],"readPath":"operators","recordType":"operator","routeId":"records.facility.path.operators","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.operator.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["jurisdiction","operator-code","status"],"profileId":"facility-reader","projectionFields":["jurisdiction","operator-code","status"],"recordType":"operator","routeId":"records.operator.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.operator.operator-editor.list","kind":"list","maxPageSize":100,"processingFields":["jurisdiction","operator-code","status"],"profileId":"operator-editor","projectionFields":["jurisdiction","operator-code","status"],"recordType":"operator","routeId":"records.operator.list","sortFields":[],"stableTieBreaker":"record_id"}]},"recordTypes":{"directory-entry":{"accessProfiles":{"directory-editor":{"allowDataExport":false,"default":true,"filterableFields":[],"id":"directory-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["email","jurisdiction","name"],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["email","jurisdiction","name"]}},"apiName":"DirectoryEntry","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:e71d4b035e29425de197e952f1acfc4711d2e9a418b23a038e8fec525740c91b","derivedFields":{},"derivedRelations":{},"display":{"description":"A contact entry maintained through generated record routes.","label":"Directory entry"},"fields":{"email":{"classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_directory_entry_email_52312bfceceb72d2","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","relationship":null,"required":true},"name":{"classification":"public","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_directory_entry_name_670ab7df6d39437e","relationship":null,"required":true}},"hooks":{},"id":"directory-entry","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_directory_entry_7749c98ffacfd2fa","primaryDataset":"facility-registry","readPaths":{},"route":"directory-entries","sourceRelation":{"recordType":"directory-entry","sqlName":"directory_entry","storedFields":["name","email","jurisdiction"]},"storedFields":[{"apiName":"name","classification":"public","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_directory_entry_name_670ab7df6d39437e","required":true,"sqlName":"name"},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_directory_entry_email_52312bfceceb72d2","required":true,"sqlName":"email"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"facility":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readPaths":[{"allowCount":false,"filterableFields":[],"path":"operators","readableFields":["jurisdiction","operator-code","status"],"sortableFields":[]}],"readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]},"proposal-reviewer":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"proposal-reviewer","operations":["get"],"principalClaim":"registry_principal","readableFields":["address-line","city","postal-code"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]}},"apiName":"Facility","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"changeControl":{"requiredFor":["patch"]},"classification":"internal","constraints":{},"definitionRevision":"sha256:79cde2b1615cc8e6c537ec313ab3b9394fae8917b87e651a771caf87b3a6aeca","derivedFields":{},"derivedRelations":{},"display":{"description":"A registered facility whose corrections require a durable Proposal.","label":"Facility","titleField":"name"},"fields":{"address-line":{"classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","physicalName":"breg_f_facility_address_line_9fdc255005a3f27d","relationship":null,"required":true},"city":{"classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","physicalName":"breg_f_facility_city_6448672b8c1dc624","relationship":null,"required":true},"facility-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","physicalName":"breg_f_facility_facility_code_fcdd21b7440c580b","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_jurisdiction_3f30c6f43d727a01","relationship":null,"required":true},"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_facility_name_dd4952476d0a98c0","relationship":null,"required":true},"postal-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","physicalName":"breg_f_facility_postal_code_ea103f5772628647","relationship":null,"required":true},"status":{"classification":"internal","display":{},"fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"facility-status"},"id":"status","physicalName":"breg_f_facility_status_9d25f0af6dd3af59","relationship":null,"required":true}},"hooks":{},"id":"facility","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_facility_675cdbdae206c49c","primaryDataset":"facility-registry","readPaths":{"operators":{"id":"operators","route":"operators","sourceRef":"facility","targetRef":"operator","through":"facility-assignment","to":"operator"}},"relationships":{"assignments":{"cardinality":"many","fieldId":"facility","inverse":true,"inverseName":"facility","name":"assignments","readPath":null,"sourceRecordType":"facility","targetRecordType":"facility-assignment"}},"route":"facilities","sourceRelation":{"recordType":"facility","sqlName":"facility","storedFields":["facility-code","name","address-line","city","postal-code","status","jurisdiction"]},"storedFields":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","physicalName":"breg_f_facility_facility_code_fcdd21b7440c580b","required":true,"sqlName":"facility_code"},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_facility_name_dd4952476d0a98c0","required":true,"sqlName":"name"},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","physicalName":"breg_f_facility_address_line_9fdc255005a3f27d","required":true,"sqlName":"address_line"},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","physicalName":"breg_f_facility_city_6448672b8c1dc624","required":true,"sqlName":"city"},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","physicalName":"breg_f_facility_postal_code_ea103f5772628647","required":true,"sqlName":"postal_code"},{"apiName":"status","classification":"internal","fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"facility-status"},"id":"status","physicalName":"breg_f_facility_status_9d25f0af6dd3af59","required":true,"sqlName":"status"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_jurisdiction_3f30c6f43d727a01","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"facility-assignment":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":["facility","operator"],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readableFields":["facility","jurisdiction","operator"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]}},"apiName":"FacilityAssignment","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:c96af95e58e87cae1572a6d53b9442216103af7f0941a32322e6dc82a067632a","derivedFields":{},"derivedRelations":{},"display":{"description":"The operator assigned when a facility is registered.","label":"Facility assignment"},"fields":{"facility":{"classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","physicalName":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","relationship":{"inverseName":"assignments"},"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","relationship":null,"required":true},"operator":{"classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","physicalName":"breg_f_facility_assignment_operator_a1c886577b591b54","relationship":{"inverseName":"facilityAssignments"},"required":true}},"hooks":{},"id":"facility-assignment","indexes":{"by-facility":["facility"],"by-operator":["operator"]},"lookups":{},"mutationMode":"create-only","physicalTable":"breg_e_facility_assignment_4204e7def2a858e1","primaryDataset":"facility-registry","readPaths":{},"relationships":{"facility":{"cardinality":"one","fieldId":"facility","inverse":false,"inverseName":"assignments","name":"facility","readPath":null,"sourceRecordType":"facility-assignment","targetRecordType":"facility"},"operator":{"cardinality":"one","fieldId":"operator","inverse":false,"inverseName":"facilityAssignments","name":"operator","readPath":null,"sourceRecordType":"facility-assignment","targetRecordType":"operator"}},"route":"facility-assignments","sourceRelation":{"recordType":"facility-assignment","sqlName":"facility_assignment","storedFields":["facility","operator","jurisdiction"]},"storedFields":[{"apiName":"facility","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","physicalName":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","required":true,"sqlName":"facility"},{"apiName":"operator","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","physicalName":"breg_f_facility_assignment_operator_a1c886577b591b54","required":true,"sqlName":"operator"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"operator":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readableFields":["jurisdiction","operator-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]},"operator-editor":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"operator-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["jurisdiction","operator-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:operator:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["jurisdiction","operator-code","status"]}},"apiName":"Operator","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:53fe18fc724aed52600ba3b4a34502bbfb84c24e0cb819c6f5608eb6ee8fa471","derivedFields":{},"derivedRelations":{},"display":{"description":"An organization permitted to operate a facility.","label":"Operator","titleField":"operator-code"},"fields":{"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_operator_jurisdiction_dbc56c1b79599a92","relationship":null,"required":true},"operator-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"operator-code","physicalName":"breg_f_operator_operator_code_3694ef0a22200362","relationship":null,"required":true},"status":{"classification":"internal","display":{},"fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"operator-status"},"id":"status","physicalName":"breg_f_operator_status_270775d5b9b0abba","relationship":null,"required":true}},"hooks":{},"id":"operator","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_operator_81bd5233dc15cfc8","primaryDataset":"facility-registry","readPaths":{},"relationships":{"facilityAssignments":{"cardinality":"many","fieldId":"operator","inverse":true,"inverseName":"operator","name":"facilityAssignments","readPath":null,"sourceRecordType":"operator","targetRecordType":"facility-assignment"}},"route":"operators","sourceRelation":{"recordType":"operator","sqlName":"operator","storedFields":["operator-code","status","jurisdiction"]},"storedFields":[{"apiName":"operatorCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"operator-code","physicalName":"breg_f_operator_operator_code_3694ef0a22200362","required":true,"sqlName":"operator_code"},{"apiName":"status","classification":"internal","fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"operator-status"},"id":"status","physicalName":"breg_f_operator_status_270775d5b9b0abba","required":true,"sqlName":"status"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_operator_jurisdiction_dbc56c1b79599a92","required":true,"sqlName":"jurisdiction"}],"tombstone":false}},"registryId":"facility-registry","reviewAuthorities":[{"display":{"description":"Logical authenticated review authority resolved by deployment configuration.","label":"Casework review authority"},"id":"casework","protocol":"id.registrystack.org/protocols/review/v1"}],"version":"0.1.0"} \ No newline at end of file +{"accessProfiles":[{"display":{},"id":"casework-review-status"},{"display":{},"id":"directory-editor"},{"display":{},"id":"facility-correction-applier"},{"display":{},"id":"facility-correction-author"},{"display":{},"id":"facility-reader"},{"display":{},"id":"facility-registrar"},{"display":{},"id":"operator-editor"},{"display":{},"id":"proposal-reviewer"}],"actionInventory":{"access":[{"actionId":"correct-address","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.correct-address.start"},{"actionId":"deactivate-facility","defaultProfileId":"facility-correction-author","operation":"start","profileIds":["facility-correction-author"],"routeId":"actions.deactivate-facility.start"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.availability"},{"actionId":"register-facility","defaultProfileId":"facility-registrar","operation":"invoke","profileIds":["facility-registrar"],"routeId":"actions.register-facility.invoke"}],"actions":[{"apiName":"correctAddress","commitEvidence":[],"definitionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"effects":[{"dependsOn":[],"id":"facility-address","mutations":[{"field":"address-line","kind":"set","value":{"kind":"literal","value":null}},{"field":"city","kind":"set","value":{"kind":"literal","value":null}},{"field":"postal-code","kind":"set","value":{"kind":"literal","value":null}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{"supporting-document":{"classification":"restricted","contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}},"permissions":[{"actorKind":"service","default":false,"operations":["get-review-status"],"principalClaim":"registry_principal","profileId":"casework-review-status","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":["casework-service"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review-status"],"reviewAuthority":"casework","targets":[],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","apply"],"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"party":"owner","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":["supporting-document"],"readableContextFields":[],"readableInputs":["address-line","city","facility","postal-code"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":["supporting-document"]},{"actorKind":null,"default":false,"operations":["get-review-context"],"principalClaim":"registry_principal","profileId":"proposal-reviewer","readableAttachments":[],"readableContextFields":["changes","currentAddressLine","facilityId","supportingDocument"],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"reviewContext":{"fields":{"changes":{"fields":["address-line","city","postal-code"],"recordType":"facility","type":"changes"},"currentAddressLine":{"field":"address-line","input":"facility","type":"record"},"facilityId":{"input":"facility","type":"input"},"supportingDocument":{"slot":"supporting-document","type":"document"}},"id":"facility-address-context"},"systemApplyGrant":{"actionId":"correct-address","actionRevision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","revision":"sha256:b09c24636b3d208832104a44747d02487181ee91ed74305e6fe0db2fba63c6f6","targets":[{"fields":[],"operation":"get","readFields":["address-line","status"],"recordType":"facility"},{"fields":["address-line","city","postal-code"],"operation":"patch","readFields":["address-line","city","postal-code"],"recordType":"facility"}]}}},"handler":{"abi":"registry.action-plan/v1","boundInputs":["address-line","city","facility","postal-code"],"capabilities":[],"entrypoint":"plan","id":"correct-address-plan","kind":"rhai","limits":{"maximumArrayItems":256,"maximumCallDepth":32,"maximumExpressionDepth":64,"maximumMapEntries":256,"maximumModules":0,"maximumOperations":10000,"maximumOutputBytes":8192,"maximumSourceBytes":65536,"maximumStringBytes":16384},"refusals":{"invalid-postal-code":"Postal code is invalid"},"rhaiVersion":"1.27.0","scriptSha256":"sha256:0270538e561991ed35b7fa004f47fd98b744e626bd395fec3f073d61bc02b830","sourceModule":null,"writes":[{"fieldTypes":{"address-line":{"maximumLength":240,"minimumLength":1,"type":"string"},"city":{"maximumLength":120,"minimumLength":1,"type":"string"},"postal-code":{"maximumLength":24,"minimumLength":1,"type":"string"}},"fields":["address-line","city","postal-code"],"id":"facility-address","operation":"patch","referenceSources":{},"requiredFields":["address-line","city","postal-code"],"targetFromInput":"facility","targetRecordType":"facility"}]},"id":"correct-address","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-address"],"route":"/v1/actions/correct-address/proposals","targetUses":[{"conditionRequired":true,"fields":["address-line","city","postal-code"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["address-line","status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"deactivateFacility","commitEvidence":[],"definitionRevision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"effects":[{"dependsOn":[],"id":"facility-status","mutations":[{"field":"status","kind":"set","value":{"kind":"literal","value":"inactive"}}],"operation":"patch","target":{"binding":{"input":"facility","kind":"existing"},"recordType":"facility"}}],"execution":{"mode":"proposal","proposal":{"application":{"mode":"manual"},"attachments":{},"permissions":[{"actorKind":null,"default":false,"operations":["get","list","apply"],"principalClaim":"registry_principal","profileId":"facility-correction-applier","readableAttachments":[],"readableContextFields":[],"readableInputs":[],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:apply"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]},{"actorKind":null,"default":false,"operations":["get","list","edit","submit","revise","cancel","rebase","retry","get-review-status"],"party":"owner","principalClaim":"registry_principal","profileId":"facility-correction-author","readableAttachments":[],"readableContextFields":[],"readableInputs":["facility"],"requesterClients":[],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"targets":[{"recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null}},"id":"deactivate-facility","inputs":[{"apiName":"facilityId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["start"],"principalClaim":"registry_principal","profileId":"facility-correction-author","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:correction:submit"],"results":[],"targets":[{"operation":"patch","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}},{"operation":"get","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"facility","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"field":"","input":"facility","recordType":"facility","revisionUnchanged":true},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"facility","recordType":"facility","revisionUnchanged":false}],"resultEffects":["facility-status"],"route":"/v1/actions/deactivate-facility/proposals","targetUses":[{"conditionRequired":true,"fields":["status"],"operation":"patch","recordType":"facility","source":{"input":"facility","kind":"input"}},{"conditionRequired":false,"fields":["status"],"operation":"get","recordType":"facility","source":{"input":"facility","kind":"input"}}]},{"apiName":"registerFacility","commitEvidence":[],"definitionRevision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"effects":[{"dependsOn":[],"id":"facility","mutations":[{"field":"address-line","kind":"set","value":{"input":"address-line","kind":"from-input"}},{"field":"city","kind":"set","value":{"input":"city","kind":"from-input"}},{"field":"facility-code","kind":"set","value":{"input":"facility-code","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}},{"field":"postal-code","kind":"set","value":{"input":"postal-code","kind":"from-input"}},{"field":"status","kind":"set","value":{"kind":"literal","value":"active"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility"}},{"dependsOn":["facility"],"id":"assignment","mutations":[{"field":"facility","kind":"set","value":{"effect":"facility","kind":"from-effect","target_entity_id":"facility"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"operator","kind":"set","value":{"input":"operator","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"facility-assignment"}}],"execution":{"mode":"immediate"},"id":"register-facility","inputs":[{"apiName":"facilityCode","classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","required":true},{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"addressLine","classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","required":true},{"apiName":"city","classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","required":true},{"apiName":"postalCode","classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","required":true},{"apiName":"operatorId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":false,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"facility-registrar","requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:register"],"results":["assignment","facility"],"targets":[{"operation":"create","recordType":"facility","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"facility","kind":"effect"}},{"operation":"create","recordType":"facility-assignment","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"assignment","kind":"effect"}},{"operation":"get","recordType":"operator","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"operator","kind":"input"}}]}],"requires":[{"atLeast":null,"atMost":null,"currentDate":null,"equalsInput":"jurisdiction","field":"jurisdiction","input":"operator","recordType":"operator","revisionUnchanged":false},{"atLeast":null,"atMost":null,"currentDate":null,"equals":"active","field":"status","input":"operator","recordType":"operator","revisionUnchanged":false}],"resultEffects":["assignment","facility"],"route":"/v1/actions/register-facility","targetUses":[{"conditionRequired":false,"fields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"operation":"create","recordType":"facility","source":{"effect":"facility","kind":"effect"}},{"conditionRequired":false,"fields":["facility","jurisdiction","operator"],"operation":"create","recordType":"facility-assignment","source":{"effect":"assignment","kind":"effect"}},{"conditionRequired":false,"fields":["jurisdiction","status"],"operation":"get","recordType":"operator","source":{"input":"operator","kind":"input"}}]}],"routes":[{"accessProfiles":["facility-correction-author"],"actionId":"correct-address","defaultAccessProfile":"facility-correction-author","id":"actions.correct-address.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/correct-address/proposals"},{"accessProfiles":["facility-correction-author"],"actionId":"deactivate-facility","defaultAccessProfile":"facility-correction-author","id":"actions.deactivate-facility.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/deactivate-facility/proposals"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/register-facility"},{"accessProfiles":["facility-registrar"],"actionId":"register-facility","defaultAccessProfile":"facility-registrar","id":"actions.register-facility.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/register-facility/availability"}]},"datasets":[{"display":{"description":"Authoritative facility, operator, assignment, and directory records.","label":"Facility Registry"},"id":"facility-registry"}],"defaultLanguage":"en","display":{"description":"Facilities, operators, assignments, and an administrative directory.","label":"Facility Registry"},"eventDeliveryInventory":{"deliveries":[]},"metadataInventory":{"recordTypes":[{"entries":[{"accessProfile":"directory-editor","operation":"create","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.create"},{"accessProfile":"directory-editor","operation":"get","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.get"},{"accessProfile":"directory-editor","operation":"list","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.list"},{"accessProfile":"directory-editor","operation":"patch","readableFields":["email","jurisdiction","name"],"responseRecordType":"directory-entry","routeId":"records.directory-entry.patch"}],"id":"directory-entry","route":"directory-entries","schemaPath":"/v1/schemas/directory-entry"},{"entries":[{"accessProfile":"facility-reader","operation":"get","readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"responseRecordType":"facility","routeId":"records.facility.get"},{"accessProfile":"proposal-reviewer","operation":"get","readableFields":["address-line","city","postal-code"],"responseRecordType":"facility","routeId":"records.facility.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"responseRecordType":"facility","routeId":"records.facility.list"},{"accessProfile":"facility-reader","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.facility.path.operators"}],"id":"facility","route":"facilities","schemaPath":"/v1/schemas/facility"},{"entries":[{"accessProfile":"facility-reader","operation":"get","readableFields":["facility","jurisdiction","operator"],"responseRecordType":"facility-assignment","routeId":"records.facility-assignment.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["facility","jurisdiction","operator"],"responseRecordType":"facility-assignment","routeId":"records.facility-assignment.list"}],"id":"facility-assignment","route":"facility-assignments","schemaPath":"/v1/schemas/facility-assignment"},{"entries":[{"accessProfile":"operator-editor","operation":"create","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.create"},{"accessProfile":"facility-reader","operation":"get","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.get"},{"accessProfile":"operator-editor","operation":"get","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.get"},{"accessProfile":"facility-reader","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.list"},{"accessProfile":"operator-editor","operation":"list","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.list"},{"accessProfile":"operator-editor","operation":"patch","readableFields":["jurisdiction","operator-code","status"],"responseRecordType":"operator","routeId":"records.operator.patch"}],"id":"operator","route":"operators","schemaPath":"/v1/schemas/operator"}],"registryId":"facility-registry","version":"0.1.0"},"moduleClosure":[],"moduleOrder":[],"physicalNames":{"entities":{"directory-entry":{"constraints":{},"fields":{"email":"breg_f_directory_entry_email_52312bfceceb72d2","jurisdiction":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","name":"breg_f_directory_entry_name_670ab7df6d39437e"},"indexes":{},"policies":{"directory-editor":"breg_p_directory_entry_directory_editor_38223c6ec8ba725e"},"table":"breg_e_directory_entry_7749c98ffacfd2fa"},"facility":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_facility_03fcee9becbbddde"},"fields":{"address-line":"breg_f_facility_address_line_9fdc255005a3f27d","city":"breg_f_facility_city_6448672b8c1dc624","facility-code":"breg_f_facility_facility_code_fcdd21b7440c580b","jurisdiction":"breg_f_facility_jurisdiction_3f30c6f43d727a01","name":"breg_f_facility_name_dd4952476d0a98c0","postal-code":"breg_f_facility_postal_code_ea103f5772628647","status":"breg_f_facility_status_9d25f0af6dd3af59"},"indexes":{},"policies":{"facility-reader":"breg_p_facility_facility_reader_7f2e27daae49a934","proposal-reviewer":"breg_p_facility_proposal_reviewer_f78b1d9607a4f6d4"},"table":"breg_e_facility_675cdbdae206c49c"},"facility-assignment":{"constraints":{"active-reference:facility":"breg_ar_facility_assignment_facility_a0769507dc779efd","active-reference:operator":"breg_ar_facility_assignment_operator_07b723ba3f193078","reference:facility":"breg_r_facility_assignment_facility_395a42a8ee07d1c8","reference:operator":"breg_r_facility_assignment_operator_77d7314e67a83fc3"},"fields":{"facility":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","jurisdiction":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","operator":"breg_f_facility_assignment_operator_a1c886577b591b54"},"indexes":{"by-facility":"breg_i_facility_assignment_by_facility_50c129597b44ca5e","by-operator":"breg_i_facility_assignment_by_operator_4dd9f29e7dd262f7"},"policies":{"facility-reader":"breg_p_facility_assignment_facility_reader_5aa4a0dfad5c32ff"},"table":"breg_e_facility_assignment_4204e7def2a858e1"},"operator":{"constraints":{"active-reference-key:record-lifecycle":"breg_rk_operator_1dd7541ac167e817"},"fields":{"jurisdiction":"breg_f_operator_jurisdiction_dbc56c1b79599a92","operator-code":"breg_f_operator_operator_code_3694ef0a22200362","status":"breg_f_operator_status_270775d5b9b0abba"},"indexes":{},"policies":{"facility-reader":"breg_p_operator_facility_reader_af71ef451ec4ddc5","operator-editor":"breg_p_operator_operator_editor_5c7dd402df93ea5d"},"table":"breg_e_operator_81bd5233dc15cfc8"}}},"queryInventory":{"operations":[{"allowCount":false,"filterFields":[],"id":"records.directory-entry.directory-editor.list","kind":"list","maxPageSize":100,"processingFields":["email","jurisdiction","name"],"profileId":"directory-editor","projectionFields":["email","jurisdiction","name"],"recordType":"directory-entry","routeId":"records.directory-entry.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[{"field":"facility","operators":["equals","in","is-null","is-not-null"]},{"field":"operator","operators":["equals","in","is-null","is-not-null"]}],"id":"records.facility-assignment.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["facility","jurisdiction","operator"],"profileId":"facility-reader","projectionFields":["facility","jurisdiction","operator"],"recordType":"facility-assignment","routeId":"records.facility-assignment.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.facility.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"profileId":"facility-reader","projectionFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"recordType":"facility","routeId":"records.facility.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.facility.facility-reader.path.operators","kind":"list","maxPageSize":100,"processingFields":["facility","jurisdiction","operator","operator-code","status"],"profileId":"facility-reader","projectionFields":["jurisdiction","operator-code","status"],"readPath":"operators","recordType":"operator","routeId":"records.facility.path.operators","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.operator.facility-reader.list","kind":"list","maxPageSize":100,"processingFields":["jurisdiction","operator-code","status"],"profileId":"facility-reader","projectionFields":["jurisdiction","operator-code","status"],"recordType":"operator","routeId":"records.operator.list","sortFields":[],"stableTieBreaker":"record_id"},{"allowCount":false,"filterFields":[],"id":"records.operator.operator-editor.list","kind":"list","maxPageSize":100,"processingFields":["jurisdiction","operator-code","status"],"profileId":"operator-editor","projectionFields":["jurisdiction","operator-code","status"],"recordType":"operator","routeId":"records.operator.list","sortFields":[],"stableTieBreaker":"record_id"}]},"recordTypes":{"directory-entry":{"accessProfiles":{"directory-editor":{"allowDataExport":false,"default":true,"filterableFields":[],"id":"directory-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["email","jurisdiction","name"],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["email","jurisdiction","name"]}},"apiName":"DirectoryEntry","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:e71d4b035e29425de197e952f1acfc4711d2e9a418b23a038e8fec525740c91b","derivedFields":{},"derivedRelations":{},"display":{"description":"A contact entry maintained through generated record routes.","label":"Directory entry"},"fields":{"email":{"classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_directory_entry_email_52312bfceceb72d2","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","relationship":null,"required":true},"name":{"classification":"public","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_directory_entry_name_670ab7df6d39437e","relationship":null,"required":true}},"hooks":{},"id":"directory-entry","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_directory_entry_7749c98ffacfd2fa","primaryDataset":"facility-registry","readPaths":{},"route":"directory-entries","sourceRelation":{"recordType":"directory-entry","sqlName":"directory_entry","storedFields":["name","email","jurisdiction"]},"storedFields":[{"apiName":"name","classification":"public","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_directory_entry_name_670ab7df6d39437e","required":true,"sqlName":"name"},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_directory_entry_email_52312bfceceb72d2","required":true,"sqlName":"email"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_directory_entry_jurisdiction_07920d2f3781053a","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"facility":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readPaths":[{"allowCount":false,"filterableFields":[],"path":"operators","readableFields":["jurisdiction","operator-code","status"],"sortableFields":[]}],"readableFields":["address-line","city","facility-code","jurisdiction","name","postal-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]},"proposal-reviewer":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"proposal-reviewer","operations":["get"],"principalClaim":"registry_principal","readableFields":["address-line","city","postal-code"],"requiredPurposes":["facility-review"],"requiredScopes":["registry:proposal:review"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]}},"apiName":"Facility","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"changeControl":{"requiredFor":["patch"]},"classification":"internal","constraints":{},"definitionRevision":"sha256:79cde2b1615cc8e6c537ec313ab3b9394fae8917b87e651a771caf87b3a6aeca","derivedFields":{},"derivedRelations":{},"display":{"description":"A registered facility whose corrections require a durable Proposal.","label":"Facility","titleField":"name"},"fields":{"address-line":{"classification":"internal","display":{},"fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","physicalName":"breg_f_facility_address_line_9fdc255005a3f27d","relationship":null,"required":true},"city":{"classification":"internal","display":{},"fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","physicalName":"breg_f_facility_city_6448672b8c1dc624","relationship":null,"required":true},"facility-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","physicalName":"breg_f_facility_facility_code_fcdd21b7440c580b","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_jurisdiction_3f30c6f43d727a01","relationship":null,"required":true},"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_facility_name_dd4952476d0a98c0","relationship":null,"required":true},"postal-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","physicalName":"breg_f_facility_postal_code_ea103f5772628647","relationship":null,"required":true},"status":{"classification":"internal","display":{},"fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"facility-status"},"id":"status","physicalName":"breg_f_facility_status_9d25f0af6dd3af59","relationship":null,"required":true}},"hooks":{},"id":"facility","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_facility_675cdbdae206c49c","primaryDataset":"facility-registry","readPaths":{"operators":{"id":"operators","route":"operators","sourceRef":"facility","targetRef":"operator","through":"facility-assignment","to":"operator"}},"relationships":{"assignments":{"cardinality":"many","fieldId":"facility","inverse":true,"inverseName":"facility","name":"assignments","readPath":null,"sourceRecordType":"facility","targetRecordType":"facility-assignment"}},"route":"facilities","sourceRelation":{"recordType":"facility","sqlName":"facility","storedFields":["facility-code","name","address-line","city","postal-code","status","jurisdiction"]},"storedFields":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","physicalName":"breg_f_facility_facility_code_fcdd21b7440c580b","required":true,"sqlName":"facility_code"},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_facility_name_dd4952476d0a98c0","required":true,"sqlName":"name"},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","physicalName":"breg_f_facility_address_line_9fdc255005a3f27d","required":true,"sqlName":"address_line"},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","physicalName":"breg_f_facility_city_6448672b8c1dc624","required":true,"sqlName":"city"},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","physicalName":"breg_f_facility_postal_code_ea103f5772628647","required":true,"sqlName":"postal_code"},{"apiName":"status","classification":"internal","fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"facility-status"},"id":"status","physicalName":"breg_f_facility_status_9d25f0af6dd3af59","required":true,"sqlName":"status"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_jurisdiction_3f30c6f43d727a01","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"facility-assignment":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":["facility","operator"],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readableFields":["facility","jurisdiction","operator"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]}},"apiName":"FacilityAssignment","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:c96af95e58e87cae1572a6d53b9442216103af7f0941a32322e6dc82a067632a","derivedFields":{},"derivedRelations":{},"display":{"description":"The operator assigned when a facility is registered.","label":"Facility assignment"},"fields":{"facility":{"classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","physicalName":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","relationship":{"inverseName":"assignments"},"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","relationship":null,"required":true},"operator":{"classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","physicalName":"breg_f_facility_assignment_operator_a1c886577b591b54","relationship":{"inverseName":"facilityAssignments"},"required":true}},"hooks":{},"id":"facility-assignment","indexes":{"by-facility":["facility"],"by-operator":["operator"]},"lookups":{},"mutationMode":"create-only","physicalTable":"breg_e_facility_assignment_4204e7def2a858e1","primaryDataset":"facility-registry","readPaths":{},"relationships":{"facility":{"cardinality":"one","fieldId":"facility","inverse":false,"inverseName":"assignments","name":"facility","readPath":null,"sourceRecordType":"facility-assignment","targetRecordType":"facility"},"operator":{"cardinality":"one","fieldId":"operator","inverse":false,"inverseName":"facilityAssignments","name":"operator","readPath":null,"sourceRecordType":"facility-assignment","targetRecordType":"operator"}},"route":"facility-assignments","sourceRelation":{"recordType":"facility-assignment","sqlName":"facility_assignment","storedFields":["facility","operator","jurisdiction"]},"storedFields":[{"apiName":"facility","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","physicalName":"breg_f_facility_assignment_facility_7e20b6ef1c1e3c53","required":true,"sqlName":"facility"},{"apiName":"operator","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","physicalName":"breg_f_facility_assignment_operator_a1c886577b591b54","required":true,"sqlName":"operator"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_facility_assignment_jurisdiction_3d2151082481a455","required":true,"sqlName":"jurisdiction"}],"tombstone":false},"operator":{"accessProfiles":{"facility-reader":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"facility-reader","operations":["get","list"],"principalClaim":"registry_principal","readableFields":["jurisdiction","operator-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:facility:read"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":[]},"operator-editor":{"allowDataExport":false,"default":false,"filterableFields":[],"id":"operator-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["jurisdiction","operator-code","status"],"requiredPurposes":["facility-administration"],"requiredScopes":["registry:operator:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["jurisdiction","operator-code","status"]}},"apiName":"Operator","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:53fe18fc724aed52600ba3b4a34502bbfb84c24e0cb819c6f5608eb6ee8fa471","derivedFields":{},"derivedRelations":{},"display":{"description":"An organization permitted to operate a facility.","label":"Operator","titleField":"operator-code"},"fields":{"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_operator_jurisdiction_dbc56c1b79599a92","relationship":null,"required":true},"operator-code":{"classification":"internal","display":{},"fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"operator-code","physicalName":"breg_f_operator_operator_code_3694ef0a22200362","relationship":null,"required":true},"status":{"classification":"internal","display":{},"fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"operator-status"},"id":"status","physicalName":"breg_f_operator_status_270775d5b9b0abba","relationship":null,"required":true}},"hooks":{},"id":"operator","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_operator_81bd5233dc15cfc8","primaryDataset":"facility-registry","readPaths":{},"relationships":{"facilityAssignments":{"cardinality":"many","fieldId":"operator","inverse":true,"inverseName":"operator","name":"facilityAssignments","readPath":null,"sourceRecordType":"operator","targetRecordType":"facility-assignment"}},"route":"operators","sourceRelation":{"recordType":"operator","sqlName":"operator","storedFields":["operator-code","status","jurisdiction"]},"storedFields":[{"apiName":"operatorCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"operator-code","physicalName":"breg_f_operator_operator_code_3694ef0a22200362","required":true,"sqlName":"operator_code"},{"apiName":"status","classification":"internal","fieldType":{"type":"vocabulary-code","values":["active","inactive"],"vocabulary":"operator-status"},"id":"status","physicalName":"breg_f_operator_status_270775d5b9b0abba","required":true,"sqlName":"status"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_operator_jurisdiction_dbc56c1b79599a92","required":true,"sqlName":"jurisdiction"}],"tombstone":false}},"registryId":"facility-registry","reviewAuthorities":[{"display":{"description":"Logical authenticated review authority resolved by deployment configuration.","label":"Casework review authority"},"id":"casework","protocol":"id.registrystack.org/protocols/review/v1"}],"version":"0.1.0"} \ No newline at end of file diff --git a/products/breg/generated/facility/generated/action-contracts.json b/products/breg/generated/facility/generated/action-contracts.json index c620b424d1..8f34ba5f26 100644 --- a/products/breg/generated/facility/generated/action-contracts.json +++ b/products/breg/generated/facility/generated/action-contracts.json @@ -1 +1 @@ -{"actions":[{"application":{"maximumAttempts":3,"mode":"automatic"},"display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"id":"correct-address","input":{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"revision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a"},{"application":{"mode":"manual"},"display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"id":"deactivate-facility","input":{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"type":"none"},"revision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d"},{"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"id":"register-facility","input":{"$id":"urn:breg:action:register-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-facility","x-registry-requiredConditionKeys":[]},"mode":"immediate","output":{"$id":"urn:breg:action:register-facility:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"register-facility"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"assignment":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility-assignment"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"facility":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["assignment","facility"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6"}],"apiVersion":"id.registrystack.org/formats/breg/action-contracts/v1","kind":"BRegActionContracts"} \ No newline at end of file +{"actions":[{"application":{"maximumAttempts":3,"mode":"automatic"},"display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"id":"correct-address","input":{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"authority":"casework","policy":{"id":"facility-address-review"},"source":"facility-registry","type":"required"},"revision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a"},{"application":{"mode":"manual"},"display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"id":"deactivate-facility","input":{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"type":"none"},"revision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d"},{"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"id":"register-facility","input":{"$id":"urn:breg:action:register-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-facility","x-registry-requiredConditionKeys":[]},"mode":"immediate","output":{"$id":"urn:breg:action:register-facility:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"register-facility"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"assignment":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility-assignment"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"facility":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["assignment","facility"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6"}],"apiVersion":"id.registrystack.org/formats/breg/action-contracts/v1","kind":"BRegActionContracts"} \ No newline at end of file diff --git a/products/breg/generated/facility/generated/action-schemas/correct-address.invoke.response.schema.json b/products/breg/generated/facility/generated/action-schemas/correct-address.invoke.response.schema.json index fbfdbff5d7..bf1a56ee36 100644 --- a/products/breg/generated/facility/generated/action-schemas/correct-address.invoke.response.schema.json +++ b/products/breg/generated/facility/generated/action-schemas/correct-address.invoke.response.schema.json @@ -1 +1 @@ -{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file +{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file diff --git a/products/breg/generated/facility/generated/action-schemas/deactivate-facility.invoke.response.schema.json b/products/breg/generated/facility/generated/action-schemas/deactivate-facility.invoke.response.schema.json index fbfdbff5d7..bf1a56ee36 100644 --- a/products/breg/generated/facility/generated/action-schemas/deactivate-facility.invoke.response.schema.json +++ b/products/breg/generated/facility/generated/action-schemas/deactivate-facility.invoke.response.schema.json @@ -1 +1 @@ -{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file +{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file diff --git a/products/breg/generated/facility/generated/openapi.json b/products/breg/generated/facility/generated/openapi.json index c5b9c11715..e88bfd9a52 100644 --- a/products/breg/generated/facility/generated/openapi.json +++ b/products/breg/generated/facility/generated/openapi.json @@ -1 +1 @@ -{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.rejected","proposal.review-result-mismatch","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-correct-address-invoke-input":{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},"action-correct-address-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-deactivate-facility-invoke-input":{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},"action-deactivate-facility-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-register-facility-availability-input":{"$id":"urn:breg:action:register-facility:availability-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"oneOf":[{"properties":{"input":{"properties":{"operatorId":{"format":"uuid","type":"string"}},"required":["operatorId"]},"targetInput":{"const":"operatorId"}}}],"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"},"targetInput":{"enum":["operatorId"],"type":"string"}},"required":["targetInput","input"],"type":"object","x-registry-action":"register-facility"},"action-register-facility-availability-response":{"$id":"urn:breg:action:register-facility:availability-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"availability":{"oneOf":[{"additionalProperties":false,"properties":{"available":{"const":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"}},"required":["available","observedRevision"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"const":false},"guardLabel":{"maxLength":256,"minLength":1,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"guard-not-satisfied"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"missingInputs":{"items":{"enum":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"string"},"minItems":1,"type":"array","uniqueItems":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"input-required"},"recovery":{"const":"correct-input"}},"required":["available","observedRevision","reason","recovery","missingInputs"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"observedRevision":{"type":"null"},"reason":{"const":"not-disclosed"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"}]}},"required":["availability"],"type":"object","x-registry-action":"register-facility"},"action-register-facility-invoke-input":{"$id":"urn:breg:action:register-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-facility","x-registry-requiredConditionKeys":[]},"action-register-facility-invoke-response":{"$id":"urn:breg:action:register-facility:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"register-facility"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"assignment":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility-assignment"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"facility":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["assignment","facility"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"directory-entry":{"$id":"urn:breg:record-type:directory-entry","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"directory-entry-create-input":{"$id":"urn:breg:record-type:directory-entry:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"facility":{"$id":"urn:breg:record-type:facility","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"required":["facilityCode","name","addressLine","city","postalCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable","x-registry-mutationPolicy":{"patch":"proposal-required"}},"facility-assignment":{"$id":"urn:breg:record-type:facility-assignment","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"required":["facility","operator","jurisdiction"],"type":"object","x-registry-mutationMode":"create-only"},"operator":{"$id":"urn:breg:record-type:operator","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"required":["operatorCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"operator-create-input":{"$id":"urn:breg:record-type:operator:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"required":["operatorCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"facility-registry","version":"0.1.0"},"openapi":"3.1.0","paths":{"/v1/actions/correct-address/proposals":{"post":{"operationId":"actions.correct-address.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-address-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-address-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-correction-author"],"x-registry-action":{"access":{"accessProfiles":["facility-correction-author"]},"apiName":"correctAddress","attachments":[{"contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"execution":{"application":"automatic","mode":"proposal","review":"required"},"id":"correct-address","inputMode":"handler","inputs":[{"apiName":"facilityId","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","label":"facilityId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}}],"maximumInputStringBytes":16384,"referenceInputs":[{"apiName":"facilityId","input":"facility","targetRecordType":"facility"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility-address","operation":"patch","recordType":"facility"}],"revision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","route":"/v1/actions/correct-address/proposals","routes":{"availability":null,"start":{"inputSchema":"action-correct-address-invoke-input","method":"POST","operationId":"actions.correct-address.start","path":"/v1/actions/correct-address/proposals","requiresIdempotencyKey":true,"responseSchema":"action-correct-address-invoke-response"}}},"x-registry-defaultAccessProfile":"facility-correction-author","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/deactivate-facility/proposals":{"post":{"operationId":"actions.deactivate-facility.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-deactivate-facility-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-deactivate-facility-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-correction-author"],"x-registry-action":{"access":{"accessProfiles":["facility-correction-author"]},"apiName":"deactivateFacility","attachments":[],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"execution":{"application":"manual","mode":"proposal","review":"none"},"id":"deactivate-facility","inputMode":"fixed","inputs":[{"apiName":"facilityId","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","label":"facilityId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"facilityId","input":"facility","targetRecordType":"facility"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility-status","operation":"patch","recordType":"facility"}],"revision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","route":"/v1/actions/deactivate-facility/proposals","routes":{"availability":null,"start":{"inputSchema":"action-deactivate-facility-invoke-input","method":"POST","operationId":"actions.deactivate-facility.start","path":"/v1/actions/deactivate-facility/proposals","requiresIdempotencyKey":true,"responseSchema":"action-deactivate-facility-invoke-response"}}},"x-registry-defaultAccessProfile":"facility-correction-author","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/register-facility":{"post":{"operationId":"actions.register-facility.invoke","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-invoke-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-invoke-response"}}},"description":"Immediate action committed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-registrar"],"x-registry-action":{"access":{"accessProfiles":["facility-registrar"]},"apiName":"registerFacility","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":null,"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"execution":{"mode":"immediate"},"id":"register-facility","inputMode":"fixed","inputs":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","label":"facilityCode","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":1,"type":"string"}},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":200,"minLength":1,"type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}},{"apiName":"operatorId","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","label":"operatorId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"operatorId","input":"operator","targetRecordType":"operator"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility","operation":"create","recordType":"facility"},{"effect":"assignment","operation":"create","recordType":"facility-assignment"}],"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","route":"/v1/actions/register-facility","routes":{"availability":{"inputSchema":"action-register-facility-availability-input","method":"POST","operationId":"actions.register-facility.availability","path":"/v1/actions/register-facility/availability","requiresIdempotencyKey":false,"responseSchema":"action-register-facility-availability-response"},"invoke":{"inputSchema":"action-register-facility-invoke-input","method":"POST","operationId":"actions.register-facility.invoke","path":"/v1/actions/register-facility","requiresIdempotencyKey":true,"responseSchema":"action-register-facility-invoke-response"},"targetConditions":null}},"x-registry-defaultAccessProfile":"facility-registrar","x-registry-operation":"invoke","x-registry-routeKind":"invoke"}},"/v1/actions/register-facility/availability":{"post":{"operationId":"actions.register-facility.availability","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-availability-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-availability-response"}}},"description":"Action availability returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-registrar"],"x-registry-action":{"access":{"accessProfiles":["facility-registrar"]},"apiName":"registerFacility","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":null,"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"execution":{"mode":"immediate"},"id":"register-facility","inputMode":"fixed","inputs":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","label":"facilityCode","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":1,"type":"string"}},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":200,"minLength":1,"type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}},{"apiName":"operatorId","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","label":"operatorId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"operatorId","input":"operator","targetRecordType":"operator"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility","operation":"create","recordType":"facility"},{"effect":"assignment","operation":"create","recordType":"facility-assignment"}],"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","route":"/v1/actions/register-facility","routes":{"availability":{"inputSchema":"action-register-facility-availability-input","method":"POST","operationId":"actions.register-facility.availability","path":"/v1/actions/register-facility/availability","requiresIdempotencyKey":false,"responseSchema":"action-register-facility-availability-response"},"invoke":{"inputSchema":"action-register-facility-invoke-input","method":"POST","operationId":"actions.register-facility.invoke","path":"/v1/actions/register-facility","requiresIdempotencyKey":true,"responseSchema":"action-register-facility-invoke-response"},"targetConditions":null}},"x-registry-defaultAccessProfile":"facility-registrar","x-registry-operation":"invoke","x-registry-routeKind":"availability"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/review-context":{"get":{"description":"One bounded transport exchange under each item's current get-review-context authority. Ordered visible or concealed results; operational failures refuse the whole batch. Maximum response is 8 MiB.","operationId":"proposals.get-review-context-batch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["proposal-reviewer"],"maxLength":128,"type":"string"}},{"description":"One to 100 distinct canonical Proposal UUIDs, in response order.","explode":false,"in":"query","name":"ids","required":true,"schema":{"items":{"format":"uuid","type":"string"},"maxItems":100,"minItems":1,"type":"array","uniqueItems":true},"style":"form"}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"context":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"fields":{"type":"object"},"reference":{"type":"string"}},"required":["reference","contract","fields"],"type":"object"},"effectDigest":{"type":"string"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"},"id":{"format":"uuid","type":"string"},"status":{"const":"visible"}},"required":["id","status","context"],"type":"object"},{"additionalProperties":false,"properties":{"id":{"format":"uuid","type":"string"},"status":{"const":"concealed"}},"required":["id","status"],"type":"object"}]},"maxItems":100,"minItems":1,"type":"array"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["proposal-reviewer"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/{proposal_id}/apply":{"post":{"operationId":"proposals.apply","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"reason":{"description":"Optional application explanation, preserved unchanged. At most 4096 Unicode characters; NUL is refused.","maxLength":4096,"pattern":"^[^\\u0000]*$","type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["submissionVersion","effectDigest"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}},"proposal.review-result-mismatch":{"value":{"code":"proposal.review-result-mismatch","detail":"The current review result does not match the retained approval.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.guard-failed","precondition.failed","proposal.review-result-mismatch"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier"]}},"/v1/proposals/{proposal_id}/attachments/supporting-document":{"delete":{"operationId":"proposals.attachments.supporting-document.delete","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]},"get":{"operationId":"proposals.attachments.supporting-document.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author","proposal-reviewer"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"query","name":"submissionVersion","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"reviewContextField","required":false,"schema":{"pattern":"^[a-z][a-zA-Z0-9]{0,63}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"effectDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"contextSchemaDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}}],"responses":{"200":{"content":{"*/*":{"schema":{"contentMediaType":"application/octet-stream","maxLength":16777216,"type":"string"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author","proposal-reviewer"]},"patch":{"operationId":"proposals.attachments.supporting-document.patch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/pdf":{"schema":{"format":"binary","maxLength":1048576,"type":"string"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"413":{"content":{"application/problem+json":{"examples":{"attachment.too-large":{"value":{"code":"attachment.too-large","detail":"The file is larger than the attachment slot accepts.","status":413,"title":"Content Too Large","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.too-large"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"attachment.content-type":{"value":{"code":"attachment.content-type","detail":"The file media type is not one the attachment slot accepts.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.content-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/rebase":{"post":{"operationId":"proposals.rebase","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/retry":{"post":{"operationId":"proposals.retry","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/review-context":{"get":{"operationId":"proposals.get-review-context","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["proposal-reviewer"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Request live applicant answers for a displayed human review context. Admission and preflight reads omit this option and receive no intrinsic asks.","in":"query","name":"include","required":false,"schema":{"const":"answers"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"answeredAt":{"format":"date-time","type":"string"},"documents":{"items":{"additionalProperties":false,"properties":{"byteSize":{"maximum":16777216,"minimum":1,"type":"integer"},"contentType":{"maxLength":255,"type":"string"},"download":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"method":{"const":"GET"},"operation":{"const":"get-review-context"},"path":{"type":"string"}},"required":["method","operation","accessProfile","path"],"type":"object"},"id":{"format":"uuid","type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["id","sha256","contentType","byteSize","verificationStatus"],"type":"object"},"maxItems":32,"type":"array"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["documents","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state"],"type":"object"},"maxItems":50,"type":"array"},"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"fields":{"type":"object"},"reference":{"type":"string"}},"required":["reference","contract","fields"],"type":"object"},"effectDigest":{"type":"string"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["proposal-reviewer"]}},"/v1/proposals/{proposal_id}/review-status":{"get":{"operationId":"proposals.get-review-status","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["casework-review-status","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Request the institution's optional applicant-visible progress code. The code is returned only when the selected caller-owned grant enables readableReviewProgress.","in":"query","name":"include","required":false,"schema":{"const":"progress"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"reference":{"type":"string"}},"required":["reference"],"type":"object"},"effectDigest":{"type":"string"},"handoff":{"additionalProperties":false,"properties":{"reason":{"enum":["remote-refused","producer-identity-mismatch","review-acceptance-changed","review-policy-changed","submission-recovery-expired","operator-closed","unspecified"]},"state":{"enum":["pending","accepted","failed","withdrawn"]}},"required":["state"],"type":"object"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"progressCode":{"description":"Institution-defined applicant-visible progress. Absent when the institution conceals the current stage, progress was not requested or granted, the provider is unavailable, or the accepted review round is no longer live.","maxLength":64,"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"requestId":{"format":"uuid","type":"string"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["casework-review-status","facility-correction-author"]}},"/v1/proposals/{proposal_id}/revise":{"post":{"operationId":"proposals.revise","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},{"additionalProperties":false,"type":"object"}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"attachment.verification-pending":{"value":{"code":"attachment.verification-pending","detail":"The attachment is awaiting verification. Refresh the Proposal before submitting.","fieldPath":"/attachments/supporting-document","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}},"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.verification-pending","idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.guard-failed","precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"422":{"content":{"application/problem+json":{"examples":{"action.refused/invalid-postal-code":{"value":{"code":"action.refused","detail":"Postal code is invalid","refusalCode":"invalid-postal-code","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/refused"}},"attachment.verification-rejected":{"value":{"code":"attachment.verification-rejected","detail":"The attachment was rejected by verification. Replace or remove the file before submitting.","fieldPath":"/attachments/supporting-document","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.refused","attachment.verification-rejected"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"500":{"content":{"application/problem+json":{"examples":{"action.handler-failed":{"value":{"code":"action.handler-failed","detail":"The action handler could not produce an accepted result.","status":500,"title":"Internal Server Error","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.handler-failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/records/directory-entries":{"get":{"operationId":"records.directory-entry.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"directory-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"directory-editor","requiredFilters":[],"selectableProperties":["email","jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.directory-entry.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/directory-entry-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"create","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/directory-entries/{record_id}":{"get":{"operationId":"records.directory-entry.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"get","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.directory-entry.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"patch","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/facilities":{"get":{"operationId":"records.facility.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["addressLine","city","facilityCode","jurisdiction","name","postalCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facilities/{record_id}":{"get":{"operationId":"records.facility.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","proposal-reviewer"],"x-registry-operation":"get","x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/facilities/{record_id}/operators":{"get":{"operationId":"records.facility.path.operators","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facility-assignments":{"get":{"operationId":"records.facility-assignment.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[{"operators":["equals","in","is-null","is-not-null"],"property":"facility"},{"operators":["equals","in","is-null","is-not-null"],"property":"operator"}],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["facility","jurisdiction","operator"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility-assignment","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility-assignment","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facility-assignments/{record_id}":{"get":{"operationId":"records.facility-assignment.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"get","x-registry-recordType":"facility-assignment","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility-assignment","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/operators":{"get":{"operationId":"records.operator.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","operator-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null},"operator-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"operator-editor","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.operator.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/operator-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["operator-editor"],"x-registry-operation":"create","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/operators/{record_id}":{"get":{"operationId":"records.operator.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","operator-editor"],"x-registry-operation":"get","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.operator.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["operator-editor"],"x-registry-operation":"patch","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file +{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.form-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached"}}},{"properties":{"code":{"const":"proposal.form-undeclared"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared"}}},{"properties":{"code":{"const":"proposal.message-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.subject-changed"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},{"properties":{"code":{"const":"proposal.subject-not-caller"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.form-limit-reached","proposal.form-undeclared","proposal.message-limit-reached","proposal.rejected","proposal.review-result-mismatch","proposal.subject-changed","proposal.subject-not-caller","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-correct-address-invoke-input":{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},"action-correct-address-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-deactivate-facility-invoke-input":{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},"action-deactivate-facility-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-register-facility-availability-input":{"$id":"urn:breg:action:register-facility:availability-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"oneOf":[{"properties":{"input":{"properties":{"operatorId":{"format":"uuid","type":"string"}},"required":["operatorId"]},"targetInput":{"const":"operatorId"}}}],"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"},"targetInput":{"enum":["operatorId"],"type":"string"}},"required":["targetInput","input"],"type":"object","x-registry-action":"register-facility"},"action-register-facility-availability-response":{"$id":"urn:breg:action:register-facility:availability-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"availability":{"oneOf":[{"additionalProperties":false,"properties":{"available":{"const":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"}},"required":["available","observedRevision"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"const":false},"guardLabel":{"maxLength":256,"minLength":1,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"guard-not-satisfied"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"missingInputs":{"items":{"enum":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"string"},"minItems":1,"type":"array","uniqueItems":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"input-required"},"recovery":{"const":"correct-input"}},"required":["available","observedRevision","reason","recovery","missingInputs"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"observedRevision":{"type":"null"},"reason":{"const":"not-disclosed"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"}]}},"required":["availability"],"type":"object","x-registry-action":"register-facility"},"action-register-facility-invoke-input":{"$id":"urn:breg:action:register-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"operatorId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":["facilityCode","name","addressLine","city","postalCode","operatorId","jurisdiction"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-facility","x-registry-requiredConditionKeys":[]},"action-register-facility-invoke-response":{"$id":"urn:breg:action:register-facility:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"register-facility"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"assignment":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility-assignment"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"facility":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"facility"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["assignment","facility"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"directory-entry":{"$id":"urn:breg:record-type:directory-entry","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"directory-entry-create-input":{"$id":"urn:breg:record-type:directory-entry:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"facility":{"$id":"urn:breg:record-type:facility","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"required":["facilityCode","name","addressLine","city","postalCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable","x-registry-mutationPolicy":{"patch":"proposal-required"}},"facility-assignment":{"$id":"urn:breg:record-type:facility-assignment","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"required":["facility","operator","jurisdiction"],"type":"object","x-registry-mutationMode":"create-only"},"operator":{"$id":"urn:breg:record-type:operator","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"required":["operatorCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"operator-create-input":{"$id":"urn:breg:record-type:operator:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"required":["operatorCode","status","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"facility-registry","version":"0.1.0"},"openapi":"3.1.0","paths":{"/v1/actions/correct-address/proposals":{"post":{"operationId":"actions.correct-address.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-address-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-address-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-correction-author"],"x-registry-action":{"access":{"accessProfiles":["facility-correction-author"]},"apiName":"correctAddress","attachments":[{"contentTypes":["application/pdf"],"id":"supporting-document","maximumBytes":1048576,"required":false}],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Submit a frozen address correction for independent review and later application.","label":"Correct facility address"},"execution":{"application":"automatic","mode":"proposal","review":"required"},"id":"correct-address","inputMode":"handler","inputs":[{"apiName":"facilityId","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","label":"facilityId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}}],"maximumInputStringBytes":16384,"referenceInputs":[{"apiName":"facilityId","input":"facility","targetRecordType":"facility"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility-address","operation":"patch","recordType":"facility"}],"revision":"sha256:efb20d40704ae6c133b660f2fe3d556b4a00ee5478a5871cf1fd026e7d7b6b7a","route":"/v1/actions/correct-address/proposals","routes":{"availability":null,"start":{"inputSchema":"action-correct-address-invoke-input","method":"POST","operationId":"actions.correct-address.start","path":"/v1/actions/correct-address/proposals","requiresIdempotencyKey":true,"responseSchema":"action-correct-address-invoke-response"}}},"x-registry-defaultAccessProfile":"facility-correction-author","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/deactivate-facility/proposals":{"post":{"operationId":"actions.deactivate-facility.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-deactivate-facility-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-deactivate-facility-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-correction-author"],"x-registry-action":{"access":{"accessProfiles":["facility-correction-author"]},"apiName":"deactivateFacility","attachments":[],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Submit a durable deactivation that requires no external review.","label":"Deactivate facility"},"execution":{"application":"manual","mode":"proposal","review":"none"},"id":"deactivate-facility","inputMode":"fixed","inputs":[{"apiName":"facilityId","classification":"internal","fieldType":{"onDelete":"restrict","target":"facility","type":"reference"},"id":"facility","label":"facilityId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"facilityId","input":"facility","targetRecordType":"facility"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility-status","operation":"patch","recordType":"facility"}],"revision":"sha256:9237300ee419a0014c3b123cc7ac90eb9623cb4c45bba4a65c03936083299f1d","route":"/v1/actions/deactivate-facility/proposals","routes":{"availability":null,"start":{"inputSchema":"action-deactivate-facility-invoke-input","method":"POST","operationId":"actions.deactivate-facility.start","path":"/v1/actions/deactivate-facility/proposals","requiresIdempotencyKey":true,"responseSchema":"action-deactivate-facility-invoke-response"}}},"x-registry-defaultAccessProfile":"facility-correction-author","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/register-facility":{"post":{"operationId":"actions.register-facility.invoke","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-invoke-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-invoke-response"}}},"description":"Immediate action committed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-registrar"],"x-registry-action":{"access":{"accessProfiles":["facility-registrar"]},"apiName":"registerFacility","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":null,"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"execution":{"mode":"immediate"},"id":"register-facility","inputMode":"fixed","inputs":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","label":"facilityCode","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":1,"type":"string"}},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":200,"minLength":1,"type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}},{"apiName":"operatorId","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","label":"operatorId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"operatorId","input":"operator","targetRecordType":"operator"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility","operation":"create","recordType":"facility"},{"effect":"assignment","operation":"create","recordType":"facility-assignment"}],"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","route":"/v1/actions/register-facility","routes":{"availability":{"inputSchema":"action-register-facility-availability-input","method":"POST","operationId":"actions.register-facility.availability","path":"/v1/actions/register-facility/availability","requiresIdempotencyKey":false,"responseSchema":"action-register-facility-availability-response"},"invoke":{"inputSchema":"action-register-facility-invoke-input","method":"POST","operationId":"actions.register-facility.invoke","path":"/v1/actions/register-facility","requiresIdempotencyKey":true,"responseSchema":"action-register-facility-invoke-response"},"targetConditions":null}},"x-registry-defaultAccessProfile":"facility-registrar","x-registry-operation":"invoke","x-registry-routeKind":"invoke"}},"/v1/actions/register-facility/availability":{"post":{"operationId":"actions.register-facility.availability","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-availability-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-facility-availability-response"}}},"description":"Action availability returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-registrar"],"x-registry-action":{"access":{"accessProfiles":["facility-registrar"]},"apiName":"registerFacility","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":null,"display":{"description":"Create a facility and its initial operator assignment atomically.","label":"Register facility"},"execution":{"mode":"immediate"},"id":"register-facility","inputMode":"fixed","inputs":[{"apiName":"facilityCode","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":1,"type":"string"},"id":"facility-code","label":"facilityCode","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":1,"type":"string"}},{"apiName":"name","classification":"internal","fieldType":{"maximumLength":200,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":200,"minLength":1,"type":"string"}},{"apiName":"addressLine","classification":"internal","fieldType":{"maximumLength":240,"minimumLength":1,"type":"string"},"id":"address-line","label":"addressLine","nullable":false,"required":true,"schema":{"maxLength":240,"minLength":1,"type":"string"}},{"apiName":"city","classification":"internal","fieldType":{"maximumLength":120,"minimumLength":1,"type":"string"},"id":"city","label":"city","nullable":false,"required":true,"schema":{"maxLength":120,"minLength":1,"type":"string"}},{"apiName":"postalCode","classification":"internal","fieldType":{"maximumLength":24,"minimumLength":1,"type":"string"},"id":"postal-code","label":"postalCode","nullable":false,"required":true,"schema":{"maxLength":24,"minLength":1,"type":"string"}},{"apiName":"operatorId","classification":"internal","fieldType":{"onDelete":"restrict","target":"operator","type":"reference"},"id":"operator","label":"operatorId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"operatorId","input":"operator","targetRecordType":"operator"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"facility","operation":"create","recordType":"facility"},{"effect":"assignment","operation":"create","recordType":"facility-assignment"}],"revision":"sha256:5b5de70fa9b8f831387fc08e520f16fccd71863f18f3efe8b7999728927910f6","route":"/v1/actions/register-facility","routes":{"availability":{"inputSchema":"action-register-facility-availability-input","method":"POST","operationId":"actions.register-facility.availability","path":"/v1/actions/register-facility/availability","requiresIdempotencyKey":false,"responseSchema":"action-register-facility-availability-response"},"invoke":{"inputSchema":"action-register-facility-invoke-input","method":"POST","operationId":"actions.register-facility.invoke","path":"/v1/actions/register-facility","requiresIdempotencyKey":true,"responseSchema":"action-register-facility-invoke-response"},"targetConditions":null}},"x-registry-defaultAccessProfile":"facility-registrar","x-registry-operation":"invoke","x-registry-routeKind":"availability"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/review-context":{"get":{"description":"One bounded transport exchange under each item's current get-review-context authority. Ordered visible or concealed results; operational failures refuse the whole batch. Maximum response is 8 MiB.","operationId":"proposals.get-review-context-batch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["proposal-reviewer"],"maxLength":128,"type":"string"}},{"description":"One to 100 distinct canonical Proposal UUIDs, in response order.","explode":false,"in":"query","name":"ids","required":true,"schema":{"items":{"format":"uuid","type":"string"},"maxItems":100,"minItems":1,"type":"array","uniqueItems":true},"style":"form"}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"context":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"fields":{"type":"object"},"reference":{"type":"string"}},"required":["reference","contract","fields"],"type":"object"},"effectDigest":{"type":"string"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"},"id":{"format":"uuid","type":"string"},"status":{"const":"visible"}},"required":["id","status","context"],"type":"object"},{"additionalProperties":false,"properties":{"id":{"format":"uuid","type":"string"},"status":{"const":"concealed"}},"required":["id","status"],"type":"object"}]},"maxItems":100,"minItems":1,"type":"array"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["proposal-reviewer"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/{proposal_id}/apply":{"post":{"operationId":"proposals.apply","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"reason":{"description":"Optional application explanation, preserved unchanged. At most 4096 Unicode characters; NUL is refused.","maxLength":4096,"pattern":"^[^\\u0000]*$","type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["submissionVersion","effectDigest"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}},"proposal.review-result-mismatch":{"value":{"code":"proposal.review-result-mismatch","detail":"The current review result does not match the retained approval.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.guard-failed","precondition.failed","proposal.review-result-mismatch"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier"]}},"/v1/proposals/{proposal_id}/attachments/supporting-document":{"delete":{"operationId":"proposals.attachments.supporting-document.delete","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]},"get":{"operationId":"proposals.attachments.supporting-document.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author","proposal-reviewer"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"query","name":"submissionVersion","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"reviewContextField","required":false,"schema":{"pattern":"^[a-z][a-zA-Z0-9]{0,63}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"effectDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"contextSchemaDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}}],"responses":{"200":{"content":{"*/*":{"schema":{"contentMediaType":"application/octet-stream","maxLength":16777216,"type":"string"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author","proposal-reviewer"]},"patch":{"operationId":"proposals.attachments.supporting-document.patch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/pdf":{"schema":{"format":"binary","maxLength":1048576,"type":"string"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"413":{"content":{"application/problem+json":{"examples":{"attachment.too-large":{"value":{"code":"attachment.too-large","detail":"The file is larger than the attachment slot accepts.","status":413,"title":"Content Too Large","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.too-large"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"attachment.content-type":{"value":{"code":"attachment.content-type","detail":"The file media type is not one the attachment slot accepts.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.content-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/rebase":{"post":{"operationId":"proposals.rebase","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/retry":{"post":{"operationId":"proposals.retry","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/review-context":{"get":{"operationId":"proposals.get-review-context","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["proposal-reviewer"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Request live applicant answers for a displayed human review context. Admission and preflight reads omit this option and receive no intrinsic asks.","in":"query","name":"include","required":false,"schema":{"const":"answers"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"answeredAt":{"format":"date-time","type":"string"},"documents":{"items":{"additionalProperties":false,"properties":{"byteSize":{"maximum":16777216,"minimum":1,"type":"integer"},"contentType":{"maxLength":255,"type":"string"},"download":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"method":{"const":"GET"},"operation":{"const":"get-review-context"},"path":{"type":"string"}},"required":["method","operation","accessProfile","path"],"type":"object"},"id":{"format":"uuid","type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["id","sha256","contentType","byteSize","verificationStatus"],"type":"object"},"maxItems":32,"type":"array"},"formEntries":{"items":{"additionalProperties":false,"oneOf":[{"not":{"required":["contractChanged"]},"required":["input"]},{"not":{"required":["input"]},"required":["contractChanged"]}],"properties":{"addedAt":{"format":"date-time","type":"string"},"contractChanged":{"const":true},"id":{"format":"uuid","type":"string"},"input":{"maxProperties":16,"minProperties":1,"type":"object"}},"required":["id","addedAt"],"type":"object"},"maxItems":32,"type":"array"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["documents","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state"],"type":"object"},"maxItems":50,"type":"array"},"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"fields":{"type":"object"},"reference":{"type":"string"}},"required":["reference","contract","fields"],"type":"object"},"effectDigest":{"type":"string"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["proposal-reviewer"]}},"/v1/proposals/{proposal_id}/review-status":{"get":{"operationId":"proposals.get-review-status","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["casework-review-status","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Request the institution's optional applicant-visible progress code. The code is returned only when the selected caller-owned grant enables readableReviewProgress.","in":"query","name":"include","required":false,"schema":{"const":"progress"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"authority":{"type":"string"},"context":{"additionalProperties":false,"properties":{"contract":{"additionalProperties":false,"properties":{"id":{"maxLength":2048,"pattern":"^urn:registry:breg:review-context:","type":"string"},"revision":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"schemaDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"}},"required":["id","revision","schemaDigest"],"type":"object"},"reference":{"type":"string"}},"required":["reference"],"type":"object"},"effectDigest":{"type":"string"},"handoff":{"additionalProperties":false,"properties":{"reason":{"enum":["remote-refused","producer-identity-mismatch","review-acceptance-changed","review-policy-changed","submission-recovery-expired","operator-closed","unspecified"]},"state":{"enum":["pending","accepted","failed","withdrawn"]}},"required":["state"],"type":"object"},"id":{"format":"uuid","type":"string"},"policy":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"type":"string"},"version":{"type":"string"}},"required":["id","version","digest"],"type":"object"},"progressCode":{"description":"Institution-defined applicant-visible progress. Absent when the institution conceals the current stage, progress was not requested or granted, the provider is unavailable, or the accepted review round is no longer live.","maxLength":64,"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"requestId":{"format":"uuid","type":"string"},"result":{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},"reviewable":{"type":"boolean"},"revision":{"minimum":1,"type":"integer"},"subject":{"additionalProperties":false,"properties":{"digest":{"type":"string"},"id":{"format":"uuid","type":"string"},"source":{"type":"string"},"subjectType":{"const":"proposal"},"version":{"type":"string"}},"required":["source","subjectType","id","version","digest"],"type":"object"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["id","actionId","actionRevision","submissionVersion","revision","effectDigest","subject","context","reviewable"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["casework-review-status","facility-correction-author"]}},"/v1/proposals/{proposal_id}/revise":{"post":{"operationId":"proposals.revise","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-address:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityId":{"format":"uuid","type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-address","x-registry-requiredConditionKeys":[]},{"$id":"urn:breg:action:deactivate-facility:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"facilityId":{"format":"uuid","type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"deactivate-facility","x-registry-requiredConditionKeys":[]},{"additionalProperties":false,"type":"object"}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-applier","facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-applier","facility-correction-author"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["facility-correction-author"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"proposal.subject-not-caller":{"value":{"code":"proposal.subject-not-caller","detail":"This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized","proposal.subject-not-caller"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"attachment.verification-pending":{"value":{"code":"attachment.verification-pending","detail":"The attachment is awaiting verification. Refresh the Proposal before submitting.","fieldPath":"/attachments/supporting-document","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}},"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}},"proposal.subject-changed":{"value":{"code":"proposal.subject-changed","detail":"The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.verification-pending","idempotency.key-reused","mutation.conflict","proposal.rejected","proposal.subject-changed"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.guard-failed","precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"422":{"content":{"application/problem+json":{"examples":{"action.refused/invalid-postal-code":{"value":{"code":"action.refused","detail":"Postal code is invalid","refusalCode":"invalid-postal-code","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/refused"}},"attachment.verification-rejected":{"value":{"code":"attachment.verification-rejected","detail":"The attachment was rejected by verification. Replace or remove the file before submitting.","fieldPath":"/attachments/supporting-document","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.refused","attachment.verification-rejected"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"500":{"content":{"application/problem+json":{"examples":{"action.handler-failed":{"value":{"code":"action.handler-failed","detail":"The action handler could not produce an accepted result.","status":500,"title":"Internal Server Error","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["action.handler-failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["facility-correction-author"]}},"/v1/records/directory-entries":{"get":{"operationId":"records.directory-entry.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"directory-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"directory-editor","requiredFilters":[],"selectableProperties":["email","jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.directory-entry.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/directory-entry-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"create","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/directory-entries/{record_id}":{"get":{"operationId":"records.directory-entry.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"get","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.directory-entry.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/directory-entry"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"directory-entry"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"patch","x-registry-recordType":"directory-entry","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"directory-entry","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/facilities":{"get":{"operationId":"records.facility.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["addressLine","city","facilityCode","jurisdiction","name","postalCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facilities/{record_id}":{"get":{"operationId":"records.facility.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"addressLine":{"maxLength":240,"minLength":1,"type":"string"},"city":{"maxLength":120,"minLength":1,"type":"string"},"facilityCode":{"maxLength":64,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":200,"minLength":1,"type":"string"},"postalCode":{"maxLength":24,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"facility-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","proposal-reviewer"],"x-registry-operation":"get","x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/facilities/{record_id}/operators":{"get":{"operationId":"records.facility.path.operators","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facility-assignments":{"get":{"operationId":"records.facility-assignment.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[{"operators":["equals","in","is-null","is-not-null"],"property":"facility"},{"operators":["equals","in","is-null","is-not-null"],"property":"operator"}],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["facility","jurisdiction","operator"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"facility-assignment","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility-assignment","x-registry-responseShape":"RegistryRecordCollectionV1"}},"/v1/records/facility-assignments/{record_id}":{"get":{"operationId":"records.facility-assignment.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"facility":{"format":"uuid","type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operator":{"format":"uuid","type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"facility-assignment"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader"],"x-registry-operation":"get","x-registry-recordType":"facility-assignment","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"facility-assignment","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/operators":{"get":{"operationId":"records.operator.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","operator-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"facility-reader":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"facility-reader","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null},"operator-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"operator-editor","requiredFilters":[],"selectableProperties":["jurisdiction","operatorCode","status"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.operator.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/operator-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["operator-editor"],"x-registry-operation":"create","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/operators/{record_id}":{"get":{"operationId":"records.operator.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"operatorCode":{"maxLength":64,"minLength":1,"type":"string"},"status":{"enum":["active","inactive"],"type":"string","x-registry-vocabulary":"operator-status"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["facility-reader","operator-editor"],"x-registry-operation":"get","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.operator.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/operator"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"facility-registry"},"recordTypeId":{"const":"operator"},"registryId":{"const":"facility-registry"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["operator-editor"],"x-registry-operation":"patch","x-registry-recordType":"operator","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"operator","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file From 04793dfd88f6c7e6f990d3e4467d31b4d6260dfc Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 05:32:31 +0000 Subject: [PATCH 39/96] fix(breg): refresh canonical Minimal and journey contracts Signed-off-by: Jeremi Joslin --- .../generated/minimal/compiled/actions.json | 2 +- .../minimal/compiled/effective-model.json | 2 +- .../minimal/generated/action-contracts.json | 2 +- ...gister-contact.invoke.response.schema.json | 2 +- .../generated/minimal/generated/openapi.json | 2 +- .../generated/tools/journeys.v1.schema.json | 55 ++++++++++++++----- 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/products/breg/generated/minimal/compiled/actions.json b/products/breg/generated/minimal/compiled/actions.json index 30360d962b..9d53df7d31 100644 --- a/products/breg/generated/minimal/compiled/actions.json +++ b/products/breg/generated/minimal/compiled/actions.json @@ -1 +1 @@ -{"access":[{"actionId":"register-contact","defaultProfileId":"directory-editor","operation":"start","profileIds":["directory-editor"],"routeId":"actions.register-contact.start"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.availability"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.invoke"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.target-conditions"}],"actions":[{"apiName":"registerContact","commitEvidence":[],"definitionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"effects":[{"dependsOn":[],"id":"contact","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"contact"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{},"permissions":[{"actorKind":null,"default":true,"operations":["get","list","edit","submit","cancel"],"ownership":"caller","principalClaim":"registry_principal","profileId":"directory-editor","readableAttachments":[],"readableContextFields":[],"readableInputs":["email","jurisdiction","name"],"requesterClients":[],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"targets":[{"recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null,"systemApplyGrant":{"actionId":"register-contact","actionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","revision":"sha256:4c7009790caae7d25e3bda52605cdea35d888a5fb7f45bd4b0ac764ccf3ae2ba","targets":[{"fields":["email","jurisdiction","name"],"operation":"create","readFields":["email","jurisdiction","name"],"recordType":"contact"}]}}},"id":"register-contact","inputs":[{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["start"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":[],"targets":[{"operation":"create","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"contact","kind":"effect"}}]}],"resultEffects":["contact"],"route":"/v1/actions/register-contact/proposals","targetUses":[{"conditionRequired":false,"fields":["email","jurisdiction","name"],"operation":"create","recordType":"contact","source":{"effect":"contact","kind":"effect"}}]},{"apiName":"updateContactEmail","commitEvidence":[],"conditionRoute":"/v1/actions/update-contact-email/target-conditions","definitionRevision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"effects":[{"dependsOn":[],"id":"contact-email","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}}],"operation":"patch","target":{"binding":{"input":"contact","kind":"existing"},"recordType":"contact"}}],"execution":{"mode":"immediate"},"id":"update-contact-email","inputs":[{"apiName":"contactId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":["contact-email"],"targets":[{"operation":"patch","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"contact","kind":"input"}}]}],"resultEffects":["contact-email"],"route":"/v1/actions/update-contact-email","targetUses":[{"conditionRequired":true,"fields":["email"],"operation":"patch","recordType":"contact","source":{"input":"contact","kind":"input"}}]}],"routes":[{"accessProfiles":["directory-editor"],"actionId":"register-contact","defaultAccessProfile":"directory-editor","id":"actions.register-contact.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/register-contact/proposals"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/availability"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.target-conditions","kind":"target-conditions","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/target-conditions"}]} \ No newline at end of file +{"access":[{"actionId":"register-contact","defaultProfileId":"directory-editor","operation":"start","profileIds":["directory-editor"],"routeId":"actions.register-contact.start"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.availability"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.invoke"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.target-conditions"}],"actions":[{"apiName":"registerContact","commitEvidence":[],"definitionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"effects":[{"dependsOn":[],"id":"contact","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"contact"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{},"permissions":[{"actorKind":null,"default":true,"operations":["get","list","edit","submit","cancel"],"party":"owner","principalClaim":"registry_principal","profileId":"directory-editor","readableAttachments":[],"readableContextFields":[],"readableInputs":["email","jurisdiction","name"],"requesterClients":[],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"targets":[{"recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null,"systemApplyGrant":{"actionId":"register-contact","actionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","revision":"sha256:4c7009790caae7d25e3bda52605cdea35d888a5fb7f45bd4b0ac764ccf3ae2ba","targets":[{"fields":["email","jurisdiction","name"],"operation":"create","readFields":["email","jurisdiction","name"],"recordType":"contact"}]}}},"id":"register-contact","inputs":[{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["start"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":[],"targets":[{"operation":"create","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"contact","kind":"effect"}}]}],"resultEffects":["contact"],"route":"/v1/actions/register-contact/proposals","targetUses":[{"conditionRequired":false,"fields":["email","jurisdiction","name"],"operation":"create","recordType":"contact","source":{"effect":"contact","kind":"effect"}}]},{"apiName":"updateContactEmail","commitEvidence":[],"conditionRoute":"/v1/actions/update-contact-email/target-conditions","definitionRevision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"effects":[{"dependsOn":[],"id":"contact-email","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}}],"operation":"patch","target":{"binding":{"input":"contact","kind":"existing"},"recordType":"contact"}}],"execution":{"mode":"immediate"},"id":"update-contact-email","inputs":[{"apiName":"contactId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":["contact-email"],"targets":[{"operation":"patch","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"contact","kind":"input"}}]}],"resultEffects":["contact-email"],"route":"/v1/actions/update-contact-email","targetUses":[{"conditionRequired":true,"fields":["email"],"operation":"patch","recordType":"contact","source":{"input":"contact","kind":"input"}}]}],"routes":[{"accessProfiles":["directory-editor"],"actionId":"register-contact","defaultAccessProfile":"directory-editor","id":"actions.register-contact.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/register-contact/proposals"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/availability"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.target-conditions","kind":"target-conditions","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/target-conditions"}]} \ No newline at end of file diff --git a/products/breg/generated/minimal/compiled/effective-model.json b/products/breg/generated/minimal/compiled/effective-model.json index fe48e3f124..0ec4bae5d8 100644 --- a/products/breg/generated/minimal/compiled/effective-model.json +++ b/products/breg/generated/minimal/compiled/effective-model.json @@ -1 +1 @@ -{"accessProfiles":[{"display":{},"id":"directory-editor"}],"actionInventory":{"access":[{"actionId":"register-contact","defaultProfileId":"directory-editor","operation":"start","profileIds":["directory-editor"],"routeId":"actions.register-contact.start"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.availability"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.invoke"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.target-conditions"}],"actions":[{"apiName":"registerContact","commitEvidence":[],"definitionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"effects":[{"dependsOn":[],"id":"contact","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"contact"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{},"permissions":[{"actorKind":null,"default":true,"operations":["get","list","edit","submit","cancel"],"ownership":"caller","principalClaim":"registry_principal","profileId":"directory-editor","readableAttachments":[],"readableContextFields":[],"readableInputs":["email","jurisdiction","name"],"requesterClients":[],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"targets":[{"recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null,"systemApplyGrant":{"actionId":"register-contact","actionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","revision":"sha256:4c7009790caae7d25e3bda52605cdea35d888a5fb7f45bd4b0ac764ccf3ae2ba","targets":[{"fields":["email","jurisdiction","name"],"operation":"create","readFields":["email","jurisdiction","name"],"recordType":"contact"}]}}},"id":"register-contact","inputs":[{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["start"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":[],"targets":[{"operation":"create","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"contact","kind":"effect"}}]}],"resultEffects":["contact"],"route":"/v1/actions/register-contact/proposals","targetUses":[{"conditionRequired":false,"fields":["email","jurisdiction","name"],"operation":"create","recordType":"contact","source":{"effect":"contact","kind":"effect"}}]},{"apiName":"updateContactEmail","commitEvidence":[],"conditionRoute":"/v1/actions/update-contact-email/target-conditions","definitionRevision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"effects":[{"dependsOn":[],"id":"contact-email","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}}],"operation":"patch","target":{"binding":{"input":"contact","kind":"existing"},"recordType":"contact"}}],"execution":{"mode":"immediate"},"id":"update-contact-email","inputs":[{"apiName":"contactId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":["contact-email"],"targets":[{"operation":"patch","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"contact","kind":"input"}}]}],"resultEffects":["contact-email"],"route":"/v1/actions/update-contact-email","targetUses":[{"conditionRequired":true,"fields":["email"],"operation":"patch","recordType":"contact","source":{"input":"contact","kind":"input"}}]}],"routes":[{"accessProfiles":["directory-editor"],"actionId":"register-contact","defaultAccessProfile":"directory-editor","id":"actions.register-contact.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/register-contact/proposals"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/availability"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.target-conditions","kind":"target-conditions","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/target-conditions"}]},"datasets":[{"display":{"description":"Institutional contact records.","label":"Directory"},"id":"directory"}],"defaultLanguage":"en","display":{"description":"A small registry maintained through generated CRUD and two Actions.","label":"Local directory"},"eventDeliveryInventory":{"deliveries":[]},"metadataInventory":{"recordTypes":[{"entries":[{"accessProfile":"directory-editor","operation":"create","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.create"},{"accessProfile":"directory-editor","operation":"get","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.get"},{"accessProfile":"directory-editor","operation":"list","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.list"},{"accessProfile":"directory-editor","operation":"patch","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.patch"}],"id":"contact","route":"contacts","schemaPath":"/v1/schemas/contact"}],"registryId":"local-directory","version":"0.1.0"},"moduleClosure":[],"moduleOrder":[],"physicalNames":{"entities":{"contact":{"constraints":{},"fields":{"email":"breg_f_contact_email_81e3bc296a8eee9d","jurisdiction":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","name":"breg_f_contact_name_65097df652ed4b63"},"indexes":{},"policies":{"directory-editor":"breg_p_contact_directory_editor_02b19ad1074c225d"},"table":"breg_e_contact_67133dce65a54144"}}},"queryInventory":{"operations":[{"allowCount":false,"filterFields":[],"id":"records.contact.directory-editor.list","kind":"list","maxPageSize":100,"processingFields":["email","jurisdiction","name"],"profileId":"directory-editor","projectionFields":["email","jurisdiction","name"],"recordType":"contact","routeId":"records.contact.list","sortFields":[],"stableTieBreaker":"record_id"}]},"recordTypes":{"contact":{"accessProfiles":{"directory-editor":{"allowDataExport":false,"default":true,"filterableFields":[],"id":"directory-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["email","jurisdiction","name"],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["email","jurisdiction","name"]}},"apiName":"Contact","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:7574edd5bd27c1e95c9021c1d4ca439b8ed8380e712a24501878277a476c53f6","derivedFields":{},"derivedRelations":{},"display":{"description":"A named institutional contact.","label":"Contact"},"fields":{"email":{"classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_contact_email_81e3bc296a8eee9d","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","relationship":null,"required":true},"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_contact_name_65097df652ed4b63","relationship":null,"required":true}},"hooks":{},"id":"contact","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_contact_67133dce65a54144","primaryDataset":"directory","readPaths":{},"route":"contacts","sourceRelation":{"recordType":"contact","sqlName":"contact","storedFields":["name","email","jurisdiction"]},"storedFields":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_contact_name_65097df652ed4b63","required":true,"sqlName":"name"},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_contact_email_81e3bc296a8eee9d","required":true,"sqlName":"email"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","required":true,"sqlName":"jurisdiction"}],"tombstone":false}},"registryId":"local-directory","version":"0.1.0"} \ No newline at end of file +{"accessProfiles":[{"display":{},"id":"directory-editor"}],"actionInventory":{"access":[{"actionId":"register-contact","defaultProfileId":"directory-editor","operation":"start","profileIds":["directory-editor"],"routeId":"actions.register-contact.start"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.availability"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.invoke"},{"actionId":"update-contact-email","defaultProfileId":"directory-editor","operation":"invoke","profileIds":["directory-editor"],"routeId":"actions.update-contact-email.target-conditions"}],"actions":[{"apiName":"registerContact","commitEvidence":[],"definitionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"effects":[{"dependsOn":[],"id":"contact","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}},{"field":"jurisdiction","kind":"set","value":{"input":"jurisdiction","kind":"from-input"}},{"field":"name","kind":"set","value":{"input":"name","kind":"from-input"}}],"operation":"create","target":{"binding":{"kind":"create"},"recordType":"contact"}}],"execution":{"mode":"proposal","proposal":{"application":{"maximumAttempts":3,"mode":"automatic"},"attachments":{},"permissions":[{"actorKind":null,"default":true,"operations":["get","list","edit","submit","cancel"],"party":"owner","principalClaim":"registry_principal","profileId":"directory-editor","readableAttachments":[],"readableContextFields":[],"readableInputs":["email","jurisdiction","name"],"requesterClients":[],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"targets":[{"recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}]}],"writableAttachments":[]}],"retention":"retain","review":{"type":"none"},"reviewContext":null,"systemApplyGrant":{"actionId":"register-contact","actionRevision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","revision":"sha256:4c7009790caae7d25e3bda52605cdea35d888a5fb7f45bd4b0ac764ccf3ae2ba","targets":[{"fields":["email","jurisdiction","name"],"operation":"create","readFields":["email","jurisdiction","name"],"recordType":"contact"}]}}},"id":"register-contact","inputs":[{"apiName":"name","classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true},{"apiName":"jurisdiction","classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["start"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":[],"targets":[{"operation":"create","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"effect":"contact","kind":"effect"}}]}],"resultEffects":["contact"],"route":"/v1/actions/register-contact/proposals","targetUses":[{"conditionRequired":false,"fields":["email","jurisdiction","name"],"operation":"create","recordType":"contact","source":{"effect":"contact","kind":"effect"}}]},{"apiName":"updateContactEmail","commitEvidence":[],"conditionRoute":"/v1/actions/update-contact-email/target-conditions","definitionRevision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"effects":[{"dependsOn":[],"id":"contact-email","mutations":[{"field":"email","kind":"set","value":{"input":"email","kind":"from-input"}}],"operation":"patch","target":{"binding":{"input":"contact","kind":"existing"},"recordType":"contact"}}],"execution":{"mode":"immediate"},"id":"update-contact-email","inputs":[{"apiName":"contactId","classification":"internal","display":{},"fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","required":true},{"apiName":"email","classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","required":true}],"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16,"permissions":[{"default":true,"operations":["invoke"],"principalClaim":"registry_principal","profileId":"directory-editor","requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"results":["contact-email"],"targets":[{"operation":"patch","recordType":"contact","rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"source":{"input":"contact","kind":"input"}}]}],"resultEffects":["contact-email"],"route":"/v1/actions/update-contact-email","targetUses":[{"conditionRequired":true,"fields":["email"],"operation":"patch","recordType":"contact","source":{"input":"contact","kind":"input"}}]}],"routes":[{"accessProfiles":["directory-editor"],"actionId":"register-contact","defaultAccessProfile":"directory-editor","id":"actions.register-contact.start","kind":"invoke","method":"POST","operation":"start","path":"/v1/actions/register-contact/proposals"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.invoke","kind":"invoke","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.availability","kind":"availability","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/availability"},{"accessProfiles":["directory-editor"],"actionId":"update-contact-email","defaultAccessProfile":"directory-editor","id":"actions.update-contact-email.target-conditions","kind":"target-conditions","method":"POST","operation":"invoke","path":"/v1/actions/update-contact-email/target-conditions"}]},"datasets":[{"display":{"description":"Institutional contact records.","label":"Directory"},"id":"directory"}],"defaultLanguage":"en","display":{"description":"A small registry maintained through generated CRUD and two Actions.","label":"Local directory"},"eventDeliveryInventory":{"deliveries":[]},"metadataInventory":{"recordTypes":[{"entries":[{"accessProfile":"directory-editor","operation":"create","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.create"},{"accessProfile":"directory-editor","operation":"get","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.get"},{"accessProfile":"directory-editor","operation":"list","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.list"},{"accessProfile":"directory-editor","operation":"patch","readableFields":["email","jurisdiction","name"],"responseRecordType":"contact","routeId":"records.contact.patch"}],"id":"contact","route":"contacts","schemaPath":"/v1/schemas/contact"}],"registryId":"local-directory","version":"0.1.0"},"moduleClosure":[],"moduleOrder":[],"physicalNames":{"entities":{"contact":{"constraints":{},"fields":{"email":"breg_f_contact_email_81e3bc296a8eee9d","jurisdiction":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","name":"breg_f_contact_name_65097df652ed4b63"},"indexes":{},"policies":{"directory-editor":"breg_p_contact_directory_editor_02b19ad1074c225d"},"table":"breg_e_contact_67133dce65a54144"}}},"queryInventory":{"operations":[{"allowCount":false,"filterFields":[],"id":"records.contact.directory-editor.list","kind":"list","maxPageSize":100,"processingFields":["email","jurisdiction","name"],"profileId":"directory-editor","projectionFields":["email","jurisdiction","name"],"recordType":"contact","routeId":"records.contact.list","sortFields":[],"stableTieBreaker":"record_id"}]},"recordTypes":{"contact":{"accessProfiles":{"directory-editor":{"allowDataExport":false,"default":true,"filterableFields":[],"id":"directory-editor","operations":["create","get","list","patch"],"principalClaim":"registry_principal","readableFields":["email","jurisdiction","name"],"requiredPurposes":["directory-administration"],"requiredScopes":["registry:directory:write"],"revisionAccess":false,"rowBoundaries":[{"claim":"jurisdiction","field":"jurisdiction","operator":"equals"}],"sortableFields":[],"writableFields":["email","jurisdiction","name"]}},"apiName":"Contact","canonicalId":{"apiName":"id","classification":"internal","fieldType":{"type":"uuid"},"id":"id","sqlName":"id"},"classification":"internal","constraints":{},"definitionRevision":"sha256:7574edd5bd27c1e95c9021c1d4ca439b8ed8380e712a24501878277a476c53f6","derivedFields":{},"derivedRelations":{},"display":{"description":"A named institutional contact.","label":"Contact"},"fields":{"email":{"classification":"internal","display":{},"fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_contact_email_81e3bc296a8eee9d","relationship":null,"required":true},"jurisdiction":{"classification":"internal","display":{},"fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","relationship":null,"required":true},"name":{"classification":"internal","display":{},"fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_contact_name_65097df652ed4b63","relationship":null,"required":true}},"hooks":{},"id":"contact","indexes":{},"lookups":{},"mutationMode":"mutable","physicalTable":"breg_e_contact_67133dce65a54144","primaryDataset":"directory","readPaths":{},"route":"contacts","sourceRelation":{"recordType":"contact","sqlName":"contact","storedFields":["name","email","jurisdiction"]},"storedFields":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","physicalName":"breg_f_contact_name_65097df652ed4b63","required":true,"sqlName":"name"},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","physicalName":"breg_f_contact_email_81e3bc296a8eee9d","required":true,"sqlName":"email"},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","physicalName":"breg_f_contact_jurisdiction_2f8e3324037bb7f5","required":true,"sqlName":"jurisdiction"}],"tombstone":false}},"registryId":"local-directory","version":"0.1.0"} \ No newline at end of file diff --git a/products/breg/generated/minimal/generated/action-contracts.json b/products/breg/generated/minimal/generated/action-contracts.json index 67bb4af4d2..502a475ac6 100644 --- a/products/breg/generated/minimal/generated/action-contracts.json +++ b/products/breg/generated/minimal/generated/action-contracts.json @@ -1 +1 @@ -{"actions":[{"application":{"maximumAttempts":3,"mode":"automatic"},"display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"id":"register-contact","input":{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"type":"none"},"revision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da"},{"display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"id":"update-contact-email","input":{"$id":"urn:breg:action:update-contact-email:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":["contactId","email"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["input","preconditions"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"mode":"immediate","output":{"$id":"urn:breg:action:update-contact-email:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"update-contact-email"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"contact-email":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"contact"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["contact-email"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066"}],"apiVersion":"id.registrystack.org/formats/breg/action-contracts/v1","kind":"BRegActionContracts"} \ No newline at end of file +{"actions":[{"application":{"maximumAttempts":3,"mode":"automatic"},"display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"id":"register-contact","input":{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]},"mode":"proposal","output":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"review":{"type":"none"},"revision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da"},{"display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"id":"update-contact-email","input":{"$id":"urn:breg:action:update-contact-email:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":["contactId","email"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["input","preconditions"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"mode":"immediate","output":{"$id":"urn:breg:action:update-contact-email:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"update-contact-email"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"contact-email":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"contact"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["contact-email"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066"}],"apiVersion":"id.registrystack.org/formats/breg/action-contracts/v1","kind":"BRegActionContracts"} \ No newline at end of file diff --git a/products/breg/generated/minimal/generated/action-schemas/register-contact.invoke.response.schema.json b/products/breg/generated/minimal/generated/action-schemas/register-contact.invoke.response.schema.json index fbfdbff5d7..bf1a56ee36 100644 --- a/products/breg/generated/minimal/generated/action-schemas/register-contact.invoke.response.schema.json +++ b/products/breg/generated/minimal/generated/action-schemas/register-contact.invoke.response.schema.json @@ -1 +1 @@ -{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file +{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"} \ No newline at end of file diff --git a/products/breg/generated/minimal/generated/openapi.json b/products/breg/generated/minimal/generated/openapi.json index 2ac533468b..153040a897 100644 --- a/products/breg/generated/minimal/generated/openapi.json +++ b/products/breg/generated/minimal/generated/openapi.json @@ -1 +1 @@ -{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.rejected","proposal.review-result-mismatch","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-register-contact-invoke-input":{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]},"action-register-contact-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-update-contact-email-availability-input":{"$id":"urn:breg:action:update-contact-email:availability-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"oneOf":[{"properties":{"input":{"properties":{"contactId":{"format":"uuid","type":"string"}},"required":["contactId"]},"targetInput":{"const":"contactId"}}}],"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":[],"type":"object"},"targetInput":{"enum":["contactId"],"type":"string"}},"required":["targetInput","input"],"type":"object","x-registry-action":"update-contact-email"},"action-update-contact-email-availability-response":{"$id":"urn:breg:action:update-contact-email:availability-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"availability":{"oneOf":[{"additionalProperties":false,"properties":{"available":{"const":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"}},"required":["available","observedRevision"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"const":false},"guardLabel":{"maxLength":256,"minLength":1,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"guard-not-satisfied"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"missingInputs":{"items":{"enum":["contactId","email"],"type":"string"},"minItems":1,"type":"array","uniqueItems":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"input-required"},"recovery":{"const":"correct-input"}},"required":["available","observedRevision","reason","recovery","missingInputs"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"observedRevision":{"type":"null"},"reason":{"const":"not-disclosed"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"}]}},"required":["availability"],"type":"object","x-registry-action":"update-contact-email"},"action-update-contact-email-invoke-input":{"$id":"urn:breg:action:update-contact-email:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":["contactId","email"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["input","preconditions"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"action-update-contact-email-invoke-response":{"$id":"urn:breg:action:update-contact-email:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"update-contact-email"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"contact-email":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"contact"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["contact-email"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"action-update-contact-email-target-conditions-input":{"$id":"urn:breg:action:update-contact-email:target-conditions-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"}},"required":["contactId"],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"action-update-contact-email-target-conditions-response":{"$id":"urn:breg:action:update-contact-email:target-conditions-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["preconditions"],"type":"object","x-registry-action":"update-contact-email"},"contact":{"$id":"urn:breg:record-type:contact","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"contact-create-input":{"$id":"urn:breg:record-type:contact:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"local-directory","version":"0.1.0"},"openapi":"3.1.0","paths":{"/v1/actions/register-contact/proposals":{"post":{"operationId":"actions.register-contact.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-contact-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-contact-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"registerContact","attachments":[],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"execution":{"application":"automatic","mode":"proposal","review":"none"},"id":"register-contact","inputMode":"fixed","inputs":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":160,"minLength":1,"type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[],"requiredConditionKeys":[],"resultEffects":[{"effect":"contact","operation":"create","recordType":"contact"}],"revision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","route":"/v1/actions/register-contact/proposals","routes":{"availability":null,"start":{"inputSchema":"action-register-contact-invoke-input","method":"POST","operationId":"actions.register-contact.start","path":"/v1/actions/register-contact/proposals","requiresIdempotencyKey":true,"responseSchema":"action-register-contact-invoke-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/update-contact-email":{"post":{"operationId":"actions.update-contact-email.invoke","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-invoke-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-invoke-response"}}},"description":"Immediate action committed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"invoke"}},"/v1/actions/update-contact-email/availability":{"post":{"operationId":"actions.update-contact-email.availability","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-availability-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-availability-response"}}},"description":"Action availability returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"availability"}},"/v1/actions/update-contact-email/target-conditions":{"post":{"operationId":"actions.update-contact-email.target-conditions","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-target-conditions-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-target-conditions-response"}}},"description":"Action target conditions returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"target-conditions"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/records/contacts":{"get":{"operationId":"records.contact.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"directory-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"directory-editor","requiredFilters":[],"selectableProperties":["email","jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.contact.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/contact-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"create","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/contacts/{record_id}":{"get":{"operationId":"records.contact.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"get","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.contact.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"patch","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file +{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.form-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached"}}},{"properties":{"code":{"const":"proposal.form-undeclared"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared"}}},{"properties":{"code":{"const":"proposal.message-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.subject-changed"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},{"properties":{"code":{"const":"proposal.subject-not-caller"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.form-limit-reached","proposal.form-undeclared","proposal.message-limit-reached","proposal.rejected","proposal.review-result-mismatch","proposal.subject-changed","proposal.subject-not-caller","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-register-contact-invoke-input":{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]},"action-register-contact-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"action-update-contact-email-availability-input":{"$id":"urn:breg:action:update-contact-email:availability-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"oneOf":[{"properties":{"input":{"properties":{"contactId":{"format":"uuid","type":"string"}},"required":["contactId"]},"targetInput":{"const":"contactId"}}}],"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":[],"type":"object"},"targetInput":{"enum":["contactId"],"type":"string"}},"required":["targetInput","input"],"type":"object","x-registry-action":"update-contact-email"},"action-update-contact-email-availability-response":{"$id":"urn:breg:action:update-contact-email:availability-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"availability":{"oneOf":[{"additionalProperties":false,"properties":{"available":{"const":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"}},"required":["available","observedRevision"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"const":false},"guardLabel":{"maxLength":256,"minLength":1,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"guard-not-satisfied"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"missingInputs":{"items":{"enum":["contactId","email"],"type":"string"},"minItems":1,"type":"array","uniqueItems":true},"observedRevision":{"format":"int64","minimum":1,"type":"integer"},"reason":{"const":"input-required"},"recovery":{"const":"correct-input"}},"required":["available","observedRevision","reason","recovery","missingInputs"],"type":"object"},{"additionalProperties":false,"properties":{"available":{"type":"null"},"observedRevision":{"type":"null"},"reason":{"const":"not-disclosed"},"recovery":{"const":"none"}},"required":["available","observedRevision","reason","recovery"],"type":"object"}]}},"required":["availability"],"type":"object","x-registry-action":"update-contact-email"},"action-update-contact-email-invoke-input":{"$id":"urn:breg:action:update-contact-email:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"},"email":{"maxLength":254,"minLength":1,"type":"string"}},"required":["contactId","email"],"type":"object"},"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["input","preconditions"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"action-update-contact-email-invoke-response":{"$id":"urn:breg:action:update-contact-email:invoke-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"action":{"const":"update-contact-email"},"applicationId":{"format":"uuid","type":"string"},"results":{"additionalProperties":false,"properties":{"contact-email":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"const":"contact"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"}},"required":["contact-email"],"type":"object"}},"required":["action","applicationId","results"],"type":"object"},"action-update-contact-email-target-conditions-input":{"$id":"urn:breg:action:update-contact-email:target-conditions-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"contactId":{"format":"uuid","type":"string"}},"required":["contactId"],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"update-contact-email","x-registry-requiredConditionKeys":["contactId"]},"action-update-contact-email-target-conditions-response":{"$id":"urn:breg:action:update-contact-email:target-conditions-response","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"preconditions":{"additionalProperties":false,"properties":{"contactId":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"}},"required":["contactId"],"type":"object"}},"required":["preconditions"],"type":"object","x-registry-action":"update-contact-email"},"contact":{"$id":"urn:breg:record-type:contact","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"},"contact-create-input":{"$id":"urn:breg:record-type:contact:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":["name","email","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"local-directory","version":"0.1.0"},"openapi":"3.1.0","paths":{"/v1/actions/register-contact/proposals":{"post":{"operationId":"actions.register-contact.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-contact-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-register-contact-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"registerContact","attachments":[],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{"description":"Create one contact through a Proposal that applies on submit without external review.","label":"Register contact"},"execution":{"application":"automatic","mode":"proposal","review":"none"},"id":"register-contact","inputMode":"fixed","inputs":[{"apiName":"name","classification":"internal","fieldType":{"maximumLength":160,"minimumLength":1,"type":"string"},"id":"name","label":"name","nullable":false,"required":true,"schema":{"maxLength":160,"minLength":1,"type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}},{"apiName":"jurisdiction","classification":"internal","fieldType":{"maximumLength":40,"minimumLength":1,"type":"string"},"id":"jurisdiction","label":"jurisdiction","nullable":false,"required":true,"schema":{"maxLength":40,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[],"requiredConditionKeys":[],"resultEffects":[{"effect":"contact","operation":"create","recordType":"contact"}],"revision":"sha256:2a81cd7c0637d4bfd3043ca4643134bde20a92d9e14ba15cd966a8e00d3e40da","route":"/v1/actions/register-contact/proposals","routes":{"availability":null,"start":{"inputSchema":"action-register-contact-invoke-input","method":"POST","operationId":"actions.register-contact.start","path":"/v1/actions/register-contact/proposals","requiresIdempotencyKey":true,"responseSchema":"action-register-contact-invoke-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/actions/update-contact-email":{"post":{"operationId":"actions.update-contact-email.invoke","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-invoke-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-invoke-response"}}},"description":"Immediate action committed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"action.guard-failed":{"value":{"code":"action.guard-failed","detail":"The action guard was not satisfied.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}},"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"invoke"}},"/v1/actions/update-contact-email/availability":{"post":{"operationId":"actions.update-contact-email.availability","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-availability-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-availability-response"}}},"description":"Action availability returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"runtime.field-encryption.unavailable":{"value":{"code":"runtime.field-encryption.unavailable","detail":"The Registry field-encryption service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}},"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"availability"}},"/v1/actions/update-contact-email/target-conditions":{"post":{"operationId":"actions.update-contact-email.target-conditions","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-target-conditions-input"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-update-contact-email-target-conditions-response"}}},"description":"Action target conditions returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-action":{"access":{"accessProfiles":["directory-editor"]},"apiName":"updateContactEmail","bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"conditionRoute":"/v1/actions/update-contact-email/target-conditions","display":{"description":"Replace one contact's email address as soon as the Action is invoked.","label":"Update contact email"},"execution":{"mode":"immediate"},"id":"update-contact-email","inputMode":"fixed","inputs":[{"apiName":"contactId","classification":"internal","fieldType":{"onDelete":"restrict","target":"contact","type":"reference"},"id":"contact","label":"contactId","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"email","classification":"internal","fieldType":{"maximumLength":254,"minimumLength":1,"type":"string"},"id":"email","label":"email","nullable":false,"required":true,"schema":{"maxLength":254,"minLength":1,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"contactId","input":"contact","targetRecordType":"contact"}],"requiredConditionKeys":["contactId"],"resultEffects":[{"effect":"contact-email","operation":"patch","recordType":"contact"}],"revision":"sha256:ca1bd47281413d63288eb89a49143a8e56fcee9320d904db1219ee1ec89f1066","route":"/v1/actions/update-contact-email","routes":{"availability":{"inputSchema":"action-update-contact-email-availability-input","method":"POST","operationId":"actions.update-contact-email.availability","path":"/v1/actions/update-contact-email/availability","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-availability-response"},"invoke":{"inputSchema":"action-update-contact-email-invoke-input","method":"POST","operationId":"actions.update-contact-email.invoke","path":"/v1/actions/update-contact-email","requiresIdempotencyKey":true,"responseSchema":"action-update-contact-email-invoke-response"},"targetConditions":{"inputSchema":"action-update-contact-email-target-conditions-input","method":"POST","operationId":"actions.update-contact-email.target-conditions","path":"/v1/actions/update-contact-email/target-conditions","requiresIdempotencyKey":false,"responseSchema":"action-update-contact-email-target-conditions-response"}}},"x-registry-defaultAccessProfile":"directory-editor","x-registry-operation":"invoke","x-registry-routeKind":"target-conditions"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:register-contact:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"register-contact","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["directory-editor"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"proposal.subject-not-caller":{"value":{"code":"proposal.subject-not-caller","detail":"This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized","proposal.subject-not-caller"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}},"proposal.subject-changed":{"value":{"code":"proposal.subject-changed","detail":"The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected","proposal.subject-changed"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["directory-editor"]}},"/v1/records/contacts":{"get":{"operationId":"records.contact.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"directory-editor":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"directory-editor","requiredFilters":[],"selectableProperties":["email","jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.contact.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/contact-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"create","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/contacts/{record_id}":{"get":{"operationId":"records.contact.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"email":{"maxLength":254,"minLength":1,"type":"string"},"jurisdiction":{"maxLength":40,"minLength":1,"type":"string"},"name":{"maxLength":160,"minLength":1,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"get","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"},"patch":{"operationId":"records.contact.patch","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Strong Registry ETag for the currently visible record representation.","in":"header","name":"If-Match","required":true,"schema":{"maxLength":256,"minLength":6,"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"items":{"additionalProperties":false,"else":{"required":["value"]},"if":{"properties":{"op":{"const":"remove"}}},"properties":{"op":{"enum":["add","replace","remove","test"],"type":"string"},"path":{"type":"string"},"value":true},"required":["op","path"],"then":{"not":{"required":["value"]}},"type":"object"},"maxItems":128,"minItems":1,"type":"array"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/contact"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"contact"},"registryId":{"const":"local-directory"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record patched","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["directory-editor"],"x-registry-operation":"patch","x-registry-recordType":"contact","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"contact","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file diff --git a/products/breg/generated/tools/journeys.v1.schema.json b/products/breg/generated/tools/journeys.v1.schema.json index 870678a9dc..af524f0450 100644 --- a/products/breg/generated/tools/journeys.v1.schema.json +++ b/products/breg/generated/tools/journeys.v1.schema.json @@ -24,12 +24,23 @@ "submissionCapture": { "$ref": "#/$defs/LocalId" }, + "text": { + "description": "The text a `message` step writes to the Proposal's thread.", + "type": "string" + }, "transition": { "$ref": "#/$defs/ProposalJourneyOperation" }, "type": { "const": "proposal", "type": "string" + }, + "waitSeconds": { + "description": "On a Get step, how long the schema test runs the built-in\napplication executor and reads the Proposal again until the\nresponse matches the step's expectation.", + "format": "uint32", + "maximum": 60, + "minimum": 1, + "type": "integer" } }, "required": [ @@ -543,20 +554,34 @@ "type": "string" }, "ProposalJourneyOperation": { - "enum": [ - "start", - "get", - "edit", - "submit", - "revise", - "rebase", - "retry", - "cancel", - "apply", - "get-review-context", - "get-review-status" - ], - "type": "string" + "oneOf": [ + { + "enum": [ + "start", + "get", + "edit", + "submit", + "revise", + "rebase", + "retry", + "cancel", + "apply", + "get-review-context", + "get-review-status" + ], + "type": "string" + }, + { + "const": "message", + "description": "Write `text` to the Proposal's message thread.", + "type": "string" + }, + { + "const": "read-messages", + "description": "Mark the thread read through the newest message the capture shows.", + "type": "string" + } + ] }, "StepSource": { "additionalProperties": false, @@ -580,7 +605,7 @@ "$ref": "#/$defs/LocalId" }, "default": {}, - "description": "Maps disclosed Action result aliases to distinct local capture aliases.\nCapture aliases must be unique throughout the journey, including earlier\ncaptures; the reader checks this semantic rule.", + "description": "Maps disclosed Action result aliases to distinct local capture aliases.\nOn a Proposal get or apply step, maps an effect ID to a record capture\ntaken from the application's result links; the effect must be the\nAction's only effect on its Record type. Capture aliases must be unique\nthroughout the journey, including earlier captures; the reader checks\nthis semantic rule.", "propertyNames": { "$ref": "#/$defs/LocalId" }, From c2d99dda16baed1e12693b4a0b944724b6841842 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 05:33:21 +0000 Subject: [PATCH 40/96] docs(breg): clarify Proposal Submit subject-field checks Signed-off-by: Jeremi Joslin --- .../src/content/docs/configure/breg-proposals.mdx | 11 +++++++---- .../breg/contracts/security-invariant-matrix.yaml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/site/src/content/docs/configure/breg-proposals.mdx b/docs/site/src/content/docs/configure/breg-proposals.mdx index 72f4e7e34f..60449ae65c 100644 --- a/docs/site/src/content/docs/configure/breg-proposals.mdx +++ b/docs/site/src/content/docs/configure/breg-proposals.mdx @@ -213,9 +213,12 @@ An empty field and another person's identifier both answer `403 proposal.subject Whoever writes that field chooses who may follow Proposals about the Record, so the compiler treats it as authority. A direct Create, Batch, Import or Patch grant that may write it is refused with `breg.proposal.subject-field-write` when its row boundaries let the writer name anyone. -So is an Action grant whose plan sets it with no person deciding: an immediate Action, or a Proposal Action without required review that is applied automatically. +The same check applies to the target grant of an immediate Action whose Plan can set the field. +For a Proposal Action whose Plan can set the field, the same check applies when `review.type: none` and application is automatic. +It covers both the Action target grant and the separate target grant under `permissions.proposals` that allows `submit`. An unrestricted grant stays admitted, for staff who may decide who a Record is about. -So does a grant bounded on that field by the profile's own principal claim, and a Proposal Action that a reviewer decides or a person applies. +So does a grant bounded on that field by the profile's own principal claim. +This Plan-based check permits Proposal Actions with required review or manual application. BReg binds the subject once, at the first Submit, not at Start. A draft binds no one, so the person it names cannot see it. @@ -288,11 +291,11 @@ Nothing here records a mandate or lets a party delegate. The filer keeps the owner access their own profile gives, and BReg does not check that they had the right to act for the subject. That is the job of the profile that says `submitsFor: anyone`. -{/* Evidence: crates/registry-breg/tests/proposal_party_compiler.rs; +{/* Evidence: crates/registry-breg/tests/proposal_party_compiler.rs a_proposal_applied_with_no_one_in_the_loop_cannot_set_a_subject_field; crates/registry-breg/tests/postgres_proposal_subject.rs; crates/registry-breg/src/api/proposals.rs select_proposal_grant; crates/registry-breg/src/mutation/proposal.rs bind_proposal_subject; - crates/registry-breg/src/proposal_subject.rs validate_field_writes. */} + crates/registry-breg/src/proposal_subject.rs validate_field_writes, plan_targets_include_action_and_proposal_write_permissions. */} ### Access after a target leaves the row boundary diff --git a/products/breg/contracts/security-invariant-matrix.yaml b/products/breg/contracts/security-invariant-matrix.yaml index 10e136248a..2073502dcb 100644 --- a/products/breg/contracts/security-invariant-matrix.yaml +++ b/products/breg/contracts/security-invariant-matrix.yaml @@ -289,7 +289,7 @@ invariants: - {"id": "BREG-SEC-270", "state": "enforced", "targetWave": "W5", "threat": "An agent, a service or a delegated token carrying the subject's principal is admitted as the subject.", "enforcementPoint": "Subject matching requires the admission's human test: a verified person acting for no one else and under no task grant.", "refusal": "Refuse at admission or conceal with 404 resource.not-found.", "negativeId": "BREG-NEG-270", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "only_a_person_acting_for_themselves_is_matched_as_the_subject"}} - {"id": "BREG-SEC-271", "state": "enforced", "targetWave": "W5", "threat": "A subject entry edits, submits, revises or applies work someone else filed.", "enforcementPoint": "Project compilation of party: subject entries.", "refusal": "Refuse with breg.proposal.subject-operation-forbidden.", "negativeId": "BREG-NEG-271", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_subject_entry_holds_only_the_follower_operations"}} - {"id": "BREG-SEC-272", "state": "enforced", "targetWave": "W5", "threat": "Audit records the subject's identifier or its internal reference.", "enforcementPoint": "The binding Submit records only a keyed, database-scoped subject pseudonym; later requests record partyRole.", "refusal": "Never write the identifier or the unkeyed reference to audit.", "negativeId": "BREG-NEG-272", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "audit_names_the_subject_by_pseudonym_and_each_later_request_by_party"}} - - {"id": "BREG-SEC-273", "state": "enforced", "targetWave": "W5", "threat": "A writer whose row boundaries let them name anyone sets the Record field a Proposal subject is read from, and so chooses who follows Proposals about that Record.", "enforcementPoint": "Project compilation of direct Record write grants, and of Action grants whose plan sets a field any `subject.field` names with no person deciding: an immediate Action, or a Proposal Action without required review that is applied automatically.", "refusal": "Refuse with breg.proposal.subject-field-write unless the grant is unrestricted or bounded on that field by its own principal claim.", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} + - {"id": "BREG-SEC-273", "state": "enforced", "targetWave": "W5", "threat": "A writer whose row boundaries let them name anyone sets the Record field a Proposal subject is read from, and so chooses who follows Proposals about that Record.", "enforcementPoint": "Project compilation checks direct Record write grants that can set a field named by `subject.field`. For Plans that can set such a field, it checks immediate Action target grants and, for Proposal Actions with `review.type: none` and automatic application, both Action target grants and Proposal Submit target grants.", "refusal": "Refuse with breg.proposal.subject-field-write unless the grant is unrestricted or bounded on that field by its own principal claim.", "negativeId": "BREG-NEG-273", "negativeTest": {"path": "crates/registry-breg/tests/proposal_party_compiler.rs", "name": "a_bounded_writer_cannot_choose_who_a_subject_field_names"}} - {"id": "BREG-SEC-274", "state": "enforced", "targetWave": "W5", "threat": "A party downloads an attachment its governing entry does not read, through another entry of the same profile.", "enforcementPoint": "The attachment route selects the entry that admitted the caller, party included, and the download transaction rechecks that entry's readable slots.", "refusal": "Conceal with 404 resource.not-found.", "negativeId": "BREG-NEG-274", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_subject.rs", "name": "attachment_downloads_follow_the_entry_that_admitted_the_caller"}} - {"id": "BREG-SEC-275", "state": "enforced", "targetWave": "W5", "threat": "A caller who is neither the Proposal's party nor admitted office staff reads, writes or marks read its message thread, or reads its content.", "enforcementPoint": "Every thread route admits the caller through the Proposal grant that holds message and the party matching of the Proposal; the transaction checks the governing party again.", "refusal": "Conceal write, list and mark-read with 404 resource.not-found; a grant without message is refused by name and its document carries no messages member.", "negativeId": "BREG-NEG-275", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found"}} - {"id": "BREG-SEC-276", "state": "enforced", "targetWave": "W5", "threat": "A writer chooses the side a message comes from, so a party passes as the office or staff as the applicant, or a reader learns which officer wrote.", "enforcementPoint": "The side is taken from the admitting entry: a party-bound entry writes from: party with its partyRole, any other grant from: official. Items carry mine and never a sender name or pseudonym.", "refusal": "The request carries no side; served items name only from, partyRole, mine, sentAt and text.", "negativeId": "BREG-NEG-276", "negativeTest": {"path": "crates/registry-breg/tests/postgres_proposal_messages.rs", "name": "the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_is_the_partys_turn"}} From 497dac1b9b3c537834bb4aac2b140931eee20634 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 05:42:27 +0000 Subject: [PATCH 41/96] chore(identifiers): bind the generated BReg journey schema Signed-off-by: Jeremi Joslin --- products/identifiers/generated/catalog.v1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/identifiers/generated/catalog.v1.json b/products/identifiers/generated/catalog.v1.json index b5c52c944a..c63cd415a0 100644 --- a/products/identifiers/generated/catalog.v1.json +++ b/products/identifiers/generated/catalog.v1.json @@ -5950,7 +5950,7 @@ }, "artifact": { "path": "products/breg/generated/tools/journeys.v1.schema.json", - "sha256": "8a220c615cfb0967b3df58baacfcdd8d3ce4309c08841d46c371c8c2bc299154", + "sha256": "2558b4e570b95f18d79f2f0fe45830b05a49ceba0ccd2fc18d5722b83fd1f4fb", "mediaType": "application/schema+json" } }, From be2376c5379cb11aeabcb2b8abbef6cba7f3f951 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 06:00:09 +0000 Subject: [PATCH 42/96] fix(breg): sync example TypeScript clients with canonical OpenAPI Signed-off-by: Jeremi Joslin --- clients/typescript/generated/breg-facility.ts | 68 +++++++++---------- clients/typescript/generated/breg-minimal.ts | 36 +++++----- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/clients/typescript/generated/breg-facility.ts b/clients/typescript/generated/breg-facility.ts index 03de78ac6f..a2eb4f0ca8 100644 --- a/clients/typescript/generated/breg-facility.ts +++ b/clients/typescript/generated/breg-facility.ts @@ -1,5 +1,5 @@ // Generated for Stack version 0.52.0, client version 0.52.0. -// Source SHA-256 04e9cb0a48a7f056eea904829bf26257ecd384e04b0b619c87fd0bd758629ef8 +// Source SHA-256 5b60b01c07f05b3d1c776a8f6f43bce555990088ecad7175e60ec16c417cfd39 // Unconstrained JSON /paths/~1v1~1records~1directory-entries~1{record_id}/patch/requestBody/content/application~1json-patch+json/schema/items/properties/value // Unconstrained JSON /paths/~1v1~1records~1operators~1{record_id}/patch/requestBody/content/application~1json-patch+json/schema/items/properties/value import { assertClientVersion, type Transport, type Answer, type CallOptions, type JsonValue, type Operation, type Page, type RequestValues, type ResponseVariant, type WireBytes, type WireText } from "../core.ts" @@ -10,12 +10,12 @@ import { listPage, listQuery, type FieldValue, type Filter, type ListPage, type export type Schema_ImmediateActionPrecondition = ({ "ifMatch": (string) }) export type Schema_ImmediateActionResultReference = ({ "recordId": (string); "recordType": (string); "revision": (number) }) -export type Schema_Problem = (({ "code"?: "access-profile.ambiguous"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous" }) | ({ "code"?: "action.evidence-failed"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/action/evidence-failed" }) | ({ "code"?: "action.guard-failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/action/guard-failed" }) | ({ "code"?: "action.handler-failed"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/action/handler-failed" }) | ({ "code"?: "action.refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/action/refused" }) | ({ "code"?: "attachment.content-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/content-type" }) | ({ "code"?: "attachment.digest-mismatch"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch" }) | ({ "code"?: "attachment.limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/limit-reached" }) | ({ "code"?: "attachment.required"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/required" }) | ({ "code"?: "attachment.slot-write-once"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once" }) | ({ "code"?: "attachment.too-large"; "status"?: 413; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/too-large" }) | ({ "code"?: "attachment.verification-pending"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-pending" }) | ({ "code"?: "attachment.verification-rejected"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected" }) | ({ "code"?: "authentication.refused"; "status"?: 401; "type"?: "https://id.registrystack.org/problems/registry-breg/authentication/refused" }) | ({ "code"?: "idempotency.expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/expired" }) | ({ "code"?: "idempotency.key-reused"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/key-reused" }) | ({ "code"?: "ingestion.chunk-mismatch"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch" }) | ({ "code"?: "ingestion.profile-mismatch"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch" }) | ({ "code"?: "ingestion.receipt-erased"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased" }) | ({ "code"?: "ingestion.run-blocked"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked" }) | ({ "code"?: "ingestion.run-not-open"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open" }) | ({ "code"?: "lookup.unresolved"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/lookup/unresolved" }) | ({ "code"?: "mutation.conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/mutation/conflict" }) | ({ "code"?: "precondition.failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/failed" }) | ({ "code"?: "precondition.required"; "status"?: 428; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/required" }) | ({ "code"?: "profile.not-authorized"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/profile/not-authorized" }) | ({ "code"?: "proposal.rejected"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/rejected" }) | ({ "code"?: "proposal.review-result-mismatch"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch" }) | ({ "code"?: "proposal.submission-expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/submission-expired" }) | ({ "code"?: "query.cursor-invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/cursor-invalid" }) | ({ "code"?: "query.filter-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/filter-required" }) | ({ "code"?: "query.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/invalid" }) | ({ "code"?: "request.access-reason-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/access-reason-required" }) | ({ "code"?: "request.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/invalid" }) | ({ "code"?: "request.timeout"; "status"?: 504; "type"?: "https://id.registrystack.org/problems/registry-breg/request/timeout" }) | ({ "code"?: "resource.not-found"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/resource/not-found" }) | ({ "code"?: "runtime.field-encryption.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable" }) | ({ "code"?: "service.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/service/unavailable" }) | ({ "code"?: "source.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/source/unavailable" }) | ({ "code"?: "statistical-dataset.domain-violation"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation" }) | ({ "code"?: "statistical-dataset.release-refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused" }) | ({ "code"?: "statistical-dataset.version-conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict" }) | ({ "code"?: "statistical-dataset.version-withdrawn"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn" }) | ({ "code"?: "unsupported.media-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/unsupported/media-type" }) | ({ "code"?: "write.outside-boundary"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" })) & ({ "accessProfiles"?: (Array<(string)>); "atField"?: (string); "code": ("access-profile.ambiguous" | "action.evidence-failed" | "action.guard-failed" | "action.handler-failed" | "action.refused" | "attachment.content-type" | "attachment.digest-mismatch" | "attachment.limit-reached" | "attachment.required" | "attachment.slot-write-once" | "attachment.too-large" | "attachment.verification-pending" | "attachment.verification-rejected" | "authentication.refused" | "idempotency.expired" | "idempotency.key-reused" | "ingestion.chunk-mismatch" | "ingestion.profile-mismatch" | "ingestion.receipt-erased" | "ingestion.run-blocked" | "ingestion.run-not-open" | "lookup.unresolved" | "mutation.conflict" | "precondition.failed" | "precondition.required" | "profile.not-authorized" | "proposal.rejected" | "proposal.review-result-mismatch" | "proposal.submission-expired" | "query.cursor-invalid" | "query.filter-required" | "query.invalid" | "request.access-reason-required" | "request.invalid" | "request.timeout" | "resource.not-found" | "runtime.field-encryption.unavailable" | "service.unavailable" | "source.unavailable" | "statistical-dataset.domain-violation" | "statistical-dataset.release-refused" | "statistical-dataset.version-conflict" | "statistical-dataset.version-withdrawn" | "unsupported.media-type" | "write.outside-boundary") & (string); "constraintId"?: (string); "constraintKind"?: ("compare" | "int-range" | "vocabulary") & (string); "detail": (string); "failedCheck"?: (string); "field"?: (string); "fieldId"?: (string); "fieldPath"?: (string); "guardReason"?: (string); "left"?: (string); "notAfterField"?: (string); "reasonCode"?: ("computation-error" | "source-data-error" | "disclosure-risk") & (string); "recordType"?: (string); "refusalCode"?: (string); "requiredFilters"?: (Array<(Array<(string)>)>); "right"?: (string); "status": (number); "title": (string); "traceId": (string); "type": (string) }) & (({ "code": "access-profile.ambiguous" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & ({ "status"?: 400; "accessProfiles": {} | null })) | ({ "code": "action.evidence-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "detail"?: "The declared Evidence dependency could not be accepted."; "fieldPath"?: (string); "status"?: 503 })) | ({ "code": "action.guard-failed" } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "action.handler-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "status"?: 500 })) | ({ "code": "action.refused" } & { "guardReason"?: never } & ({ "status"?: 422; "refusalCode": {} | null }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.content-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.digest-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.required" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.slot-write-once" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.too-large" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-pending" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-rejected" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "authentication.refused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.key-reused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.chunk-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.profile-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.receipt-erased" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-blocked" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-not-open" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "lookup.unresolved" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "mutation.conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "profile.not-authorized" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.rejected" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.review-result-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.submission-expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.cursor-invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.filter-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.access-reason-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.timeout" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "resource.not-found" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "runtime.field-encryption.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "service.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "source.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.domain-violation" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.release-refused" } & { "guardReason"?: never } & ({ "refusalCode": ("period-not-ended" | "before-first-period" | "provisional-after-final" | "already-withdrawn" | "negative-value"); "status"?: 422 }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-withdrawn" } & { "guardReason"?: never } & { "refusalCode"?: never } & ({ "status"?: 410; "reasonCode": {} | null }) & { "accessProfiles"?: never }) | ({ "code": "unsupported.media-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "write.outside-boundary" } & ({ "code"?: "write.outside-boundary"; "detail"?: "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."; "status"?: 403; "title"?: "Forbidden"; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never })) +export type Schema_Problem = (({ "code"?: "access-profile.ambiguous"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous" }) | ({ "code"?: "action.evidence-failed"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/action/evidence-failed" }) | ({ "code"?: "action.guard-failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/action/guard-failed" }) | ({ "code"?: "action.handler-failed"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/action/handler-failed" }) | ({ "code"?: "action.refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/action/refused" }) | ({ "code"?: "attachment.content-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/content-type" }) | ({ "code"?: "attachment.digest-mismatch"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch" }) | ({ "code"?: "attachment.limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/limit-reached" }) | ({ "code"?: "attachment.required"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/required" }) | ({ "code"?: "attachment.slot-write-once"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once" }) | ({ "code"?: "attachment.too-large"; "status"?: 413; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/too-large" }) | ({ "code"?: "attachment.verification-pending"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-pending" }) | ({ "code"?: "attachment.verification-rejected"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected" }) | ({ "code"?: "authentication.refused"; "status"?: 401; "type"?: "https://id.registrystack.org/problems/registry-breg/authentication/refused" }) | ({ "code"?: "idempotency.expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/expired" }) | ({ "code"?: "idempotency.key-reused"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/key-reused" }) | ({ "code"?: "ingestion.chunk-mismatch"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch" }) | ({ "code"?: "ingestion.profile-mismatch"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch" }) | ({ "code"?: "ingestion.receipt-erased"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased" }) | ({ "code"?: "ingestion.run-blocked"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked" }) | ({ "code"?: "ingestion.run-not-open"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open" }) | ({ "code"?: "lookup.unresolved"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/lookup/unresolved" }) | ({ "code"?: "mutation.conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/mutation/conflict" }) | ({ "code"?: "precondition.failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/failed" }) | ({ "code"?: "precondition.required"; "status"?: 428; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/required" }) | ({ "code"?: "profile.not-authorized"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/profile/not-authorized" }) | ({ "code"?: "proposal.form-limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached" }) | ({ "code"?: "proposal.form-undeclared"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared" }) | ({ "code"?: "proposal.message-limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached" }) | ({ "code"?: "proposal.rejected"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/rejected" }) | ({ "code"?: "proposal.review-result-mismatch"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch" }) | ({ "code"?: "proposal.subject-changed"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/subject-changed" }) | ({ "code"?: "proposal.subject-not-caller"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller" }) | ({ "code"?: "proposal.submission-expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/submission-expired" }) | ({ "code"?: "query.cursor-invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/cursor-invalid" }) | ({ "code"?: "query.filter-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/filter-required" }) | ({ "code"?: "query.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/invalid" }) | ({ "code"?: "request.access-reason-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/access-reason-required" }) | ({ "code"?: "request.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/invalid" }) | ({ "code"?: "request.timeout"; "status"?: 504; "type"?: "https://id.registrystack.org/problems/registry-breg/request/timeout" }) | ({ "code"?: "resource.not-found"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/resource/not-found" }) | ({ "code"?: "runtime.field-encryption.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable" }) | ({ "code"?: "service.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/service/unavailable" }) | ({ "code"?: "source.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/source/unavailable" }) | ({ "code"?: "statistical-dataset.domain-violation"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation" }) | ({ "code"?: "statistical-dataset.release-refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused" }) | ({ "code"?: "statistical-dataset.version-conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict" }) | ({ "code"?: "statistical-dataset.version-withdrawn"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn" }) | ({ "code"?: "unsupported.media-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/unsupported/media-type" }) | ({ "code"?: "write.outside-boundary"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" })) & ({ "accessProfiles"?: (Array<(string)>); "atField"?: (string); "code": ("access-profile.ambiguous" | "action.evidence-failed" | "action.guard-failed" | "action.handler-failed" | "action.refused" | "attachment.content-type" | "attachment.digest-mismatch" | "attachment.limit-reached" | "attachment.required" | "attachment.slot-write-once" | "attachment.too-large" | "attachment.verification-pending" | "attachment.verification-rejected" | "authentication.refused" | "idempotency.expired" | "idempotency.key-reused" | "ingestion.chunk-mismatch" | "ingestion.profile-mismatch" | "ingestion.receipt-erased" | "ingestion.run-blocked" | "ingestion.run-not-open" | "lookup.unresolved" | "mutation.conflict" | "precondition.failed" | "precondition.required" | "profile.not-authorized" | "proposal.form-limit-reached" | "proposal.form-undeclared" | "proposal.message-limit-reached" | "proposal.rejected" | "proposal.review-result-mismatch" | "proposal.subject-changed" | "proposal.subject-not-caller" | "proposal.submission-expired" | "query.cursor-invalid" | "query.filter-required" | "query.invalid" | "request.access-reason-required" | "request.invalid" | "request.timeout" | "resource.not-found" | "runtime.field-encryption.unavailable" | "service.unavailable" | "source.unavailable" | "statistical-dataset.domain-violation" | "statistical-dataset.release-refused" | "statistical-dataset.version-conflict" | "statistical-dataset.version-withdrawn" | "unsupported.media-type" | "write.outside-boundary") & (string); "constraintId"?: (string); "constraintKind"?: ("compare" | "int-range" | "vocabulary") & (string); "detail": (string); "failedCheck"?: (string); "field"?: (string); "fieldId"?: (string); "fieldPath"?: (string); "guardReason"?: (string); "left"?: (string); "notAfterField"?: (string); "reasonCode"?: ("computation-error" | "source-data-error" | "disclosure-risk") & (string); "recordType"?: (string); "refusalCode"?: (string); "requiredFilters"?: (Array<(Array<(string)>)>); "right"?: (string); "status": (number); "title": (string); "traceId": (string); "type": (string) }) & (({ "code": "access-profile.ambiguous" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & ({ "status"?: 400; "accessProfiles": {} | null })) | ({ "code": "action.evidence-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "detail"?: "The declared Evidence dependency could not be accepted."; "fieldPath"?: (string); "status"?: 503 })) | ({ "code": "action.guard-failed" } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "action.handler-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "status"?: 500 })) | ({ "code": "action.refused" } & { "guardReason"?: never } & ({ "status"?: 422; "refusalCode": {} | null }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.content-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.digest-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.required" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.slot-write-once" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.too-large" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-pending" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-rejected" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "authentication.refused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.key-reused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.chunk-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.profile-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.receipt-erased" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-blocked" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-not-open" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "lookup.unresolved" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "mutation.conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "profile.not-authorized" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.form-limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.form-undeclared" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.message-limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.rejected" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.review-result-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.subject-changed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.subject-not-caller" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.submission-expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.cursor-invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.filter-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.access-reason-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.timeout" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "resource.not-found" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "runtime.field-encryption.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "service.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "source.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.domain-violation" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.release-refused" } & { "guardReason"?: never } & ({ "refusalCode": ("period-not-ended" | "before-first-period" | "provisional-after-final" | "already-withdrawn" | "negative-value"); "status"?: 422 }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-withdrawn" } & { "guardReason"?: never } & { "refusalCode"?: never } & ({ "status"?: 410; "reasonCode": {} | null }) & { "accessProfiles"?: never }) | ({ "code": "unsupported.media-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "write.outside-boundary" } & ({ "code"?: "write.outside-boundary"; "detail"?: "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."; "status"?: 403; "title"?: "Forbidden"; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never })) export type Schema_ReviewCompletion = ({ "completedAt": (string); "eventId": (string); "requestId": (string); "resultId": (string); "type": "review.completed" }) export type Schema_action_correct_address_invoke_input = ({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) -export type Schema_action_correct_address_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) +export type Schema_action_correct_address_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) export type Schema_action_deactivate_facility_invoke_input = ({ "input": ({ "facilityId"?: (string) }) }) -export type Schema_action_deactivate_facility_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) +export type Schema_action_deactivate_facility_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) export type Schema_action_register_facility_availability_input = (({ "input"?: ({ "operatorId": (string) }); "targetInput"?: "operatorId" })) & ({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityCode"?: (string); "jurisdiction"?: (string); "name"?: (string); "operatorId"?: (string); "postalCode"?: (string) }); "targetInput": ("operatorId") & (string) }) export type Schema_action_register_facility_availability_response = ({ "availability": (({ "available": true; "observedRevision": (number) }) | ({ "available": false; "guardLabel"?: (string); "guardReason"?: (string); "observedRevision": (number); "reason": "guard-not-satisfied"; "recovery": "none" }) | ({ "available": (null); "missingInputs": (Array<("facilityCode" | "name" | "addressLine" | "city" | "postalCode" | "operatorId" | "jurisdiction") & (string)>); "observedRevision": (number); "reason": "input-required"; "recovery": "correct-input" }) | ({ "available": (null); "observedRevision": (null); "reason": "not-disclosed"; "recovery": "none" })) }) export type Schema_action_register_facility_invoke_input = ({ "input": ({ "addressLine": (string); "city": (string); "facilityCode": (string); "jurisdiction": (string); "name": (string); "operatorId": (string); "postalCode": (string) }); "preconditions"?: (Record) }) @@ -32,22 +32,22 @@ export interface Operations { "actions.deactivate-facility.start": { input: CallOptions & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_deactivate_facility_invoke_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_deactivate_facility_invoke_response } "actions.register-facility.invoke": { input: CallOptions & { query?: { "accessProfile"?: "facility-registrar" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_register_facility_invoke_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_register_facility_invoke_response } "actions.register-facility.availability": { input: CallOptions & { query?: { "accessProfile"?: "facility-registrar" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_register_facility_availability_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_register_facility_availability_response } - "proposals.list": { input: CallOptions & { query?: { "accessProfile"?: "facility-correction-applier" | "facility-correction-author"; "action"?: (string); "owner"?: "caller"; "target"?: (string); "state"?: ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "turn"?: ("party" | "official" | "nobody"); "cursor"?: (string); "limit"?: (number); "pendingManualApplication"?: (boolean) } } & { accept?: "application/json" | "*/*" }; required: false; output: ({ "items": (Array<({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>); "nextCursor"?: (string) }) } + "proposals.list": { input: CallOptions & { query?: { "accessProfile"?: "facility-correction-applier" | "facility-correction-author"; "action"?: (string); "owner"?: "caller"; "target"?: (string); "state"?: ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "turn"?: ("party" | "official" | "nobody"); "cursor"?: (string); "limit"?: (number); "pendingManualApplication"?: (boolean) } } & { accept?: "application/json" | "*/*" }; required: false; output: ({ "items": (Array<({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>); "nextCursor"?: (string) }) } "proposals.get-review-context-batch": { input: CallOptions & { query: { "accessProfile"?: "proposal-reviewer"; "ids": (Array<(string)>) } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "items": (Array<(({ "context": ({ "actionId": (string); "actionRevision": (string); "authority"?: (string); "context": ({ "contract": ({ "id": (string); "revision": (string); "schemaDigest": (string) }); "fields": (Record); "reference": (string) }); "effectDigest": (string); "id": (string); "policy"?: ({ "digest": (string); "id": (string); "version": (string) }); "result"?: ({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }); "reviewable": (boolean); "revision": (number); "subject": ({ "digest": (string); "id": (string); "source": (string); "subjectType": "proposal"; "version": (string) }); "submissionVersion": (number) }); "id": (string); "status": "visible" }) | ({ "id": (string); "status": "concealed" }))>) }) } - "proposals.get": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-applier" | "facility-correction-author" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.apply": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-applier" } } & { headers: { "If-Match": (string) } } & ({ body: ({ "effectDigest": (string); "reason"?: (string); "submissionVersion": (number) }) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.attachments.supporting-document.delete": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.get": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-applier" | "facility-correction-author" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.apply": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-applier" } } & { headers: { "If-Match": (string) } } & ({ body: ({ "effectDigest": (string); "reason"?: (string); "submissionVersion": (number) }) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.attachments.supporting-document.delete": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } "proposals.attachments.supporting-document.get": { input: CallOptions & { path: { "proposal_id": (string) } } & { query: { "accessProfile"?: "facility-correction-author" | "proposal-reviewer"; "submissionVersion": (number); "reviewContextField"?: (string); "effectDigest"?: (string); "contextSchemaDigest"?: (string) } } & { accept?: "*/*" }; required: true; output: WireBytes } - "proposals.attachments.supporting-document.patch": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: Uint8Array | Blob | string }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.cancel": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.edit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.rebase": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.retry": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.get-review-context": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "proposal-reviewer"; "include"?: "answers" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "authority"?: (string); "context": ({ "asks"?: (Array<({ "answer"?: ({ "answeredAt": (string); "documents": (Array<({ "byteSize": (number); "contentType": (string); "download"?: ({ "accessProfile": (string); "method": "GET"; "operation": "get-review-context"; "path": (string) }); "id": (string); "sha256": (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") })>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "contract": ({ "id": (string); "revision": (string); "schemaDigest": (string) }); "fields": (Record); "reference": (string) }); "effectDigest": (string); "id": (string); "policy"?: ({ "digest": (string); "id": (string); "version": (string) }); "result"?: ({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }); "reviewable": (boolean); "revision": (number); "subject": ({ "digest": (string); "id": (string); "source": (string); "subjectType": "proposal"; "version": (string) }); "submissionVersion": (number) }) } + "proposals.attachments.supporting-document.patch": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: Uint8Array | Blob | string }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.cancel": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.edit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.rebase": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.retry": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.get-review-context": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "proposal-reviewer"; "include"?: "answers" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "authority"?: (string); "context": ({ "asks"?: (Array<({ "answer"?: ({ "answeredAt": (string); "documents": (Array<({ "byteSize": (number); "contentType": (string); "download"?: ({ "accessProfile": (string); "method": "GET"; "operation": "get-review-context"; "path": (string) }); "id": (string); "sha256": (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") })>); "formEntries"?: (Array<(({ "input": {} | null }) | ({ "contractChanged": {} | null })) & ({ "addedAt": (string); "contractChanged"?: true; "id": (string); "input"?: (Record) })>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "contract": ({ "id": (string); "revision": (string); "schemaDigest": (string) }); "fields": (Record); "reference": (string) }); "effectDigest": (string); "id": (string); "policy"?: ({ "digest": (string); "id": (string); "version": (string) }); "result"?: ({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }); "reviewable": (boolean); "revision": (number); "subject": ({ "digest": (string); "id": (string); "source": (string); "subjectType": "proposal"; "version": (string) }); "submissionVersion": (number) }) } "proposals.get-review-status": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "casework-review-status" | "facility-correction-author"; "include"?: "progress" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "authority"?: (string); "context": ({ "contract"?: ({ "id": (string); "revision": (string); "schemaDigest": (string) }); "reference": (string) }); "effectDigest": (string); "handoff"?: ({ "reason"?: ("remote-refused" | "producer-identity-mismatch" | "review-acceptance-changed" | "review-policy-changed" | "submission-recovery-expired" | "operator-closed" | "unspecified"); "state": ("pending" | "accepted" | "failed" | "withdrawn") }); "id": (string); "policy"?: ({ "digest": (string); "id": (string); "version": (string) }); "progressCode"?: (string); "requestId"?: (string); "result"?: ({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }); "reviewable": (boolean); "revision": (number); "subject": ({ "digest": (string); "id": (string); "source": (string); "subjectType": "proposal"; "version": (string) }); "submissionVersion": (number) }) } - "proposals.revise": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) }) | (Record)) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.revise": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "addressLine"?: (string); "city"?: (string); "facilityId"?: (string); "postalCode"?: (string) }) }) | ({ "input": ({ "facilityId"?: (string) }) }) | (Record)) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } "proposals.get-submission": { input: CallOptions & { path: { "proposal_id": (string); "submission_version": (number) } } & { query?: { "accessProfile"?: "facility-correction-applier" | "facility-correction-author" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "application": (({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "state": "applied" }) | ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "cancelled" | "rejected") }) | (null)); "current": (boolean); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest": (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "review": (({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }) | (null)); "submissionVersion": (number) }) } - "proposals.submit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.submit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "facility-correction-author" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } "records.directory-entry.list": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor"; "$select"?: (string); "$filter"?: (string); "$orderby"?: (string); "limit"?: (number); "$count"?: (boolean); "cursor"?: (string) } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: false; output: ({ "count"?: (number); "items": (Array<({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) })>); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }); "pageInfo": ({ "nextCursor": (string | null) }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "count"?: (number); "items": (Array<({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) })>); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }); "pageInfo": ({ "nextCursor": (string | null) }) }) } "records.directory-entry.create": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor" } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & ({ body: ({ "data": Schema_directory_entry_create_input }) }) & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: true; output: ({ "data": ({ "domainData": Schema_directory_entry; "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "data": ({ "domainData": Schema_directory_entry; "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }) }) } "records.directory-entry.get": { input: CallOptions & { path: { "record_id": (string) } } & { query?: { "accessProfile"?: "directory-editor"; "$select"?: (string) } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: true; output: ({ "data": ({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "data": ({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "facility-registry"; "recordTypeId": "directory-entry"; "registryId": "facility-registry" }) }) } @@ -105,12 +105,12 @@ function recordRow(record: RecordEnvelope & { domainData: Data }): RecordR } const rules: Record = Object.fromEntries([ - ["/components/schemas/Problem", JSON.parse("{\"additionalProperties\":false,\"allOf\":[{\"if\":{\"properties\":{\"code\":{\"enum\":[\"attachment.required\",\"attachment.verification-pending\",\"attachment.verification-rejected\"]}}},\"then\":{\"allOf\":[{\"else\":{\"properties\":{\"status\":{\"const\":422}}},\"if\":{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"}}},\"then\":{\"properties\":{\"status\":{\"const\":409}}}}],\"properties\":{\"fieldPath\":{\"pattern\":\"^/attachments/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"fieldPath\"]},\"required\":[\"fieldPath\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"}}},\"then\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"detail\":{\"const\":\"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.\"},\"status\":{\"const\":403},\"title\":{\"const\":\"Forbidden\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"failedCheck\"]}}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"action.guard-failed\"}}}},\"then\":{\"not\":{\"required\":[\"guardReason\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.refused\"}}},\"then\":{\"properties\":{\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"}}},\"then\":{\"properties\":{\"refusalCode\":{\"enum\":[\"period-not-ended\",\"before-first-period\",\"provisional-after-final\",\"already-withdrawn\",\"negative-value\"]},\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"enum\":[\"action.refused\",\"statistical-dataset.release-refused\"]}}}},\"then\":{\"not\":{\"required\":[\"refusalCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"}}},\"then\":{\"properties\":{\"status\":{\"const\":410}},\"required\":[\"reasonCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"statistical-dataset.version-withdrawn\"}}}},\"then\":{\"not\":{\"required\":[\"reasonCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"}}},\"then\":{\"additionalProperties\":true,\"not\":{\"required\":[\"failedCheck\"]},\"properties\":{\"status\":{\"const\":400}},\"required\":[\"accessProfiles\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"access-profile.ambiguous\"}}}},\"then\":{\"not\":{\"required\":[\"accessProfiles\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"}}},\"then\":{\"properties\":{\"detail\":{\"const\":\"The declared Evidence dependency could not be accepted.\"},\"fieldPath\":{\"pattern\":\"^/evidence/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"status\":{\"const\":503}}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"}}},\"then\":{\"properties\":{\"status\":{\"const\":500}}}},{\"if\":{\"anyOf\":[{\"required\":[\"atField\"]},{\"required\":[\"notAfterField\"]}]},\"then\":{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400}},\"required\":[\"atField\",\"notAfterField\"]}},{\"if\":{\"anyOf\":[{\"required\":[\"recordType\"]},{\"required\":[\"fieldId\"]},{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"then\":{\"oneOf\":[{\"not\":{\"anyOf\":[{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"required\":[\"fieldId\"]},{\"not\":{\"required\":[\"fieldId\"]},\"oneOf\":[{\"not\":{\"required\":[\"field\"]},\"properties\":{\"constraintKind\":{\"const\":\"compare\"}},\"required\":[\"left\",\"right\"]},{\"not\":{\"anyOf\":[{\"required\":[\"left\"]},{\"required\":[\"right\"]}]},\"properties\":{\"constraintKind\":{\"enum\":[\"int-range\",\"vocabulary\"]}},\"required\":[\"field\"]}],\"required\":[\"constraintId\",\"constraintKind\"]}],\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409}},\"required\":[\"recordType\"]}}],\"anyOf\":[{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous\"}}},{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/evidence-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.guard-failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/guard-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/handler-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/refused\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.content-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/content-type\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.digest-mismatch\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.required\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/required\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.slot-write-once\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.too-large\"},\"status\":{\"const\":413},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/too-large\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-rejected\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected\"}}},{\"properties\":{\"code\":{\"const\":\"authentication.refused\"},\"status\":{\"const\":401},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/authentication/refused\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/expired\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.key-reused\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.chunk-mismatch\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.profile-mismatch\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.receipt-erased\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-blocked\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-not-open\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open\"}}},{\"properties\":{\"code\":{\"const\":\"lookup.unresolved\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/lookup/unresolved\"}}},{\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/mutation/conflict\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/failed\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.required\"},\"status\":{\"const\":428},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/required\"}}},{\"properties\":{\"code\":{\"const\":\"profile.not-authorized\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/profile/not-authorized\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.rejected\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/rejected\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.review-result-mismatch\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.submission-expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired\"}}},{\"properties\":{\"code\":{\"const\":\"query.cursor-invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid\"}}},{\"properties\":{\"code\":{\"const\":\"query.filter-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/filter-required\"}}},{\"properties\":{\"code\":{\"const\":\"query.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.access-reason-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/access-reason-required\"}}},{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.timeout\"},\"status\":{\"const\":504},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/timeout\"}}},{\"properties\":{\"code\":{\"const\":\"resource.not-found\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/resource/not-found\"}}},{\"properties\":{\"code\":{\"const\":\"runtime.field-encryption.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"service.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/service/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"source.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/source/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.domain-violation\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn\"}}},{\"properties\":{\"code\":{\"const\":\"unsupported.media-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/unsupported/media-type\"}}},{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}}}],\"properties\":{\"accessProfiles\":{\"items\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"atField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"code\":{\"enum\":[\"access-profile.ambiguous\",\"action.evidence-failed\",\"action.guard-failed\",\"action.handler-failed\",\"action.refused\",\"attachment.content-type\",\"attachment.digest-mismatch\",\"attachment.limit-reached\",\"attachment.required\",\"attachment.slot-write-once\",\"attachment.too-large\",\"attachment.verification-pending\",\"attachment.verification-rejected\",\"authentication.refused\",\"idempotency.expired\",\"idempotency.key-reused\",\"ingestion.chunk-mismatch\",\"ingestion.profile-mismatch\",\"ingestion.receipt-erased\",\"ingestion.run-blocked\",\"ingestion.run-not-open\",\"lookup.unresolved\",\"mutation.conflict\",\"precondition.failed\",\"precondition.required\",\"profile.not-authorized\",\"proposal.rejected\",\"proposal.review-result-mismatch\",\"proposal.submission-expired\",\"query.cursor-invalid\",\"query.filter-required\",\"query.invalid\",\"request.access-reason-required\",\"request.invalid\",\"request.timeout\",\"resource.not-found\",\"runtime.field-encryption.unavailable\",\"service.unavailable\",\"source.unavailable\",\"statistical-dataset.domain-violation\",\"statistical-dataset.release-refused\",\"statistical-dataset.version-conflict\",\"statistical-dataset.version-withdrawn\",\"unsupported.media-type\",\"write.outside-boundary\"],\"type\":\"string\"},\"constraintId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"constraintKind\":{\"enum\":[\"compare\",\"int-range\",\"vocabulary\"],\"type\":\"string\"},\"detail\":{\"maxLength\":256,\"type\":\"string\"},\"failedCheck\":{\"type\":\"string\"},\"field\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldPath\":{\"maxLength\":256,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"left\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"notAfterField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"reasonCode\":{\"enum\":[\"computation-error\",\"source-data-error\",\"disclosure-risk\"],\"type\":\"string\"},\"recordType\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"refusalCode\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"requiredFilters\":{\"items\":{\"items\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"maxItems\":32,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"maxItems\":8,\"minItems\":1,\"type\":\"array\"},\"right\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"status\":{\"maximum\":599,\"minimum\":400,\"type\":\"integer\"},\"title\":{\"maxLength\":128,\"type\":\"string\"},\"traceId\":{\"maxLength\":32,\"minLength\":32,\"pattern\":\"^[0-9a-f]{32}$\",\"type\":\"string\"},\"type\":{\"maxLength\":256,\"type\":\"string\"}},\"required\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\"],\"type\":\"object\"}")], + ["/components/schemas/Problem", JSON.parse("{\"additionalProperties\":false,\"allOf\":[{\"if\":{\"properties\":{\"code\":{\"enum\":[\"attachment.required\",\"attachment.verification-pending\",\"attachment.verification-rejected\"]}}},\"then\":{\"allOf\":[{\"else\":{\"properties\":{\"status\":{\"const\":422}}},\"if\":{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"}}},\"then\":{\"properties\":{\"status\":{\"const\":409}}}}],\"properties\":{\"fieldPath\":{\"pattern\":\"^/attachments/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"fieldPath\"]},\"required\":[\"fieldPath\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"}}},\"then\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"detail\":{\"const\":\"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.\"},\"status\":{\"const\":403},\"title\":{\"const\":\"Forbidden\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"failedCheck\"]}}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"action.guard-failed\"}}}},\"then\":{\"not\":{\"required\":[\"guardReason\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.refused\"}}},\"then\":{\"properties\":{\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"}}},\"then\":{\"properties\":{\"refusalCode\":{\"enum\":[\"period-not-ended\",\"before-first-period\",\"provisional-after-final\",\"already-withdrawn\",\"negative-value\"]},\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"enum\":[\"action.refused\",\"statistical-dataset.release-refused\"]}}}},\"then\":{\"not\":{\"required\":[\"refusalCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"}}},\"then\":{\"properties\":{\"status\":{\"const\":410}},\"required\":[\"reasonCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"statistical-dataset.version-withdrawn\"}}}},\"then\":{\"not\":{\"required\":[\"reasonCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"}}},\"then\":{\"additionalProperties\":true,\"not\":{\"required\":[\"failedCheck\"]},\"properties\":{\"status\":{\"const\":400}},\"required\":[\"accessProfiles\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"access-profile.ambiguous\"}}}},\"then\":{\"not\":{\"required\":[\"accessProfiles\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"}}},\"then\":{\"properties\":{\"detail\":{\"const\":\"The declared Evidence dependency could not be accepted.\"},\"fieldPath\":{\"pattern\":\"^/evidence/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"status\":{\"const\":503}}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"}}},\"then\":{\"properties\":{\"status\":{\"const\":500}}}},{\"if\":{\"anyOf\":[{\"required\":[\"atField\"]},{\"required\":[\"notAfterField\"]}]},\"then\":{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400}},\"required\":[\"atField\",\"notAfterField\"]}},{\"if\":{\"anyOf\":[{\"required\":[\"recordType\"]},{\"required\":[\"fieldId\"]},{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"then\":{\"oneOf\":[{\"not\":{\"anyOf\":[{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"required\":[\"fieldId\"]},{\"not\":{\"required\":[\"fieldId\"]},\"oneOf\":[{\"not\":{\"required\":[\"field\"]},\"properties\":{\"constraintKind\":{\"const\":\"compare\"}},\"required\":[\"left\",\"right\"]},{\"not\":{\"anyOf\":[{\"required\":[\"left\"]},{\"required\":[\"right\"]}]},\"properties\":{\"constraintKind\":{\"enum\":[\"int-range\",\"vocabulary\"]}},\"required\":[\"field\"]}],\"required\":[\"constraintId\",\"constraintKind\"]}],\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409}},\"required\":[\"recordType\"]}}],\"anyOf\":[{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous\"}}},{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/evidence-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.guard-failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/guard-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/handler-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/refused\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.content-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/content-type\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.digest-mismatch\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.required\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/required\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.slot-write-once\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.too-large\"},\"status\":{\"const\":413},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/too-large\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-rejected\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected\"}}},{\"properties\":{\"code\":{\"const\":\"authentication.refused\"},\"status\":{\"const\":401},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/authentication/refused\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/expired\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.key-reused\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.chunk-mismatch\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.profile-mismatch\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.receipt-erased\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-blocked\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-not-open\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open\"}}},{\"properties\":{\"code\":{\"const\":\"lookup.unresolved\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/lookup/unresolved\"}}},{\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/mutation/conflict\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/failed\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.required\"},\"status\":{\"const\":428},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/required\"}}},{\"properties\":{\"code\":{\"const\":\"profile.not-authorized\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/profile/not-authorized\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.form-limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.form-undeclared\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.message-limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.rejected\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/rejected\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.review-result-mismatch\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.subject-changed\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.subject-not-caller\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.submission-expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired\"}}},{\"properties\":{\"code\":{\"const\":\"query.cursor-invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid\"}}},{\"properties\":{\"code\":{\"const\":\"query.filter-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/filter-required\"}}},{\"properties\":{\"code\":{\"const\":\"query.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.access-reason-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/access-reason-required\"}}},{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.timeout\"},\"status\":{\"const\":504},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/timeout\"}}},{\"properties\":{\"code\":{\"const\":\"resource.not-found\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/resource/not-found\"}}},{\"properties\":{\"code\":{\"const\":\"runtime.field-encryption.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"service.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/service/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"source.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/source/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.domain-violation\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn\"}}},{\"properties\":{\"code\":{\"const\":\"unsupported.media-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/unsupported/media-type\"}}},{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}}}],\"properties\":{\"accessProfiles\":{\"items\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"atField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"code\":{\"enum\":[\"access-profile.ambiguous\",\"action.evidence-failed\",\"action.guard-failed\",\"action.handler-failed\",\"action.refused\",\"attachment.content-type\",\"attachment.digest-mismatch\",\"attachment.limit-reached\",\"attachment.required\",\"attachment.slot-write-once\",\"attachment.too-large\",\"attachment.verification-pending\",\"attachment.verification-rejected\",\"authentication.refused\",\"idempotency.expired\",\"idempotency.key-reused\",\"ingestion.chunk-mismatch\",\"ingestion.profile-mismatch\",\"ingestion.receipt-erased\",\"ingestion.run-blocked\",\"ingestion.run-not-open\",\"lookup.unresolved\",\"mutation.conflict\",\"precondition.failed\",\"precondition.required\",\"profile.not-authorized\",\"proposal.form-limit-reached\",\"proposal.form-undeclared\",\"proposal.message-limit-reached\",\"proposal.rejected\",\"proposal.review-result-mismatch\",\"proposal.subject-changed\",\"proposal.subject-not-caller\",\"proposal.submission-expired\",\"query.cursor-invalid\",\"query.filter-required\",\"query.invalid\",\"request.access-reason-required\",\"request.invalid\",\"request.timeout\",\"resource.not-found\",\"runtime.field-encryption.unavailable\",\"service.unavailable\",\"source.unavailable\",\"statistical-dataset.domain-violation\",\"statistical-dataset.release-refused\",\"statistical-dataset.version-conflict\",\"statistical-dataset.version-withdrawn\",\"unsupported.media-type\",\"write.outside-boundary\"],\"type\":\"string\"},\"constraintId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"constraintKind\":{\"enum\":[\"compare\",\"int-range\",\"vocabulary\"],\"type\":\"string\"},\"detail\":{\"maxLength\":256,\"type\":\"string\"},\"failedCheck\":{\"type\":\"string\"},\"field\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldPath\":{\"maxLength\":256,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"left\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"notAfterField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"reasonCode\":{\"enum\":[\"computation-error\",\"source-data-error\",\"disclosure-risk\"],\"type\":\"string\"},\"recordType\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"refusalCode\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"requiredFilters\":{\"items\":{\"items\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"maxItems\":32,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"maxItems\":8,\"minItems\":1,\"type\":\"array\"},\"right\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"status\":{\"maximum\":599,\"minimum\":400,\"type\":\"integer\"},\"title\":{\"maxLength\":128,\"type\":\"string\"},\"traceId\":{\"maxLength\":32,\"minLength\":32,\"pattern\":\"^[0-9a-f]{32}$\",\"type\":\"string\"},\"type\":{\"maxLength\":256,\"type\":\"string\"}},\"required\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\"],\"type\":\"object\"}")], ["/components/schemas/ReviewCompletion", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"completedAt\":{\"type\":\"string\"},\"eventId\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"},\"resultId\":{\"type\":\"string\"},\"type\":{\"const\":\"review.completed\"}},\"required\":[\"type\",\"eventId\",\"requestId\",\"resultId\",\"completedAt\"],\"type\":\"object\"}")], ["/components/schemas/action-correct-address-invoke-input", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"addressLine\":{\"maxLength\":240,\"minLength\":1,\"type\":\"string\"},\"city\":{\"maxLength\":120,\"minLength\":1,\"type\":\"string\"},\"facilityId\":{\"type\":\"string\"},\"postalCode\":{\"maxLength\":24,\"minLength\":1,\"type\":\"string\"}},\"required\":[],\"type\":\"object\"}},\"required\":[\"input\"],\"type\":\"object\"}")], - ["/components/schemas/action-correct-address-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/components/schemas/action-correct-address-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/components/schemas/action-deactivate-facility-invoke-input", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"facilityId\":{\"type\":\"string\"}},\"required\":[],\"type\":\"object\"}},\"required\":[\"input\"],\"type\":\"object\"}")], - ["/components/schemas/action-deactivate-facility-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/components/schemas/action-deactivate-facility-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/components/schemas/action-register-facility-availability-input", JSON.parse("{\"additionalProperties\":false,\"oneOf\":[{\"properties\":{\"input\":{\"properties\":{\"operatorId\":{\"type\":\"string\"}},\"required\":[\"operatorId\"]},\"targetInput\":{\"const\":\"operatorId\"}}}],\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"addressLine\":{\"maxLength\":240,\"minLength\":1,\"type\":\"string\"},\"city\":{\"maxLength\":120,\"minLength\":1,\"type\":\"string\"},\"facilityCode\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"jurisdiction\":{\"maxLength\":40,\"minLength\":1,\"type\":\"string\"},\"name\":{\"maxLength\":200,\"minLength\":1,\"type\":\"string\"},\"operatorId\":{\"type\":\"string\"},\"postalCode\":{\"maxLength\":24,\"minLength\":1,\"type\":\"string\"}},\"required\":[],\"type\":\"object\"},\"targetInput\":{\"enum\":[\"operatorId\"],\"type\":\"string\"}},\"required\":[\"targetInput\",\"input\"],\"type\":\"object\"}")], ["/components/schemas/action-register-facility-availability-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"availability\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"available\":{\"const\":true},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"available\",\"observedRevision\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"const\":false},\"guardLabel\":{\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"const\":\"guard-not-satisfied\"},\"recovery\":{\"const\":\"none\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"type\":\"null\"},\"missingInputs\":{\"items\":{\"enum\":[\"facilityCode\",\"name\",\"addressLine\",\"city\",\"postalCode\",\"operatorId\",\"jurisdiction\"],\"type\":\"string\"},\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"const\":\"input-required\"},\"recovery\":{\"const\":\"correct-input\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\",\"missingInputs\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"type\":\"null\"},\"observedRevision\":{\"type\":\"null\"},\"reason\":{\"const\":\"not-disclosed\"},\"recovery\":{\"const\":\"none\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\"],\"type\":\"object\"}]}},\"required\":[\"availability\"],\"type\":\"object\"}")], ["/components/schemas/action-register-facility-invoke-input", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"addressLine\":{\"maxLength\":240,\"minLength\":1,\"type\":\"string\"},\"city\":{\"maxLength\":120,\"minLength\":1,\"type\":\"string\"},\"facilityCode\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"jurisdiction\":{\"maxLength\":40,\"minLength\":1,\"type\":\"string\"},\"name\":{\"maxLength\":200,\"minLength\":1,\"type\":\"string\"},\"operatorId\":{\"type\":\"string\"},\"postalCode\":{\"maxLength\":24,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"facilityCode\",\"name\",\"addressLine\",\"city\",\"postalCode\",\"operatorId\",\"jurisdiction\"],\"type\":\"object\"},\"preconditions\":{\"additionalProperties\":false,\"properties\":{},\"required\":[],\"type\":\"object\"}},\"required\":[\"input\"],\"type\":\"object\"}")], @@ -160,7 +160,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1actions~1register-facility~1availability/post/responses/415/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], ["/paths/~1v1~1actions~1register-facility~1availability/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], ["/paths/~1v1~1actions~1register-facility~1availability/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], - ["/paths/~1v1~1proposals/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"items\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"},\"maxItems\":100,\"type\":\"array\"},\"nextCursor\":{\"type\":\"string\"}},\"required\":[\"items\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"items\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"},\"maxItems\":100,\"type\":\"array\"},\"nextCursor\":{\"type\":\"string\"}},\"required\":[\"items\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals/get/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"query.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -174,14 +174,14 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1review-context/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1review-context/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1review-context/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"dependentRequired\":{\"appliedAt\":[\"appliedBy\"],\"appliedBy\":[\"appliedAt\"]},\"properties\":{\"applicationId\":{\"type\":\"string\"},\"appliedAt\":{\"type\":\"string\"},\"appliedBy\":{\"pattern\":\"^hmac-sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"dependentRequired\":{\"appliedAt\":[\"appliedBy\"],\"appliedBy\":[\"appliedAt\"]},\"properties\":{\"applicationId\":{\"type\":\"string\"},\"appliedAt\":{\"type\":\"string\"},\"appliedBy\":{\"pattern\":\"^hmac-sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -193,7 +193,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1apply/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/delete/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/delete/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/delete/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/delete/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/delete/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -210,7 +210,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -223,7 +223,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1attachments~1supporting-document/patch/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -235,7 +235,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -247,7 +247,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -259,7 +259,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1rebase/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -271,7 +271,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1retry/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1review-context/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"authority\":{\"type\":\"string\"},\"context\":{\"additionalProperties\":false,\"properties\":{\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":\"string\"},\"documents\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"maxLength\":255,\"type\":\"string\"},\"download\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"method\":{\"const\":\"GET\"},\"operation\":{\"const\":\"get-review-context\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"operation\",\"accessProfile\",\"path\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[0-9a-f]{64}$\",\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"id\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"},\"maxItems\":32,\"type\":\"array\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"documents\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"contract\":{\"additionalProperties\":false,\"properties\":{\"id\":{\"maxLength\":2048,\"pattern\":\"^urn:registry:breg:review-context:\",\"type\":\"string\"},\"revision\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"schemaDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"}},\"required\":[\"id\",\"revision\",\"schemaDigest\"],\"type\":\"object\"},\"fields\":{\"type\":\"object\"},\"reference\":{\"type\":\"string\"}},\"required\":[\"reference\",\"contract\",\"fields\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"policy\":{\"additionalProperties\":false,\"properties\":{\"digest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}},\"required\":[\"id\",\"version\",\"digest\"],\"type\":\"object\"},\"result\":{\"additionalProperties\":false,\"properties\":{\"availableUntil\":{\"type\":\"string\"},\"completedAt\":{\"type\":\"string\"},\"resultId\":{\"type\":\"string\"},\"state\":{\"enum\":[\"pending\",\"approved\",\"rejected\",\"changes-requested\",\"answered\",\"cancelled\",\"superseded\",\"expired\"]}},\"required\":[\"state\"],\"type\":\"object\"},\"reviewable\":{\"type\":\"boolean\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"subject\":{\"additionalProperties\":false,\"properties\":{\"digest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"source\":{\"type\":\"string\"},\"subjectType\":{\"const\":\"proposal\"},\"version\":{\"type\":\"string\"}},\"required\":[\"source\",\"subjectType\",\"id\",\"version\",\"digest\"],\"type\":\"object\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"effectDigest\",\"subject\",\"context\",\"reviewable\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1review-context/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"authority\":{\"type\":\"string\"},\"context\":{\"additionalProperties\":false,\"properties\":{\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"answeredAt\":{\"type\":\"string\"},\"documents\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"maxLength\":255,\"type\":\"string\"},\"download\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"method\":{\"const\":\"GET\"},\"operation\":{\"const\":\"get-review-context\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"operation\",\"accessProfile\",\"path\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[0-9a-f]{64}$\",\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"id\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"},\"maxItems\":32,\"type\":\"array\"},\"formEntries\":{\"items\":{\"additionalProperties\":false,\"oneOf\":[{\"not\":{\"required\":[\"contractChanged\"]},\"required\":[\"input\"]},{\"not\":{\"required\":[\"input\"]},\"required\":[\"contractChanged\"]}],\"properties\":{\"addedAt\":{\"type\":\"string\"},\"contractChanged\":{\"const\":true},\"id\":{\"type\":\"string\"},\"input\":{\"maxProperties\":16,\"minProperties\":1,\"type\":\"object\"}},\"required\":[\"id\",\"addedAt\"],\"type\":\"object\"},\"maxItems\":32,\"type\":\"array\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"documents\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"contract\":{\"additionalProperties\":false,\"properties\":{\"id\":{\"maxLength\":2048,\"pattern\":\"^urn:registry:breg:review-context:\",\"type\":\"string\"},\"revision\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"schemaDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"}},\"required\":[\"id\",\"revision\",\"schemaDigest\"],\"type\":\"object\"},\"fields\":{\"type\":\"object\"},\"reference\":{\"type\":\"string\"}},\"required\":[\"reference\",\"contract\",\"fields\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"policy\":{\"additionalProperties\":false,\"properties\":{\"digest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}},\"required\":[\"id\",\"version\",\"digest\"],\"type\":\"object\"},\"result\":{\"additionalProperties\":false,\"properties\":{\"availableUntil\":{\"type\":\"string\"},\"completedAt\":{\"type\":\"string\"},\"resultId\":{\"type\":\"string\"},\"state\":{\"enum\":[\"pending\",\"approved\",\"rejected\",\"changes-requested\",\"answered\",\"cancelled\",\"superseded\",\"expired\"]}},\"required\":[\"state\"],\"type\":\"object\"},\"reviewable\":{\"type\":\"boolean\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"subject\":{\"additionalProperties\":false,\"properties\":{\"digest\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"source\":{\"type\":\"string\"},\"subjectType\":{\"const\":\"proposal\"},\"version\":{\"type\":\"string\"}},\"required\":[\"source\",\"subjectType\",\"id\",\"version\",\"digest\"],\"type\":\"object\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"effectDigest\",\"subject\",\"context\",\"reviewable\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1review-context/get/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1review-context/get/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1review-context/get/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -285,7 +285,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1review-status/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1review-status/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1review-status/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1revise/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1revise/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1revise/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1revise/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1revise/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -305,12 +305,12 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/410/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"proposal.submission-expired\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\",\"proposal.subject-not-caller\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/409/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"attachment.verification-pending\",\"idempotency.key-reused\",\"mutation.conflict\",\"proposal.rejected\"]}},\"type\":\"object\"}]}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/409/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"attachment.verification-pending\",\"idempotency.key-reused\",\"mutation.conflict\",\"proposal.rejected\",\"proposal.subject-changed\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/410/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"idempotency.expired\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/412/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"action.guard-failed\",\"precondition.failed\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/415/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"unsupported.media-type\"]}},\"type\":\"object\"}]}")], @@ -500,7 +500,7 @@ export class Client { if (!route) throw new TypeError("Unknown operation") return this.#transport.call(route, options) } - async proposals_listPage(options: Operations["proposals.list"]["input"] = {}, cursor?: string): Promise); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>> { + async proposals_listPage(options: Operations["proposals.list"]["input"] = {}, cursor?: string): Promise); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>> { const { data } = await this.call("proposals.list", { ...options, query: cursor === undefined ? options.query : { ...options.query, cursor } }) return { items: data.items, nextCursor: data.nextCursor ?? null } } diff --git a/clients/typescript/generated/breg-minimal.ts b/clients/typescript/generated/breg-minimal.ts index 78795d9df4..0b83a11d31 100644 --- a/clients/typescript/generated/breg-minimal.ts +++ b/clients/typescript/generated/breg-minimal.ts @@ -1,5 +1,5 @@ // Generated for Stack version 0.52.0, client version 0.52.0. -// Source SHA-256 bce07d69a8eed5bb72b32568719f0ad0dc4ed711148c6f57735cc64e379193f1 +// Source SHA-256 a0c571c73a3d832ce42d500fd151a8d72947955a848e0a138e9dfbed0b08ff78 // Unconstrained JSON /paths/~1v1~1records~1contacts~1{record_id}/patch/requestBody/content/application~1json-patch+json/schema/items/properties/value import { assertClientVersion, type Transport, type Answer, type CallOptions, type JsonValue, type Operation, type Page, type RequestValues, type ResponseVariant, type WireBytes, type WireText } from "../core.ts" import { actionAvailability, type ActionAvailability, type DescribeOptions } from "../core.ts" @@ -9,10 +9,10 @@ import { listPage, listQuery, type FieldValue, type Filter, type ListPage, type export type Schema_ImmediateActionPrecondition = ({ "ifMatch": (string) }) export type Schema_ImmediateActionResultReference = ({ "recordId": (string); "recordType": (string); "revision": (number) }) -export type Schema_Problem = (({ "code"?: "access-profile.ambiguous"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous" }) | ({ "code"?: "action.evidence-failed"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/action/evidence-failed" }) | ({ "code"?: "action.guard-failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/action/guard-failed" }) | ({ "code"?: "action.handler-failed"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/action/handler-failed" }) | ({ "code"?: "action.refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/action/refused" }) | ({ "code"?: "attachment.content-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/content-type" }) | ({ "code"?: "attachment.digest-mismatch"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch" }) | ({ "code"?: "attachment.limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/limit-reached" }) | ({ "code"?: "attachment.required"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/required" }) | ({ "code"?: "attachment.slot-write-once"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once" }) | ({ "code"?: "attachment.too-large"; "status"?: 413; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/too-large" }) | ({ "code"?: "attachment.verification-pending"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-pending" }) | ({ "code"?: "attachment.verification-rejected"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected" }) | ({ "code"?: "authentication.refused"; "status"?: 401; "type"?: "https://id.registrystack.org/problems/registry-breg/authentication/refused" }) | ({ "code"?: "idempotency.expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/expired" }) | ({ "code"?: "idempotency.key-reused"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/key-reused" }) | ({ "code"?: "ingestion.chunk-mismatch"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch" }) | ({ "code"?: "ingestion.profile-mismatch"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch" }) | ({ "code"?: "ingestion.receipt-erased"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased" }) | ({ "code"?: "ingestion.run-blocked"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked" }) | ({ "code"?: "ingestion.run-not-open"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open" }) | ({ "code"?: "lookup.unresolved"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/lookup/unresolved" }) | ({ "code"?: "mutation.conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/mutation/conflict" }) | ({ "code"?: "precondition.failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/failed" }) | ({ "code"?: "precondition.required"; "status"?: 428; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/required" }) | ({ "code"?: "profile.not-authorized"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/profile/not-authorized" }) | ({ "code"?: "proposal.rejected"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/rejected" }) | ({ "code"?: "proposal.review-result-mismatch"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch" }) | ({ "code"?: "proposal.submission-expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/submission-expired" }) | ({ "code"?: "query.cursor-invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/cursor-invalid" }) | ({ "code"?: "query.filter-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/filter-required" }) | ({ "code"?: "query.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/invalid" }) | ({ "code"?: "request.access-reason-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/access-reason-required" }) | ({ "code"?: "request.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/invalid" }) | ({ "code"?: "request.timeout"; "status"?: 504; "type"?: "https://id.registrystack.org/problems/registry-breg/request/timeout" }) | ({ "code"?: "resource.not-found"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/resource/not-found" }) | ({ "code"?: "runtime.field-encryption.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable" }) | ({ "code"?: "service.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/service/unavailable" }) | ({ "code"?: "source.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/source/unavailable" }) | ({ "code"?: "statistical-dataset.domain-violation"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation" }) | ({ "code"?: "statistical-dataset.release-refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused" }) | ({ "code"?: "statistical-dataset.version-conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict" }) | ({ "code"?: "statistical-dataset.version-withdrawn"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn" }) | ({ "code"?: "unsupported.media-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/unsupported/media-type" }) | ({ "code"?: "write.outside-boundary"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" })) & ({ "accessProfiles"?: (Array<(string)>); "atField"?: (string); "code": ("access-profile.ambiguous" | "action.evidence-failed" | "action.guard-failed" | "action.handler-failed" | "action.refused" | "attachment.content-type" | "attachment.digest-mismatch" | "attachment.limit-reached" | "attachment.required" | "attachment.slot-write-once" | "attachment.too-large" | "attachment.verification-pending" | "attachment.verification-rejected" | "authentication.refused" | "idempotency.expired" | "idempotency.key-reused" | "ingestion.chunk-mismatch" | "ingestion.profile-mismatch" | "ingestion.receipt-erased" | "ingestion.run-blocked" | "ingestion.run-not-open" | "lookup.unresolved" | "mutation.conflict" | "precondition.failed" | "precondition.required" | "profile.not-authorized" | "proposal.rejected" | "proposal.review-result-mismatch" | "proposal.submission-expired" | "query.cursor-invalid" | "query.filter-required" | "query.invalid" | "request.access-reason-required" | "request.invalid" | "request.timeout" | "resource.not-found" | "runtime.field-encryption.unavailable" | "service.unavailable" | "source.unavailable" | "statistical-dataset.domain-violation" | "statistical-dataset.release-refused" | "statistical-dataset.version-conflict" | "statistical-dataset.version-withdrawn" | "unsupported.media-type" | "write.outside-boundary") & (string); "constraintId"?: (string); "constraintKind"?: ("compare" | "int-range" | "vocabulary") & (string); "detail": (string); "failedCheck"?: (string); "field"?: (string); "fieldId"?: (string); "fieldPath"?: (string); "guardReason"?: (string); "left"?: (string); "notAfterField"?: (string); "reasonCode"?: ("computation-error" | "source-data-error" | "disclosure-risk") & (string); "recordType"?: (string); "refusalCode"?: (string); "requiredFilters"?: (Array<(Array<(string)>)>); "right"?: (string); "status": (number); "title": (string); "traceId": (string); "type": (string) }) & (({ "code": "access-profile.ambiguous" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & ({ "status"?: 400; "accessProfiles": {} | null })) | ({ "code": "action.evidence-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "detail"?: "The declared Evidence dependency could not be accepted."; "fieldPath"?: (string); "status"?: 503 })) | ({ "code": "action.guard-failed" } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "action.handler-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "status"?: 500 })) | ({ "code": "action.refused" } & { "guardReason"?: never } & ({ "status"?: 422; "refusalCode": {} | null }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.content-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.digest-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.required" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.slot-write-once" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.too-large" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-pending" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-rejected" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "authentication.refused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.key-reused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.chunk-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.profile-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.receipt-erased" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-blocked" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-not-open" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "lookup.unresolved" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "mutation.conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "profile.not-authorized" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.rejected" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.review-result-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.submission-expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.cursor-invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.filter-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.access-reason-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.timeout" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "resource.not-found" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "runtime.field-encryption.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "service.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "source.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.domain-violation" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.release-refused" } & { "guardReason"?: never } & ({ "refusalCode": ("period-not-ended" | "before-first-period" | "provisional-after-final" | "already-withdrawn" | "negative-value"); "status"?: 422 }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-withdrawn" } & { "guardReason"?: never } & { "refusalCode"?: never } & ({ "status"?: 410; "reasonCode": {} | null }) & { "accessProfiles"?: never }) | ({ "code": "unsupported.media-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "write.outside-boundary" } & ({ "code"?: "write.outside-boundary"; "detail"?: "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."; "status"?: 403; "title"?: "Forbidden"; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never })) +export type Schema_Problem = (({ "code"?: "access-profile.ambiguous"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous" }) | ({ "code"?: "action.evidence-failed"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/action/evidence-failed" }) | ({ "code"?: "action.guard-failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/action/guard-failed" }) | ({ "code"?: "action.handler-failed"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/action/handler-failed" }) | ({ "code"?: "action.refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/action/refused" }) | ({ "code"?: "attachment.content-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/content-type" }) | ({ "code"?: "attachment.digest-mismatch"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch" }) | ({ "code"?: "attachment.limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/limit-reached" }) | ({ "code"?: "attachment.required"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/required" }) | ({ "code"?: "attachment.slot-write-once"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once" }) | ({ "code"?: "attachment.too-large"; "status"?: 413; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/too-large" }) | ({ "code"?: "attachment.verification-pending"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-pending" }) | ({ "code"?: "attachment.verification-rejected"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected" }) | ({ "code"?: "authentication.refused"; "status"?: 401; "type"?: "https://id.registrystack.org/problems/registry-breg/authentication/refused" }) | ({ "code"?: "idempotency.expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/expired" }) | ({ "code"?: "idempotency.key-reused"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/idempotency/key-reused" }) | ({ "code"?: "ingestion.chunk-mismatch"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch" }) | ({ "code"?: "ingestion.profile-mismatch"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch" }) | ({ "code"?: "ingestion.receipt-erased"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased" }) | ({ "code"?: "ingestion.run-blocked"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked" }) | ({ "code"?: "ingestion.run-not-open"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open" }) | ({ "code"?: "lookup.unresolved"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/lookup/unresolved" }) | ({ "code"?: "mutation.conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/mutation/conflict" }) | ({ "code"?: "precondition.failed"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/failed" }) | ({ "code"?: "precondition.required"; "status"?: 428; "type"?: "https://id.registrystack.org/problems/registry-breg/precondition/required" }) | ({ "code"?: "profile.not-authorized"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/profile/not-authorized" }) | ({ "code"?: "proposal.form-limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached" }) | ({ "code"?: "proposal.form-undeclared"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared" }) | ({ "code"?: "proposal.message-limit-reached"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached" }) | ({ "code"?: "proposal.rejected"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/rejected" }) | ({ "code"?: "proposal.review-result-mismatch"; "status"?: 412; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch" }) | ({ "code"?: "proposal.subject-changed"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/subject-changed" }) | ({ "code"?: "proposal.subject-not-caller"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller" }) | ({ "code"?: "proposal.submission-expired"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/proposal/submission-expired" }) | ({ "code"?: "query.cursor-invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/cursor-invalid" }) | ({ "code"?: "query.filter-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/filter-required" }) | ({ "code"?: "query.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/query/invalid" }) | ({ "code"?: "request.access-reason-required"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/access-reason-required" }) | ({ "code"?: "request.invalid"; "status"?: 400; "type"?: "https://id.registrystack.org/problems/registry-breg/request/invalid" }) | ({ "code"?: "request.timeout"; "status"?: 504; "type"?: "https://id.registrystack.org/problems/registry-breg/request/timeout" }) | ({ "code"?: "resource.not-found"; "status"?: 404; "type"?: "https://id.registrystack.org/problems/registry-breg/resource/not-found" }) | ({ "code"?: "runtime.field-encryption.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable" }) | ({ "code"?: "service.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/service/unavailable" }) | ({ "code"?: "source.unavailable"; "status"?: 503; "type"?: "https://id.registrystack.org/problems/registry-breg/source/unavailable" }) | ({ "code"?: "statistical-dataset.domain-violation"; "status"?: 500; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation" }) | ({ "code"?: "statistical-dataset.release-refused"; "status"?: 422; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused" }) | ({ "code"?: "statistical-dataset.version-conflict"; "status"?: 409; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict" }) | ({ "code"?: "statistical-dataset.version-withdrawn"; "status"?: 410; "type"?: "https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn" }) | ({ "code"?: "unsupported.media-type"; "status"?: 415; "type"?: "https://id.registrystack.org/problems/registry-breg/unsupported/media-type" }) | ({ "code"?: "write.outside-boundary"; "status"?: 403; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" })) & ({ "accessProfiles"?: (Array<(string)>); "atField"?: (string); "code": ("access-profile.ambiguous" | "action.evidence-failed" | "action.guard-failed" | "action.handler-failed" | "action.refused" | "attachment.content-type" | "attachment.digest-mismatch" | "attachment.limit-reached" | "attachment.required" | "attachment.slot-write-once" | "attachment.too-large" | "attachment.verification-pending" | "attachment.verification-rejected" | "authentication.refused" | "idempotency.expired" | "idempotency.key-reused" | "ingestion.chunk-mismatch" | "ingestion.profile-mismatch" | "ingestion.receipt-erased" | "ingestion.run-blocked" | "ingestion.run-not-open" | "lookup.unresolved" | "mutation.conflict" | "precondition.failed" | "precondition.required" | "profile.not-authorized" | "proposal.form-limit-reached" | "proposal.form-undeclared" | "proposal.message-limit-reached" | "proposal.rejected" | "proposal.review-result-mismatch" | "proposal.subject-changed" | "proposal.subject-not-caller" | "proposal.submission-expired" | "query.cursor-invalid" | "query.filter-required" | "query.invalid" | "request.access-reason-required" | "request.invalid" | "request.timeout" | "resource.not-found" | "runtime.field-encryption.unavailable" | "service.unavailable" | "source.unavailable" | "statistical-dataset.domain-violation" | "statistical-dataset.release-refused" | "statistical-dataset.version-conflict" | "statistical-dataset.version-withdrawn" | "unsupported.media-type" | "write.outside-boundary") & (string); "constraintId"?: (string); "constraintKind"?: ("compare" | "int-range" | "vocabulary") & (string); "detail": (string); "failedCheck"?: (string); "field"?: (string); "fieldId"?: (string); "fieldPath"?: (string); "guardReason"?: (string); "left"?: (string); "notAfterField"?: (string); "reasonCode"?: ("computation-error" | "source-data-error" | "disclosure-risk") & (string); "recordType"?: (string); "refusalCode"?: (string); "requiredFilters"?: (Array<(Array<(string)>)>); "right"?: (string); "status": (number); "title": (string); "traceId": (string); "type": (string) }) & (({ "code": "access-profile.ambiguous" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & ({ "status"?: 400; "accessProfiles": {} | null })) | ({ "code": "action.evidence-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "detail"?: "The declared Evidence dependency could not be accepted."; "fieldPath"?: (string); "status"?: 503 })) | ({ "code": "action.guard-failed" } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "action.handler-failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never } & ({ "status"?: 500 })) | ({ "code": "action.refused" } & { "guardReason"?: never } & ({ "status"?: 422; "refusalCode": {} | null }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.content-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.digest-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.required" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.slot-write-once" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.too-large" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-pending" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "attachment.verification-rejected" } & ({ "fieldPath": (string) }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "authentication.refused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "idempotency.key-reused" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.chunk-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.profile-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.receipt-erased" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-blocked" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "ingestion.run-not-open" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "lookup.unresolved" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "mutation.conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.failed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "precondition.required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "profile.not-authorized" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.form-limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.form-undeclared" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.message-limit-reached" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.rejected" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.review-result-mismatch" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.subject-changed" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.subject-not-caller" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "proposal.submission-expired" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.cursor-invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.filter-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "query.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.access-reason-required" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.invalid" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "request.timeout" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "resource.not-found" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "runtime.field-encryption.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "service.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "source.unavailable" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.domain-violation" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.release-refused" } & { "guardReason"?: never } & ({ "refusalCode": ("period-not-ended" | "before-first-period" | "provisional-after-final" | "already-withdrawn" | "negative-value"); "status"?: 422 }) & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-conflict" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "statistical-dataset.version-withdrawn" } & { "guardReason"?: never } & { "refusalCode"?: never } & ({ "status"?: 410; "reasonCode": {} | null }) & { "accessProfiles"?: never }) | ({ "code": "unsupported.media-type" } & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never }) | ({ "code": "write.outside-boundary" } & ({ "code"?: "write.outside-boundary"; "detail"?: "The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."; "status"?: 403; "title"?: "Forbidden"; "type"?: "https://id.registrystack.org/problems/registry-breg/write/outside-boundary" }) & { "guardReason"?: never } & { "refusalCode"?: never } & { "reasonCode"?: never } & { "accessProfiles"?: never })) export type Schema_ReviewCompletion = ({ "completedAt": (string); "eventId": (string); "requestId": (string); "resultId": (string); "type": "review.completed" }) export type Schema_action_register_contact_invoke_input = ({ "input": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }) }) -export type Schema_action_register_contact_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) +export type Schema_action_register_contact_invoke_response = ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) export type Schema_action_update_contact_email_availability_input = (({ "input"?: ({ "contactId": (string) }); "targetInput"?: "contactId" })) & ({ "input": ({ "contactId"?: (string); "email"?: (string) }); "targetInput": ("contactId") & (string) }) export type Schema_action_update_contact_email_availability_response = ({ "availability": (({ "available": true; "observedRevision": (number) }) | ({ "available": false; "guardLabel"?: (string); "guardReason"?: (string); "observedRevision": (number); "reason": "guard-not-satisfied"; "recovery": "none" }) | ({ "available": (null); "missingInputs": (Array<("contactId" | "email") & (string)>); "observedRevision": (number); "reason": "input-required"; "recovery": "correct-input" }) | ({ "available": (null); "observedRevision": (null); "reason": "not-disclosed"; "recovery": "none" })) }) export type Schema_action_update_contact_email_invoke_input = ({ "input": ({ "contactId": (string); "email": (string) }); "preconditions": ({ "contactId": ({ "ifMatch": (string) }) }) }) @@ -27,12 +27,12 @@ export interface Operations { "actions.update-contact-email.invoke": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_update_contact_email_invoke_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_update_contact_email_invoke_response } "actions.update-contact-email.availability": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_update_contact_email_availability_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_update_contact_email_availability_response } "actions.update-contact-email.target-conditions": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor" } } & { headers?: { "traceparent"?: (string) } } & ({ body: Schema_action_update_contact_email_target_conditions_input }) & { accept?: "application/json" | "*/*" }; required: true; output: Schema_action_update_contact_email_target_conditions_response } - "proposals.list": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor"; "action"?: (string); "owner"?: "caller"; "target"?: (string); "state"?: ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "turn"?: ("party" | "official" | "nobody"); "cursor"?: (string); "limit"?: (number); "pendingManualApplication"?: (boolean) } } & { accept?: "application/json" | "*/*" }; required: false; output: ({ "items": (Array<({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>); "nextCursor"?: (string) }) } - "proposals.get": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.cancel": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } - "proposals.edit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.list": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor"; "action"?: (string); "owner"?: "caller"; "target"?: (string); "state"?: ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "turn"?: ("party" | "official" | "nobody"); "cursor"?: (string); "limit"?: (number); "pendingManualApplication"?: (boolean) } } & { accept?: "application/json" | "*/*" }; required: false; output: ({ "items": (Array<({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>); "nextCursor"?: (string) }) } + "proposals.get": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.cancel": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.edit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (({ "input": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }) })) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } "proposals.get-submission": { input: CallOptions & { path: { "proposal_id": (string); "submission_version": (number) } } & { query?: { "accessProfile"?: "directory-editor" } } & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "application": (({ "applicationId": (string); "appliedAt"?: (string); "appliedBy"?: (string); "state": "applied" }) | ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "cancelled" | "rejected") }) | (null)); "current": (boolean); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest": (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "review": (({ "availableUntil"?: (string); "completedAt"?: (string); "resultId"?: (string); "state": ("pending" | "approved" | "rejected" | "changes-requested" | "answered" | "cancelled" | "superseded" | "expired") }) | (null)); "submissionVersion": (number) }) } - "proposals.submit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } + "proposals.submit": { input: CallOptions & { path: { "proposal_id": (string) } } & { query?: { "accessProfile"?: "directory-editor" } } & { headers: { "If-Match": (string) } } & ({ body: (Record) }) & { accept?: "application/json" | "*/*" }; required: true; output: ({ "actionId": (string); "actionRevision": (string); "application"?: ({ "applicationId": (string); "effectDigest": (string); "resultLinks": (Array<({ "recordId": (string); "recordType": (string); "revision": (number) })>); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") }) } "records.contact.list": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor"; "$select"?: (string); "$filter"?: (string); "$orderby"?: (string); "limit"?: (number); "$count"?: (boolean); "cursor"?: (string) } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: false; output: ({ "count"?: (number); "items": (Array<({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) })>); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }); "pageInfo": ({ "nextCursor": (string | null) }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "count"?: (number); "items": (Array<({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) })>); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }); "pageInfo": ({ "nextCursor": (string | null) }) }) } "records.contact.create": { input: CallOptions & { query?: { "accessProfile"?: "directory-editor" } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & ({ body: ({ "data": Schema_contact_create_input }) }) & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: true; output: ({ "data": ({ "domainData": Schema_contact; "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "data": ({ "domainData": Schema_contact; "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }) }) } "records.contact.get": { input: CallOptions & { path: { "record_id": (string) } } & { query?: { "accessProfile"?: "directory-editor"; "$select"?: (string) } } & { headers?: { "traceparent"?: (string); "Accept"?: ("application/json" | "application/ld+json") & (string) } } & { accept?: "application/json" | "application/ld+json" | "*/*" }; required: true; output: ({ "data": ({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }) }) | ({ "@context": "https://id.registrystack.org/contexts/registry-record/v1"; "data": ({ "domainData": ({ "email"?: (string); "jurisdiction"?: (string); "name"?: (string) }); "recordId": (string); "revisionId": (string) }); "meta": ({ "datasetId": "directory"; "recordTypeId": "contact"; "registryId": "local-directory" }) }) } @@ -68,10 +68,10 @@ function recordRow(record: RecordEnvelope & { domainData: Data }): RecordR } const rules: Record = Object.fromEntries([ - ["/components/schemas/Problem", JSON.parse("{\"additionalProperties\":false,\"allOf\":[{\"if\":{\"properties\":{\"code\":{\"enum\":[\"attachment.required\",\"attachment.verification-pending\",\"attachment.verification-rejected\"]}}},\"then\":{\"allOf\":[{\"else\":{\"properties\":{\"status\":{\"const\":422}}},\"if\":{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"}}},\"then\":{\"properties\":{\"status\":{\"const\":409}}}}],\"properties\":{\"fieldPath\":{\"pattern\":\"^/attachments/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"fieldPath\"]},\"required\":[\"fieldPath\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"}}},\"then\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"detail\":{\"const\":\"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.\"},\"status\":{\"const\":403},\"title\":{\"const\":\"Forbidden\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"failedCheck\"]}}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"action.guard-failed\"}}}},\"then\":{\"not\":{\"required\":[\"guardReason\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.refused\"}}},\"then\":{\"properties\":{\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"}}},\"then\":{\"properties\":{\"refusalCode\":{\"enum\":[\"period-not-ended\",\"before-first-period\",\"provisional-after-final\",\"already-withdrawn\",\"negative-value\"]},\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"enum\":[\"action.refused\",\"statistical-dataset.release-refused\"]}}}},\"then\":{\"not\":{\"required\":[\"refusalCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"}}},\"then\":{\"properties\":{\"status\":{\"const\":410}},\"required\":[\"reasonCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"statistical-dataset.version-withdrawn\"}}}},\"then\":{\"not\":{\"required\":[\"reasonCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"}}},\"then\":{\"additionalProperties\":true,\"not\":{\"required\":[\"failedCheck\"]},\"properties\":{\"status\":{\"const\":400}},\"required\":[\"accessProfiles\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"access-profile.ambiguous\"}}}},\"then\":{\"not\":{\"required\":[\"accessProfiles\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"}}},\"then\":{\"properties\":{\"detail\":{\"const\":\"The declared Evidence dependency could not be accepted.\"},\"fieldPath\":{\"pattern\":\"^/evidence/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"status\":{\"const\":503}}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"}}},\"then\":{\"properties\":{\"status\":{\"const\":500}}}},{\"if\":{\"anyOf\":[{\"required\":[\"atField\"]},{\"required\":[\"notAfterField\"]}]},\"then\":{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400}},\"required\":[\"atField\",\"notAfterField\"]}},{\"if\":{\"anyOf\":[{\"required\":[\"recordType\"]},{\"required\":[\"fieldId\"]},{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"then\":{\"oneOf\":[{\"not\":{\"anyOf\":[{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"required\":[\"fieldId\"]},{\"not\":{\"required\":[\"fieldId\"]},\"oneOf\":[{\"not\":{\"required\":[\"field\"]},\"properties\":{\"constraintKind\":{\"const\":\"compare\"}},\"required\":[\"left\",\"right\"]},{\"not\":{\"anyOf\":[{\"required\":[\"left\"]},{\"required\":[\"right\"]}]},\"properties\":{\"constraintKind\":{\"enum\":[\"int-range\",\"vocabulary\"]}},\"required\":[\"field\"]}],\"required\":[\"constraintId\",\"constraintKind\"]}],\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409}},\"required\":[\"recordType\"]}}],\"anyOf\":[{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous\"}}},{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/evidence-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.guard-failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/guard-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/handler-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/refused\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.content-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/content-type\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.digest-mismatch\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.required\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/required\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.slot-write-once\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.too-large\"},\"status\":{\"const\":413},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/too-large\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-rejected\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected\"}}},{\"properties\":{\"code\":{\"const\":\"authentication.refused\"},\"status\":{\"const\":401},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/authentication/refused\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/expired\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.key-reused\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.chunk-mismatch\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.profile-mismatch\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.receipt-erased\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-blocked\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-not-open\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open\"}}},{\"properties\":{\"code\":{\"const\":\"lookup.unresolved\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/lookup/unresolved\"}}},{\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/mutation/conflict\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/failed\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.required\"},\"status\":{\"const\":428},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/required\"}}},{\"properties\":{\"code\":{\"const\":\"profile.not-authorized\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/profile/not-authorized\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.rejected\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/rejected\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.review-result-mismatch\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.submission-expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired\"}}},{\"properties\":{\"code\":{\"const\":\"query.cursor-invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid\"}}},{\"properties\":{\"code\":{\"const\":\"query.filter-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/filter-required\"}}},{\"properties\":{\"code\":{\"const\":\"query.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.access-reason-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/access-reason-required\"}}},{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.timeout\"},\"status\":{\"const\":504},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/timeout\"}}},{\"properties\":{\"code\":{\"const\":\"resource.not-found\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/resource/not-found\"}}},{\"properties\":{\"code\":{\"const\":\"runtime.field-encryption.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"service.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/service/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"source.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/source/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.domain-violation\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn\"}}},{\"properties\":{\"code\":{\"const\":\"unsupported.media-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/unsupported/media-type\"}}},{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}}}],\"properties\":{\"accessProfiles\":{\"items\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"atField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"code\":{\"enum\":[\"access-profile.ambiguous\",\"action.evidence-failed\",\"action.guard-failed\",\"action.handler-failed\",\"action.refused\",\"attachment.content-type\",\"attachment.digest-mismatch\",\"attachment.limit-reached\",\"attachment.required\",\"attachment.slot-write-once\",\"attachment.too-large\",\"attachment.verification-pending\",\"attachment.verification-rejected\",\"authentication.refused\",\"idempotency.expired\",\"idempotency.key-reused\",\"ingestion.chunk-mismatch\",\"ingestion.profile-mismatch\",\"ingestion.receipt-erased\",\"ingestion.run-blocked\",\"ingestion.run-not-open\",\"lookup.unresolved\",\"mutation.conflict\",\"precondition.failed\",\"precondition.required\",\"profile.not-authorized\",\"proposal.rejected\",\"proposal.review-result-mismatch\",\"proposal.submission-expired\",\"query.cursor-invalid\",\"query.filter-required\",\"query.invalid\",\"request.access-reason-required\",\"request.invalid\",\"request.timeout\",\"resource.not-found\",\"runtime.field-encryption.unavailable\",\"service.unavailable\",\"source.unavailable\",\"statistical-dataset.domain-violation\",\"statistical-dataset.release-refused\",\"statistical-dataset.version-conflict\",\"statistical-dataset.version-withdrawn\",\"unsupported.media-type\",\"write.outside-boundary\"],\"type\":\"string\"},\"constraintId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"constraintKind\":{\"enum\":[\"compare\",\"int-range\",\"vocabulary\"],\"type\":\"string\"},\"detail\":{\"maxLength\":256,\"type\":\"string\"},\"failedCheck\":{\"type\":\"string\"},\"field\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldPath\":{\"maxLength\":256,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"left\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"notAfterField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"reasonCode\":{\"enum\":[\"computation-error\",\"source-data-error\",\"disclosure-risk\"],\"type\":\"string\"},\"recordType\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"refusalCode\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"requiredFilters\":{\"items\":{\"items\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"maxItems\":32,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"maxItems\":8,\"minItems\":1,\"type\":\"array\"},\"right\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"status\":{\"maximum\":599,\"minimum\":400,\"type\":\"integer\"},\"title\":{\"maxLength\":128,\"type\":\"string\"},\"traceId\":{\"maxLength\":32,\"minLength\":32,\"pattern\":\"^[0-9a-f]{32}$\",\"type\":\"string\"},\"type\":{\"maxLength\":256,\"type\":\"string\"}},\"required\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\"],\"type\":\"object\"}")], + ["/components/schemas/Problem", JSON.parse("{\"additionalProperties\":false,\"allOf\":[{\"if\":{\"properties\":{\"code\":{\"enum\":[\"attachment.required\",\"attachment.verification-pending\",\"attachment.verification-rejected\"]}}},\"then\":{\"allOf\":[{\"else\":{\"properties\":{\"status\":{\"const\":422}}},\"if\":{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"}}},\"then\":{\"properties\":{\"status\":{\"const\":409}}}}],\"properties\":{\"fieldPath\":{\"pattern\":\"^/attachments/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"fieldPath\"]},\"required\":[\"fieldPath\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"}}},\"then\":{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"detail\":{\"const\":\"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.\"},\"status\":{\"const\":403},\"title\":{\"const\":\"Forbidden\"},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}},\"propertyNames\":{\"enum\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\",\"failedCheck\"]}}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"action.guard-failed\"}}}},\"then\":{\"not\":{\"required\":[\"guardReason\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.refused\"}}},\"then\":{\"properties\":{\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"}}},\"then\":{\"properties\":{\"refusalCode\":{\"enum\":[\"period-not-ended\",\"before-first-period\",\"provisional-after-final\",\"already-withdrawn\",\"negative-value\"]},\"status\":{\"const\":422}},\"required\":[\"refusalCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"enum\":[\"action.refused\",\"statistical-dataset.release-refused\"]}}}},\"then\":{\"not\":{\"required\":[\"refusalCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"}}},\"then\":{\"properties\":{\"status\":{\"const\":410}},\"required\":[\"reasonCode\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"statistical-dataset.version-withdrawn\"}}}},\"then\":{\"not\":{\"required\":[\"reasonCode\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"}}},\"then\":{\"additionalProperties\":true,\"not\":{\"required\":[\"failedCheck\"]},\"properties\":{\"status\":{\"const\":400}},\"required\":[\"accessProfiles\"]}},{\"if\":{\"properties\":{\"code\":{\"not\":{\"const\":\"access-profile.ambiguous\"}}}},\"then\":{\"not\":{\"required\":[\"accessProfiles\"]}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"}}},\"then\":{\"properties\":{\"detail\":{\"const\":\"The declared Evidence dependency could not be accepted.\"},\"fieldPath\":{\"pattern\":\"^/evidence/[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"status\":{\"const\":503}}}},{\"if\":{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"}}},\"then\":{\"properties\":{\"status\":{\"const\":500}}}},{\"if\":{\"anyOf\":[{\"required\":[\"atField\"]},{\"required\":[\"notAfterField\"]}]},\"then\":{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400}},\"required\":[\"atField\",\"notAfterField\"]}},{\"if\":{\"anyOf\":[{\"required\":[\"recordType\"]},{\"required\":[\"fieldId\"]},{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"then\":{\"oneOf\":[{\"not\":{\"anyOf\":[{\"required\":[\"constraintId\"]},{\"required\":[\"constraintKind\"]},{\"required\":[\"left\"]},{\"required\":[\"right\"]},{\"required\":[\"field\"]}]},\"required\":[\"fieldId\"]},{\"not\":{\"required\":[\"fieldId\"]},\"oneOf\":[{\"not\":{\"required\":[\"field\"]},\"properties\":{\"constraintKind\":{\"const\":\"compare\"}},\"required\":[\"left\",\"right\"]},{\"not\":{\"anyOf\":[{\"required\":[\"left\"]},{\"required\":[\"right\"]}]},\"properties\":{\"constraintKind\":{\"enum\":[\"int-range\",\"vocabulary\"]}},\"required\":[\"field\"]}],\"required\":[\"constraintId\",\"constraintKind\"]}],\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409}},\"required\":[\"recordType\"]}}],\"anyOf\":[{\"properties\":{\"code\":{\"const\":\"access-profile.ambiguous\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous\"}}},{\"properties\":{\"code\":{\"const\":\"action.evidence-failed\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/evidence-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.guard-failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/guard-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.handler-failed\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/handler-failed\"}}},{\"properties\":{\"code\":{\"const\":\"action.refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/action/refused\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.content-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/content-type\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.digest-mismatch\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.required\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/required\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.slot-write-once\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.too-large\"},\"status\":{\"const\":413},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/too-large\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-pending\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending\"}}},{\"properties\":{\"code\":{\"const\":\"attachment.verification-rejected\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected\"}}},{\"properties\":{\"code\":{\"const\":\"authentication.refused\"},\"status\":{\"const\":401},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/authentication/refused\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/expired\"}}},{\"properties\":{\"code\":{\"const\":\"idempotency.key-reused\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.chunk-mismatch\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.profile-mismatch\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.receipt-erased\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-blocked\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked\"}}},{\"properties\":{\"code\":{\"const\":\"ingestion.run-not-open\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open\"}}},{\"properties\":{\"code\":{\"const\":\"lookup.unresolved\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/lookup/unresolved\"}}},{\"properties\":{\"code\":{\"const\":\"mutation.conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/mutation/conflict\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.failed\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/failed\"}}},{\"properties\":{\"code\":{\"const\":\"precondition.required\"},\"status\":{\"const\":428},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/precondition/required\"}}},{\"properties\":{\"code\":{\"const\":\"profile.not-authorized\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/profile/not-authorized\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.form-limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.form-undeclared\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.message-limit-reached\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.rejected\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/rejected\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.review-result-mismatch\"},\"status\":{\"const\":412},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.subject-changed\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.subject-not-caller\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller\"}}},{\"properties\":{\"code\":{\"const\":\"proposal.submission-expired\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired\"}}},{\"properties\":{\"code\":{\"const\":\"query.cursor-invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid\"}}},{\"properties\":{\"code\":{\"const\":\"query.filter-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/filter-required\"}}},{\"properties\":{\"code\":{\"const\":\"query.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/query/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.access-reason-required\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/access-reason-required\"}}},{\"properties\":{\"code\":{\"const\":\"request.invalid\"},\"status\":{\"const\":400},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/invalid\"}}},{\"properties\":{\"code\":{\"const\":\"request.timeout\"},\"status\":{\"const\":504},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/request/timeout\"}}},{\"properties\":{\"code\":{\"const\":\"resource.not-found\"},\"status\":{\"const\":404},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/resource/not-found\"}}},{\"properties\":{\"code\":{\"const\":\"runtime.field-encryption.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"service.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/service/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"source.unavailable\"},\"status\":{\"const\":503},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/source/unavailable\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.domain-violation\"},\"status\":{\"const\":500},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.release-refused\"},\"status\":{\"const\":422},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-conflict\"},\"status\":{\"const\":409},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict\"}}},{\"properties\":{\"code\":{\"const\":\"statistical-dataset.version-withdrawn\"},\"status\":{\"const\":410},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn\"}}},{\"properties\":{\"code\":{\"const\":\"unsupported.media-type\"},\"status\":{\"const\":415},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/unsupported/media-type\"}}},{\"properties\":{\"code\":{\"const\":\"write.outside-boundary\"},\"status\":{\"const\":403},\"type\":{\"const\":\"https://id.registrystack.org/problems/registry-breg/write/outside-boundary\"}}}],\"properties\":{\"accessProfiles\":{\"items\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"atField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"code\":{\"enum\":[\"access-profile.ambiguous\",\"action.evidence-failed\",\"action.guard-failed\",\"action.handler-failed\",\"action.refused\",\"attachment.content-type\",\"attachment.digest-mismatch\",\"attachment.limit-reached\",\"attachment.required\",\"attachment.slot-write-once\",\"attachment.too-large\",\"attachment.verification-pending\",\"attachment.verification-rejected\",\"authentication.refused\",\"idempotency.expired\",\"idempotency.key-reused\",\"ingestion.chunk-mismatch\",\"ingestion.profile-mismatch\",\"ingestion.receipt-erased\",\"ingestion.run-blocked\",\"ingestion.run-not-open\",\"lookup.unresolved\",\"mutation.conflict\",\"precondition.failed\",\"precondition.required\",\"profile.not-authorized\",\"proposal.form-limit-reached\",\"proposal.form-undeclared\",\"proposal.message-limit-reached\",\"proposal.rejected\",\"proposal.review-result-mismatch\",\"proposal.subject-changed\",\"proposal.subject-not-caller\",\"proposal.submission-expired\",\"query.cursor-invalid\",\"query.filter-required\",\"query.invalid\",\"request.access-reason-required\",\"request.invalid\",\"request.timeout\",\"resource.not-found\",\"runtime.field-encryption.unavailable\",\"service.unavailable\",\"source.unavailable\",\"statistical-dataset.domain-violation\",\"statistical-dataset.release-refused\",\"statistical-dataset.version-conflict\",\"statistical-dataset.version-withdrawn\",\"unsupported.media-type\",\"write.outside-boundary\"],\"type\":\"string\"},\"constraintId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"constraintKind\":{\"enum\":[\"compare\",\"int-range\",\"vocabulary\"],\"type\":\"string\"},\"detail\":{\"maxLength\":256,\"type\":\"string\"},\"failedCheck\":{\"type\":\"string\"},\"field\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldId\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"fieldPath\":{\"maxLength\":256,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"left\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"notAfterField\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"reasonCode\":{\"enum\":[\"computation-error\",\"source-data-error\",\"disclosure-risk\"],\"type\":\"string\"},\"recordType\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"refusalCode\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"requiredFilters\":{\"items\":{\"items\":{\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"maxItems\":32,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"maxItems\":8,\"minItems\":1,\"type\":\"array\"},\"right\":{\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"status\":{\"maximum\":599,\"minimum\":400,\"type\":\"integer\"},\"title\":{\"maxLength\":128,\"type\":\"string\"},\"traceId\":{\"maxLength\":32,\"minLength\":32,\"pattern\":\"^[0-9a-f]{32}$\",\"type\":\"string\"},\"type\":{\"maxLength\":256,\"type\":\"string\"}},\"required\":[\"type\",\"title\",\"status\",\"detail\",\"code\",\"traceId\"],\"type\":\"object\"}")], ["/components/schemas/ReviewCompletion", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"completedAt\":{\"type\":\"string\"},\"eventId\":{\"type\":\"string\"},\"requestId\":{\"type\":\"string\"},\"resultId\":{\"type\":\"string\"},\"type\":{\"const\":\"review.completed\"}},\"required\":[\"type\",\"eventId\",\"requestId\",\"resultId\",\"completedAt\"],\"type\":\"object\"}")], ["/components/schemas/action-register-contact-invoke-input", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"email\":{\"maxLength\":254,\"minLength\":1,\"type\":\"string\"},\"jurisdiction\":{\"maxLength\":40,\"minLength\":1,\"type\":\"string\"},\"name\":{\"maxLength\":160,\"minLength\":1,\"type\":\"string\"}},\"required\":[],\"type\":\"object\"}},\"required\":[\"input\"],\"type\":\"object\"}")], - ["/components/schemas/action-register-contact-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/components/schemas/action-register-contact-invoke-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/components/schemas/action-update-contact-email-availability-input", JSON.parse("{\"additionalProperties\":false,\"oneOf\":[{\"properties\":{\"input\":{\"properties\":{\"contactId\":{\"type\":\"string\"}},\"required\":[\"contactId\"]},\"targetInput\":{\"const\":\"contactId\"}}}],\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"contactId\":{\"type\":\"string\"},\"email\":{\"maxLength\":254,\"minLength\":1,\"type\":\"string\"}},\"required\":[],\"type\":\"object\"},\"targetInput\":{\"enum\":[\"contactId\"],\"type\":\"string\"}},\"required\":[\"targetInput\",\"input\"],\"type\":\"object\"}")], ["/components/schemas/action-update-contact-email-availability-response", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"availability\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"available\":{\"const\":true},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"available\",\"observedRevision\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"const\":false},\"guardLabel\":{\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"guardReason\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"const\":\"guard-not-satisfied\"},\"recovery\":{\"const\":\"none\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"type\":\"null\"},\"missingInputs\":{\"items\":{\"enum\":[\"contactId\",\"email\"],\"type\":\"string\"},\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"const\":\"input-required\"},\"recovery\":{\"const\":\"correct-input\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\",\"missingInputs\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"available\":{\"type\":\"null\"},\"observedRevision\":{\"type\":\"null\"},\"reason\":{\"const\":\"not-disclosed\"},\"recovery\":{\"const\":\"none\"}},\"required\":[\"available\",\"observedRevision\",\"reason\",\"recovery\"],\"type\":\"object\"}]}},\"required\":[\"availability\"],\"type\":\"object\"}")], ["/components/schemas/action-update-contact-email-invoke-input", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"input\":{\"additionalProperties\":false,\"properties\":{\"contactId\":{\"type\":\"string\"},\"email\":{\"maxLength\":254,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"contactId\",\"email\"],\"type\":\"object\"},\"preconditions\":{\"additionalProperties\":false,\"properties\":{\"contactId\":{\"additionalProperties\":false,\"properties\":{\"ifMatch\":{\"maxLength\":256,\"minLength\":3,\"pattern\":\"^\\\"[\\\\x21\\\\x23-\\\\x7E]+\\\"$\",\"type\":\"string\"}},\"required\":[\"ifMatch\"],\"type\":\"object\"}},\"required\":[\"contactId\"],\"type\":\"object\"}},\"required\":[\"input\",\"preconditions\"],\"type\":\"object\"}")], @@ -118,21 +118,21 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1actions~1update-contact-email~1target-conditions/post/responses/415/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], ["/paths/~1v1~1actions~1update-contact-email~1target-conditions/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], ["/paths/~1v1~1actions~1update-contact-email~1target-conditions/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"$ref\":\"/components/schemas/Problem\"}")], - ["/paths/~1v1~1proposals/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"items\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"},\"maxItems\":100,\"type\":\"array\"},\"nextCursor\":{\"type\":\"string\"}},\"required\":[\"items\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"items\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"},\"maxItems\":100,\"type\":\"array\"},\"nextCursor\":{\"type\":\"string\"}},\"required\":[\"items\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals/get/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"query.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"dependentRequired\":{\"appliedAt\":[\"appliedBy\"],\"appliedBy\":[\"appliedAt\"]},\"properties\":{\"applicationId\":{\"type\":\"string\"},\"appliedAt\":{\"type\":\"string\"},\"appliedBy\":{\"pattern\":\"^hmac-sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"dependentRequired\":{\"appliedAt\":[\"appliedBy\"],\"appliedBy\":[\"appliedAt\"]},\"properties\":{\"applicationId\":{\"type\":\"string\"},\"appliedAt\":{\"type\":\"string\"},\"appliedBy\":{\"pattern\":\"^hmac-sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -144,7 +144,7 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/428/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.required\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1cancel/post/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1edit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], @@ -164,12 +164,12 @@ const rules: Record = Object.fromEntries([ ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/410/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"proposal.submission-expired\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/503/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"service.unavailable\",\"source.unavailable\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submissions~1{submission_version}/get/responses/504/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"request.timeout\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/200/content/application~1json/schema", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"actionId\":{\"type\":\"string\"},\"actionRevision\":{\"type\":\"string\"},\"application\":{\"additionalProperties\":false,\"properties\":{\"applicationId\":{\"type\":\"string\"},\"effectDigest\":{\"pattern\":\"^sha256:[0-9a-f]{64}$\",\"type\":\"string\"},\"resultLinks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"recordId\":{\"type\":\"string\"},\"recordType\":{\"type\":\"string\"},\"revision\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"recordType\",\"recordId\",\"revision\"],\"type\":\"object\"},\"maxItems\":16,\"type\":\"array\"},\"submissionVersion\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"applicationId\",\"submissionVersion\",\"effectDigest\",\"resultLinks\"],\"type\":\"object\"},\"applicationStatus\":{\"additionalProperties\":false,\"properties\":{\"automaticRetry\":{\"additionalProperties\":false,\"properties\":{\"attempts\":{\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"maximumAttempts\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"scheduled\":{\"type\":\"boolean\"}},\"required\":[\"scheduled\",\"attempts\",\"maximumAttempts\"],\"type\":\"object\"},\"mode\":{\"enum\":[\"automatic\",\"manual\"]},\"reason\":{\"enum\":[\"package-changed\",\"dependency-outage\",\"lease-expired\",\"application-refused\",\"attempts-exhausted\"]},\"recovery\":{\"enum\":[\"retry\",\"rebase\",\"revise\",\"correct-input\"]},\"state\":{\"enum\":[\"awaiting-review\",\"pending\",\"applying\",\"blocked\",\"applied\",\"cancelled\",\"rejected\"]}},\"required\":[\"state\",\"mode\"],\"type\":\"object\"},\"asks\":{\"items\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"additions\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"answeredAt\":{\"type\":\"string\"},\"formEntries\":{\"items\":{\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\",\"uniqueItems\":true},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"additions\",\"answeredAt\"],\"type\":\"object\"},\"askedAt\":{\"type\":\"string\"},\"dueAt\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":false,\"properties\":{\"answer\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"const\":\"POST\"},\"operation\":{\"const\":\"answer\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\",\"ifMatch\",\"availability\"],\"type\":\"object\"}},\"type\":\"object\"},\"state\":{\"enum\":[\"open\",\"answered\",\"expired\",\"closed\"]},\"text\":{\"maxLength\":2000,\"minLength\":1,\"type\":\"string\"},\"wants\":{\"items\":{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"enum\":[\"answer\",\"document\"]}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"form\":{\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"},\"kind\":{\"const\":\"form\"}},\"required\":[\"kind\",\"form\"],\"type\":\"object\"}]},\"maxItems\":8,\"type\":\"array\",\"uniqueItems\":true}},\"required\":[\"id\",\"text\",\"wants\",\"askedAt\",\"state\",\"links\"],\"type\":\"object\"},\"maxItems\":50,\"type\":\"array\"},\"attachments\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"classification\":{\"enum\":[\"public\",\"internal\",\"restricted\"]},\"contentTypes\":{\"items\":{\"type\":\"string\"},\"maxItems\":16,\"minItems\":1,\"type\":\"array\",\"uniqueItems\":true},\"id\":{\"type\":\"string\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"PATCH\",\"DELETE\"]},\"operation\":{\"enum\":[\"download\",\"upload\",\"remove\"]},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"maximumBytes\":{\"maximum\":16777216,\"minimum\":1,\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"},\"value\":{\"additionalProperties\":false,\"properties\":{\"byteSize\":{\"minimum\":1,\"type\":\"integer\"},\"contentType\":{\"type\":\"string\"},\"sha256\":{\"pattern\":\"^[a-f0-9]{64}$\",\"type\":\"string\"},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"uploadedAt\":{\"type\":\"string\"},\"verificationStatus\":{\"enum\":[\"notRequired\",\"pending\",\"approved\",\"rejected\"]}},\"required\":[\"submissionVersion\",\"sha256\",\"contentType\",\"byteSize\",\"verificationStatus\"],\"type\":\"object\"}},\"required\":[\"id\",\"required\",\"maximumBytes\",\"contentTypes\",\"classification\",\"links\"],\"type\":\"object\"},\"maxProperties\":8,\"type\":\"object\"},\"blockedReason\":{\"enum\":[\"package-changed\"]},\"createdAt\":{\"type\":\"string\"},\"decision\":{\"additionalProperties\":false,\"properties\":{\"decidedAt\":{\"type\":\"string\"},\"publicReason\":{\"minLength\":1,\"pattern\":\"^[^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*[^\\\\u0000-\\\\u0020\\\\u007F-\\\\u00A0\\\\u1680\\\\u2000-\\\\u200A\\\\u2028\\\\u2029\\\\u202F\\\\u205F\\\\u3000][^\\\\u0000-\\\\u001F\\\\u007F-\\\\u009F]*$\",\"type\":\"string\"},\"status\":{\"enum\":[\"approved\",\"rejected\",\"changes-requested\",\"answered\"]}},\"required\":[\"status\",\"decidedAt\"],\"type\":\"object\"},\"effectDigest\":{\"type\":\"string\"},\"handoffRefusal\":{\"additionalProperties\":false,\"properties\":{\"code\":{\"enum\":[\"review.initiator-required\",\"review.initiator-excluded\",\"review.policy-mismatch\",\"review.refused\"]}},\"required\":[\"code\"],\"type\":\"object\"},\"id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\"},\"links\":{\"additionalProperties\":{\"additionalProperties\":false,\"properties\":{\"accessProfile\":{\"type\":\"string\"},\"availability\":{\"additionalProperties\":false,\"if\":{\"properties\":{\"available\":{\"const\":false}}},\"properties\":{\"available\":{\"type\":\"boolean\"},\"observedRevision\":{\"minimum\":1,\"type\":\"integer\"},\"reason\":{\"enum\":[\"pending-review\",\"review-rejected\",\"review-changes-requested\",\"review-ended\",\"stale-revision\",\"package-changed\",\"dependency-outage\",\"invalid-input\",\"already-applied\",\"limit-reached\",\"application-pending\",\"attachment-required\",\"attachment-pending\",\"ask-answered\",\"ask-closed\",\"ask-due-passed\"]},\"recovery\":{\"enum\":[\"refresh\",\"revise\",\"retry\",\"rebase\",\"correct-input\",\"receipt-only\"]}},\"required\":[\"available\",\"observedRevision\"],\"then\":{\"required\":[\"reason\",\"recovery\"]},\"type\":\"object\"},\"ifMatch\":{\"type\":\"string\"},\"method\":{\"enum\":[\"GET\",\"POST\"]},\"operation\":{\"type\":\"string\"},\"path\":{\"type\":\"string\"}},\"required\":[\"method\",\"path\",\"accessProfile\",\"operation\"],\"type\":\"object\"},\"type\":\"object\"},\"partyRole\":{\"enum\":[\"owner\",\"subject\"]},\"revision\":{\"minimum\":1,\"type\":\"integer\"},\"state\":{\"enum\":[\"draft\",\"submitted\",\"applied\",\"cancelled\",\"rejected\"]},\"status\":{\"enum\":[\"draft\",\"awaiting-party\",\"in-review\",\"approved\",\"processing\",\"applied\",\"rejected\",\"cancelled\"]},\"submissionVersion\":{\"minimum\":0,\"type\":\"integer\"},\"title\":{\"maxLength\":1024,\"type\":\"string\"},\"turn\":{\"enum\":[\"party\",\"official\",\"nobody\"]}},\"required\":[\"id\",\"actionId\",\"actionRevision\",\"submissionVersion\",\"revision\",\"state\",\"turn\",\"links\"],\"type\":\"object\"}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/400/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"access-profile.ambiguous\",\"request.invalid\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/401/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"authentication.refused\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\"]}},\"type\":\"object\"}]}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/403/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"profile.not-authorized\",\"proposal.subject-not-caller\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/404/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"resource.not-found\"]}},\"type\":\"object\"}]}")], - ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/409/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"idempotency.key-reused\",\"mutation.conflict\",\"proposal.rejected\"]}},\"type\":\"object\"}]}")], + ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/409/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"idempotency.key-reused\",\"mutation.conflict\",\"proposal.rejected\",\"proposal.subject-changed\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/410/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"idempotency.expired\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/412/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"precondition.failed\"]}},\"type\":\"object\"}]}")], ["/paths/~1v1~1proposals~1{proposal_id}~1submit/post/responses/415/content/application~1problem+json/schema", JSON.parse("{\"allOf\":[{\"$ref\":\"/components/schemas/Problem\"},{\"properties\":{\"code\":{\"enum\":[\"unsupported.media-type\"]}},\"type\":\"object\"}]}")], @@ -258,7 +258,7 @@ export class Client { if (!route) throw new TypeError("Unknown operation") return this.#transport.call(route, options) } - async proposals_listPage(options: Operations["proposals.list"]["input"] = {}, cursor?: string): Promise); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<({ "kind": ("answer" | "document") })>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>> { + async proposals_listPage(options: Operations["proposals.list"]["input"] = {}, cursor?: string): Promise); "submissionVersion": (number) }); "applicationStatus"?: ({ "automaticRetry"?: ({ "attempts": (number); "maximumAttempts": (number); "scheduled": (boolean) }); "mode": ("automatic" | "manual"); "reason"?: ("package-changed" | "dependency-outage" | "lease-expired" | "application-refused" | "attempts-exhausted"); "recovery"?: ("retry" | "rebase" | "revise" | "correct-input"); "state": ("awaiting-review" | "pending" | "applying" | "blocked" | "applied" | "cancelled" | "rejected") }); "asks"?: (Array<({ "answer"?: ({ "additions": (Array<(string)>); "answeredAt": (string); "formEntries"?: (Array<(string)>); "text"?: (string) }); "askedAt": (string); "dueAt"?: (string); "id": (string); "links": ({ "answer"?: ({ "accessProfile": (string); "availability": ({ "available": (boolean); "observedRevision": (number); "reason"?: ("pending-review" | "review-rejected" | "review-changes-requested" | "review-ended" | "stale-revision" | "package-changed" | "dependency-outage" | "invalid-input" | "already-applied" | "limit-reached" | "application-pending" | "attachment-required" | "attachment-pending" | "ask-answered" | "ask-closed" | "ask-due-passed"); "recovery"?: ("refresh" | "revise" | "retry" | "rebase" | "correct-input" | "receipt-only") }); "ifMatch": (string); "method": "POST"; "operation": "answer"; "path": (string) }) }); "state": ("open" | "answered" | "expired" | "closed"); "text": (string); "wants": (Array<(({ "kind": ("answer" | "document") }) | ({ "form": (string); "kind": "form" }))>) })>); "attachments"?: (Record); "id": (string); "links": (Record); "maximumBytes": (number); "required": (boolean); "value"?: ({ "byteSize": (number); "contentType": (string); "sha256": (string); "submissionVersion": (number); "uploadedAt"?: (string); "verificationStatus": ("notRequired" | "pending" | "approved" | "rejected") }) })>); "blockedReason"?: ("package-changed"); "createdAt"?: (string); "decision"?: ({ "decidedAt": (string); "publicReason"?: (string); "status": ("approved" | "rejected" | "changes-requested" | "answered") }); "effectDigest"?: (string); "handoffRefusal"?: ({ "code": ("review.initiator-required" | "review.initiator-excluded" | "review.policy-mismatch" | "review.refused") }); "id": (string); "input"?: (Record); "links": (Record); "partyRole"?: ("owner" | "subject"); "revision": (number); "state": ("draft" | "submitted" | "applied" | "cancelled" | "rejected"); "status"?: ("draft" | "awaiting-party" | "in-review" | "approved" | "processing" | "applied" | "rejected" | "cancelled"); "submissionVersion": (number); "title"?: (string); "turn": ("party" | "official" | "nobody") })>> { const { data } = await this.call("proposals.list", { ...options, query: cursor === undefined ? options.query : { ...options.query, cursor } }) return { items: data.items, nextCursor: data.nextCursor ?? null } } From 325ad23e6bb328b774d560511060f6e9f2661a05 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 06:11:17 +0000 Subject: [PATCH 43/96] fix(breg): sync the required-attachment OpenAPI example Signed-off-by: Jeremi Joslin --- products/breg/examples/required-attachment/openapi.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/breg/examples/required-attachment/openapi.json b/products/breg/examples/required-attachment/openapi.json index 0fa3c3004e..5085345f1c 100644 --- a/products/breg/examples/required-attachment/openapi.json +++ b/products/breg/examples/required-attachment/openapi.json @@ -1 +1 @@ -{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.rejected","proposal.review-result-mismatch","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-correct-name-invoke-input":{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]},"action-correct-name-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"target":{"$id":"urn:breg:record-type:target","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"required":["name","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable","x-registry-mutationPolicy":{"patch":"proposal-required"}},"target-create-input":{"$id":"urn:breg:record-type:target:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"required":["name","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"required-attachment","version":"1"},"openapi":"3.1.0","paths":{"/v1/actions/correct-name/proposals":{"post":{"operationId":"actions.correct-name.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-name-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-name-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-action":{"access":{"accessProfiles":["clerk"]},"apiName":"correctName","attachments":[{"contentTypes":["text/plain"],"id":"support","maximumBytes":4096,"required":true}],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{},"execution":{"application":"manual","mode":"proposal","review":"none"},"id":"correct-name","inputMode":"fixed","inputs":[{"apiName":"target","classification":"internal","fieldType":{"onDelete":"restrict","target":"target","type":"reference"},"id":"target","label":"target","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"value","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"value","label":"value","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":0,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"target","input":"target","targetRecordType":"target"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"name","operation":"patch","recordType":"target"}],"revision":"sha256:bc33d44acbc56e239cd2c88aa76698302a40bba0bf7298b80317a82c9fc4cb36","route":"/v1/actions/correct-name/proposals","routes":{"availability":null,"start":{"inputSchema":"action-correct-name-invoke-input","method":"POST","operationId":"actions.correct-name.start","path":"/v1/actions/correct-name/proposals","requiresIdempotencyKey":true,"responseSchema":"action-correct-name-invoke-response"}}},"x-registry-defaultAccessProfile":"clerk","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/apply":{"post":{"operationId":"proposals.apply","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"reason":{"description":"Optional application explanation, preserved unchanged. At most 4096 Unicode characters; NUL is refused.","maxLength":4096,"pattern":"^[^\\u0000]*$","type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["submissionVersion","effectDigest"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/attachments/support":{"delete":{"operationId":"proposals.attachments.support.delete","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]},"get":{"operationId":"proposals.attachments.support.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"query","name":"submissionVersion","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"reviewContextField","required":false,"schema":{"pattern":"^[a-z][a-zA-Z0-9]{0,63}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"effectDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"contextSchemaDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}}],"responses":{"200":{"content":{"*/*":{"schema":{"contentMediaType":"application/octet-stream","maxLength":16777216,"type":"string"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]},"patch":{"operationId":"proposals.attachments.support.patch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"text/plain":{"schema":{"format":"binary","maxLength":4096,"type":"string"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"413":{"content":{"application/problem+json":{"examples":{"attachment.too-large":{"value":{"code":"attachment.too-large","detail":"The file is larger than the attachment slot accepts.","status":413,"title":"Content Too Large","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.too-large"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"attachment.content-type":{"value":{"code":"attachment.content-type","detail":"The file media type is not one the attachment slot accepts.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.content-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/rebase":{"post":{"operationId":"proposals.rebase","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/revise":{"post":{"operationId":"proposals.revise","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]},{"additionalProperties":false,"type":"object"}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"attachment.verification-pending":{"value":{"code":"attachment.verification-pending","detail":"The attachment is awaiting verification. Refresh the Proposal before submitting.","fieldPath":"/attachments/support","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}},"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.verification-pending","idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"422":{"content":{"application/problem+json":{"examples":{"attachment.required":{"value":{"code":"attachment.required","detail":"The required attachment slot is empty.","fieldPath":"/attachments/support","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/records/targets":{"get":{"operationId":"records.target.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"clerk":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"clerk","requiredFilters":[],"selectableProperties":["jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.target.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/target-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/target"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/target"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"create","x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/targets/{record_id}":{"get":{"operationId":"records.target.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"get","x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file +{"components":{"schemas":{"ImmediateActionPrecondition":{"additionalProperties":false,"properties":{"ifMatch":{"maxLength":256,"minLength":3,"pattern":"^\\\"[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"required":["ifMatch"],"type":"object"},"ImmediateActionResultReference":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"format":"int64","minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"Problem":{"additionalProperties":false,"allOf":[{"if":{"properties":{"code":{"enum":["attachment.required","attachment.verification-pending","attachment.verification-rejected"]}}},"then":{"allOf":[{"else":{"properties":{"status":{"const":422}}},"if":{"properties":{"code":{"const":"attachment.verification-pending"}}},"then":{"properties":{"status":{"const":409}}}}],"properties":{"fieldPath":{"pattern":"^/attachments/[a-z][a-z0-9_-]{0,63}$","type":"string"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","fieldPath"]},"required":["fieldPath"]}},{"if":{"properties":{"code":{"const":"write.outside-boundary"}}},"then":{"properties":{"code":{"const":"write.outside-boundary"},"detail":{"const":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition."},"status":{"const":403},"title":{"const":"Forbidden"},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}},"propertyNames":{"enum":["type","title","status","detail","code","traceId","failedCheck"]}}},{"if":{"properties":{"code":{"not":{"const":"action.guard-failed"}}}},"then":{"not":{"required":["guardReason"]}}},{"if":{"properties":{"code":{"const":"action.refused"}}},"then":{"properties":{"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"const":"statistical-dataset.release-refused"}}},"then":{"properties":{"refusalCode":{"enum":["period-not-ended","before-first-period","provisional-after-final","already-withdrawn","negative-value"]},"status":{"const":422}},"required":["refusalCode"]}},{"if":{"properties":{"code":{"not":{"enum":["action.refused","statistical-dataset.release-refused"]}}}},"then":{"not":{"required":["refusalCode"]}}},{"if":{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"}}},"then":{"properties":{"status":{"const":410}},"required":["reasonCode"]}},{"if":{"properties":{"code":{"not":{"const":"statistical-dataset.version-withdrawn"}}}},"then":{"not":{"required":["reasonCode"]}}},{"if":{"properties":{"code":{"const":"access-profile.ambiguous"}}},"then":{"additionalProperties":true,"not":{"required":["failedCheck"]},"properties":{"status":{"const":400}},"required":["accessProfiles"]}},{"if":{"properties":{"code":{"not":{"const":"access-profile.ambiguous"}}}},"then":{"not":{"required":["accessProfiles"]}}},{"if":{"properties":{"code":{"const":"action.evidence-failed"}}},"then":{"properties":{"detail":{"const":"The declared Evidence dependency could not be accepted."},"fieldPath":{"pattern":"^/evidence/[a-z][a-z0-9_-]{0,63}$","type":"string"},"status":{"const":503}}}},{"if":{"properties":{"code":{"const":"action.handler-failed"}}},"then":{"properties":{"status":{"const":500}}}},{"if":{"anyOf":[{"required":["atField"]},{"required":["notAfterField"]}]},"then":{"properties":{"code":{"const":"request.invalid"},"status":{"const":400}},"required":["atField","notAfterField"]}},{"if":{"anyOf":[{"required":["recordType"]},{"required":["fieldId"]},{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"then":{"oneOf":[{"not":{"anyOf":[{"required":["constraintId"]},{"required":["constraintKind"]},{"required":["left"]},{"required":["right"]},{"required":["field"]}]},"required":["fieldId"]},{"not":{"required":["fieldId"]},"oneOf":[{"not":{"required":["field"]},"properties":{"constraintKind":{"const":"compare"}},"required":["left","right"]},{"not":{"anyOf":[{"required":["left"]},{"required":["right"]}]},"properties":{"constraintKind":{"enum":["int-range","vocabulary"]}},"required":["field"]}],"required":["constraintId","constraintKind"]}],"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409}},"required":["recordType"]}}],"anyOf":[{"properties":{"code":{"const":"access-profile.ambiguous"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},{"properties":{"code":{"const":"action.evidence-failed"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/evidence-failed"}}},{"properties":{"code":{"const":"action.guard-failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/guard-failed"}}},{"properties":{"code":{"const":"action.handler-failed"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/handler-failed"}}},{"properties":{"code":{"const":"action.refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/action/refused"}}},{"properties":{"code":{"const":"attachment.content-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},{"properties":{"code":{"const":"attachment.digest-mismatch"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/digest-mismatch"}}},{"properties":{"code":{"const":"attachment.limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/limit-reached"}}},{"properties":{"code":{"const":"attachment.required"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},{"properties":{"code":{"const":"attachment.slot-write-once"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/slot-write-once"}}},{"properties":{"code":{"const":"attachment.too-large"},"status":{"const":413},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},{"properties":{"code":{"const":"attachment.verification-pending"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}}},{"properties":{"code":{"const":"attachment.verification-rejected"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/attachment/verification-rejected"}}},{"properties":{"code":{"const":"authentication.refused"},"status":{"const":401},"type":{"const":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},{"properties":{"code":{"const":"idempotency.expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},{"properties":{"code":{"const":"idempotency.key-reused"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}}},{"properties":{"code":{"const":"ingestion.chunk-mismatch"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/chunk-mismatch"}}},{"properties":{"code":{"const":"ingestion.profile-mismatch"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/profile-mismatch"}}},{"properties":{"code":{"const":"ingestion.receipt-erased"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/receipt-erased"}}},{"properties":{"code":{"const":"ingestion.run-blocked"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-blocked"}}},{"properties":{"code":{"const":"ingestion.run-not-open"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/ingestion/run-not-open"}}},{"properties":{"code":{"const":"lookup.unresolved"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/lookup/unresolved"}}},{"properties":{"code":{"const":"mutation.conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},{"properties":{"code":{"const":"precondition.failed"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},{"properties":{"code":{"const":"precondition.required"},"status":{"const":428},"type":{"const":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},{"properties":{"code":{"const":"profile.not-authorized"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},{"properties":{"code":{"const":"proposal.form-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-limit-reached"}}},{"properties":{"code":{"const":"proposal.form-undeclared"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/form-undeclared"}}},{"properties":{"code":{"const":"proposal.message-limit-reached"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/message-limit-reached"}}},{"properties":{"code":{"const":"proposal.rejected"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},{"properties":{"code":{"const":"proposal.review-result-mismatch"},"status":{"const":412},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/review-result-mismatch"}}},{"properties":{"code":{"const":"proposal.subject-changed"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},{"properties":{"code":{"const":"proposal.subject-not-caller"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},{"properties":{"code":{"const":"proposal.submission-expired"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},{"properties":{"code":{"const":"query.cursor-invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}}},{"properties":{"code":{"const":"query.filter-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/filter-required"}}},{"properties":{"code":{"const":"query.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},{"properties":{"code":{"const":"request.access-reason-required"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/access-reason-required"}}},{"properties":{"code":{"const":"request.invalid"},"status":{"const":400},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},{"properties":{"code":{"const":"request.timeout"},"status":{"const":504},"type":{"const":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},{"properties":{"code":{"const":"resource.not-found"},"status":{"const":404},"type":{"const":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},{"properties":{"code":{"const":"runtime.field-encryption.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/runtime/field-encryption/unavailable"}}},{"properties":{"code":{"const":"service.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},{"properties":{"code":{"const":"source.unavailable"},"status":{"const":503},"type":{"const":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},{"properties":{"code":{"const":"statistical-dataset.domain-violation"},"status":{"const":500},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/domain-violation"}}},{"properties":{"code":{"const":"statistical-dataset.release-refused"},"status":{"const":422},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/release-refused"}}},{"properties":{"code":{"const":"statistical-dataset.version-conflict"},"status":{"const":409},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-conflict"}}},{"properties":{"code":{"const":"statistical-dataset.version-withdrawn"},"status":{"const":410},"type":{"const":"https://id.registrystack.org/problems/registry-breg/statistical-dataset/version-withdrawn"}}},{"properties":{"code":{"const":"unsupported.media-type"},"status":{"const":415},"type":{"const":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},{"properties":{"code":{"const":"write.outside-boundary"},"status":{"const":403},"type":{"const":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}}],"properties":{"accessProfiles":{"items":{"maxLength":128,"minLength":1,"type":"string"},"minItems":2,"type":"array","uniqueItems":true},"atField":{"maxLength":128,"minLength":1,"type":"string"},"code":{"enum":["access-profile.ambiguous","action.evidence-failed","action.guard-failed","action.handler-failed","action.refused","attachment.content-type","attachment.digest-mismatch","attachment.limit-reached","attachment.required","attachment.slot-write-once","attachment.too-large","attachment.verification-pending","attachment.verification-rejected","authentication.refused","idempotency.expired","idempotency.key-reused","ingestion.chunk-mismatch","ingestion.profile-mismatch","ingestion.receipt-erased","ingestion.run-blocked","ingestion.run-not-open","lookup.unresolved","mutation.conflict","precondition.failed","precondition.required","profile.not-authorized","proposal.form-limit-reached","proposal.form-undeclared","proposal.message-limit-reached","proposal.rejected","proposal.review-result-mismatch","proposal.subject-changed","proposal.subject-not-caller","proposal.submission-expired","query.cursor-invalid","query.filter-required","query.invalid","request.access-reason-required","request.invalid","request.timeout","resource.not-found","runtime.field-encryption.unavailable","service.unavailable","source.unavailable","statistical-dataset.domain-violation","statistical-dataset.release-refused","statistical-dataset.version-conflict","statistical-dataset.version-withdrawn","unsupported.media-type","write.outside-boundary"],"type":"string"},"constraintId":{"maxLength":128,"minLength":1,"type":"string"},"constraintKind":{"enum":["compare","int-range","vocabulary"],"type":"string"},"detail":{"maxLength":256,"type":"string"},"failedCheck":{"description":"The check that refused the request, included only in development.","type":"string"},"field":{"maxLength":128,"minLength":1,"type":"string"},"fieldId":{"maxLength":128,"minLength":1,"type":"string"},"fieldPath":{"maxLength":256,"type":"string"},"guardReason":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"left":{"maxLength":128,"minLength":1,"type":"string"},"notAfterField":{"maxLength":128,"minLength":1,"type":"string"},"reasonCode":{"enum":["computation-error","source-data-error","disclosure-risk"],"type":"string"},"recordType":{"maxLength":128,"minLength":1,"type":"string"},"refusalCode":{"maxLength":128,"minLength":1,"type":"string"},"requiredFilters":{"items":{"items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"maxItems":8,"minItems":1,"type":"array"},"right":{"maxLength":128,"minLength":1,"type":"string"},"status":{"maximum":599,"minimum":400,"type":"integer"},"title":{"maxLength":128,"type":"string"},"traceId":{"maxLength":32,"minLength":32,"pattern":"^[0-9a-f]{32}$","type":"string"},"type":{"format":"uri","maxLength":256,"type":"string"}},"required":["type","title","status","detail","code","traceId"],"type":"object"},"ReviewCompletion":{"additionalProperties":false,"properties":{"completedAt":{"format":"date-time","type":"string"},"eventId":{"format":"uuid","type":"string"},"requestId":{"format":"uuid","type":"string"},"resultId":{"format":"uuid","type":"string"},"type":{"const":"review.completed"}},"required":["type","eventId","requestId","resultId","completedAt"],"type":"object"},"action-correct-name-invoke-input":{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]},"action-correct-name-invoke-response":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"target":{"$id":"urn:breg:record-type:target","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"required":["name","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable","x-registry-mutationPolicy":{"patch":"proposal-required"}},"target-create-input":{"$id":"urn:breg:record-type:target:input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"required":["name","jurisdiction"],"type":"object","x-registry-mutationMode":"mutable"}},"securitySchemes":{"bearerAuth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"},"reviewCompletion":{"description":"The review authority's configured completion key verifies the Standard Webhooks signature.","in":"header","name":"webhook-signature","type":"apiKey"}}},"info":{"title":"required-attachment","version":"1"},"openapi":"3.1.0","paths":{"/v1/actions/correct-name/proposals":{"post":{"operationId":"actions.correct-name.start","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to the action route, selected profile, package revision, normalized action input, preconditions, and granted result contract.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-name-invoke-input"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/action-correct-name-invoke-response"}}},"description":"Proposal created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag for the created Proposal.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Location":{"description":"Relative URL of the created Proposal.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-action":{"access":{"accessProfiles":["clerk"]},"apiName":"correctName","attachments":[{"contentTypes":["text/plain"],"id":"support","maximumBytes":4096,"required":true}],"bounds":{"maximumFieldMutations":128,"maximumSnapshotBytes":2097152,"maximumTargets":16},"display":{},"execution":{"application":"manual","mode":"proposal","review":"none"},"id":"correct-name","inputMode":"fixed","inputs":[{"apiName":"target","classification":"internal","fieldType":{"onDelete":"restrict","target":"target","type":"reference"},"id":"target","label":"target","nullable":false,"required":true,"schema":{"format":"uuid","type":"string"}},{"apiName":"value","classification":"internal","fieldType":{"maximumLength":64,"minimumLength":0,"type":"string"},"id":"value","label":"value","nullable":false,"required":true,"schema":{"maxLength":64,"minLength":0,"type":"string"}}],"maximumInputStringBytes":null,"referenceInputs":[{"apiName":"target","input":"target","targetRecordType":"target"}],"requiredConditionKeys":[],"resultEffects":[{"effect":"name","operation":"patch","recordType":"target"}],"revision":"sha256:bc33d44acbc56e239cd2c88aa76698302a40bba0bf7298b80317a82c9fc4cb36","route":"/v1/actions/correct-name/proposals","routes":{"availability":null,"start":{"inputSchema":"action-correct-name-invoke-input","method":"POST","operationId":"actions.correct-name.start","path":"/v1/actions/correct-name/proposals","requiresIdempotencyKey":true,"responseSchema":"action-correct-name-invoke-response"}}},"x-registry-defaultAccessProfile":"clerk","x-registry-operation":"start","x-registry-routeKind":"invoke"}},"/v1/proposals":{"get":{"operationId":"proposals.list","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"query","name":"action","schema":{"type":"string"}},{"in":"query","name":"owner","schema":{"const":"caller"}},{"in":"query","name":"target","schema":{"format":"uuid","type":"string"}},{"in":"query","name":"state","schema":{"enum":["draft","submitted","applied","cancelled","rejected"]}},{"in":"query","name":"turn","schema":{"enum":["party","official","nobody"]}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"description":"The most items a page holds. A page may hold fewer than `limit` items, so keep paging while `nextCursor` is present.","in":"query","name":"limit","schema":{"default":50,"maximum":100,"minimum":1,"type":"integer"}},{"in":"query","name":"pendingManualApplication","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"type":"string"}},"required":["items"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","query.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}":{"get":{"operationId":"proposals.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/apply":{"post":{"operationId":"proposals.apply","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"reason":{"description":"Optional application explanation, preserved unchanged. At most 4096 Unicode characters; NUL is refused.","maxLength":4096,"pattern":"^[^\\u0000]*$","type":"string"},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["submissionVersion","effectDigest"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/attachments/support":{"delete":{"operationId":"proposals.attachments.support.delete","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]},"get":{"operationId":"proposals.attachments.support.get","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"query","name":"submissionVersion","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"reviewContextField","required":false,"schema":{"pattern":"^[a-z][a-zA-Z0-9]{0,63}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"effectDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}},{"description":"All three review-context query members are required together and select only get-review-context authority. Omit all three for ordinary get authority.","in":"query","name":"contextSchemaDigest","required":false,"schema":{"pattern":"^sha256:[a-f0-9]{64}$","type":"string"}}],"responses":{"200":{"content":{"*/*":{"schema":{"contentMediaType":"application/octet-stream","maxLength":16777216,"type":"string"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]},"patch":{"operationId":"proposals.attachments.support.patch","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"text/plain":{"schema":{"format":"binary","maxLength":4096,"type":"string"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"413":{"content":{"application/problem+json":{"examples":{"attachment.too-large":{"value":{"code":"attachment.too-large","detail":"The file is larger than the attachment slot accepts.","status":413,"title":"Content Too Large","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/too-large"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.too-large"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"attachment.content-type":{"value":{"code":"attachment.content-type","detail":"The file media type is not one the attachment slot accepts.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/content-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.content-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/cancel":{"post":{"operationId":"proposals.cancel","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/edit":{"post":{"operationId":"proposals.edit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/rebase":{"post":{"operationId":"proposals.rebase","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/revise":{"post":{"operationId":"proposals.revise","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$id":"urn:breg:action:correct-name:invoke-input","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"input":{"additionalProperties":false,"properties":{"target":{"format":"uuid","type":"string"},"value":{"maxLength":64,"minLength":0,"type":"string"}},"required":[],"type":"object"}},"required":["input"],"type":"object","x-registry-action":"correct-name","x-registry-requiredConditionKeys":[]},{"additionalProperties":false,"type":"object"}]}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.key-reused","mutation.conflict","proposal.rejected"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/submissions/{submission_version}":{"get":{"operationId":"proposals.get-submission","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"path","name":"submission_version","required":true,"schema":{"maximum":4294967295,"minimum":1,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"application":{"anyOf":[{"additionalProperties":false,"dependentRequired":{"appliedAt":["appliedBy"],"appliedBy":["appliedAt"]},"properties":{"applicationId":{"format":"uuid","type":"string"},"appliedAt":{"description":"Application time, present with appliedBy only when the selected profile holds get-application-actor.","format":"date-time","type":"string"},"appliedBy":{"description":"Keyed actor pseudonym, present with appliedAt only when the selected profile holds get-application-actor.","pattern":"^hmac-sha256:[0-9a-f]{64}$","type":"string"},"state":{"const":"applied"}},"required":["state","applicationId"],"type":"object"},{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},{"type":"null"}]},"current":{"type":"boolean"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"review":{"anyOf":[{"additionalProperties":false,"properties":{"availableUntil":{"format":"date-time","type":"string"},"completedAt":{"format":"date-time","type":"string"},"resultId":{"format":"uuid","type":"string"},"state":{"enum":["pending","approved","rejected","changes-requested","answered","cancelled","superseded","expired"]}},"required":["state"],"type":"object"},{"type":"null"}]},"submissionVersion":{"maximum":4294967295,"minimum":1,"type":"integer"}},"required":["id","actionId","submissionVersion","current","effectDigest","review","application"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"proposal.submission-expired":{"value":{"code":"proposal.submission-expired","detail":"The review result and application receipt of the submission are no longer retained.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/submission-expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["proposal.submission-expired"]}},"type":"object"}]}}},"description":"The submission's review result and application receipt are no longer retained","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/proposals/{proposal_id}/submit":{"post":{"operationId":"proposals.submit","parameters":[{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"enum":["clerk"],"maxLength":128,"type":"string"}},{"in":"path","name":"proposal_id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"If-Match","required":true,"schema":{"type":"string"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"actionId":{"type":"string"},"actionRevision":{"type":"string"},"application":{"additionalProperties":false,"properties":{"applicationId":{"format":"uuid","type":"string"},"effectDigest":{"pattern":"^sha256:[0-9a-f]{64}$","type":"string"},"resultLinks":{"items":{"additionalProperties":false,"properties":{"recordId":{"format":"uuid","type":"string"},"recordType":{"type":"string"},"revision":{"minimum":1,"type":"integer"}},"required":["recordType","recordId","revision"],"type":"object"},"maxItems":16,"type":"array"},"submissionVersion":{"minimum":1,"type":"integer"}},"required":["applicationId","submissionVersion","effectDigest","resultLinks"],"type":"object"},"applicationStatus":{"additionalProperties":false,"properties":{"automaticRetry":{"additionalProperties":false,"properties":{"attempts":{"maximum":1000,"minimum":0,"type":"integer"},"maximumAttempts":{"maximum":1000,"minimum":1,"type":"integer"},"scheduled":{"type":"boolean"}},"required":["scheduled","attempts","maximumAttempts"],"type":"object"},"mode":{"enum":["automatic","manual"]},"reason":{"enum":["package-changed","dependency-outage","lease-expired","application-refused","attempts-exhausted"]},"recovery":{"enum":["retry","rebase","revise","correct-input"]},"state":{"enum":["awaiting-review","pending","applying","blocked","applied","cancelled","rejected"]}},"required":["state","mode"],"type":"object"},"asks":{"items":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"additions":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"answeredAt":{"format":"date-time","type":"string"},"formEntries":{"items":{"format":"uuid","type":"string"},"maxItems":32,"type":"array","uniqueItems":true},"text":{"maxLength":2000,"minLength":1,"type":"string"}},"required":["additions","answeredAt"],"type":"object"},"askedAt":{"format":"date-time","type":"string"},"dueAt":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string"},"links":{"additionalProperties":false,"properties":{"answer":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"const":"POST"},"operation":{"const":"answer"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation","ifMatch","availability"],"type":"object"}},"type":"object"},"state":{"enum":["open","answered","expired","closed"]},"text":{"maxLength":2000,"minLength":1,"type":"string"},"wants":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"enum":["answer","document"]}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"form":{"pattern":"^[a-z][a-z0-9_-]{0,63}$","type":"string"},"kind":{"const":"form"}},"required":["kind","form"],"type":"object"}]},"maxItems":8,"type":"array","uniqueItems":true}},"required":["id","text","wants","askedAt","state","links"],"type":"object"},"maxItems":50,"type":"array"},"attachments":{"additionalProperties":{"additionalProperties":false,"properties":{"classification":{"enum":["public","internal","restricted"]},"contentTypes":{"items":{"type":"string"},"maxItems":16,"minItems":1,"type":"array","uniqueItems":true},"id":{"type":"string"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","PATCH","DELETE"]},"operation":{"enum":["download","upload","remove"]},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"maximumBytes":{"maximum":16777216,"minimum":1,"type":"integer"},"required":{"type":"boolean"},"value":{"additionalProperties":false,"properties":{"byteSize":{"minimum":1,"type":"integer"},"contentType":{"type":"string"},"sha256":{"pattern":"^[a-f0-9]{64}$","type":"string"},"submissionVersion":{"minimum":0,"type":"integer"},"uploadedAt":{"type":"string"},"verificationStatus":{"enum":["notRequired","pending","approved","rejected"]}},"required":["submissionVersion","sha256","contentType","byteSize","verificationStatus"],"type":"object"}},"required":["id","required","maximumBytes","contentTypes","classification","links"],"type":"object"},"maxProperties":8,"type":"object"},"blockedReason":{"enum":["package-changed"]},"createdAt":{"format":"date-time","type":"string"},"decision":{"additionalProperties":false,"properties":{"decidedAt":{"format":"date-time","type":"string"},"publicReason":{"minLength":1,"pattern":"^[^\\u0000-\\u001F\\u007F-\\u009F]*[^\\u0000-\\u0020\\u007F-\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000][^\\u0000-\\u001F\\u007F-\\u009F]*$","type":"string","x-maximum-utf8-bytes":2000},"status":{"enum":["approved","rejected","changes-requested","answered"]}},"required":["status","decidedAt"],"type":"object"},"effectDigest":{"type":"string"},"handoffRefusal":{"additionalProperties":false,"properties":{"code":{"enum":["review.initiator-required","review.initiator-excluded","review.policy-mismatch","review.refused"]}},"required":["code"],"type":"object"},"id":{"format":"uuid","type":"string"},"input":{"type":"object"},"links":{"additionalProperties":{"additionalProperties":false,"properties":{"accessProfile":{"type":"string"},"availability":{"additionalProperties":false,"if":{"properties":{"available":{"const":false}}},"properties":{"available":{"type":"boolean"},"observedRevision":{"minimum":1,"type":"integer"},"reason":{"enum":["pending-review","review-rejected","review-changes-requested","review-ended","stale-revision","package-changed","dependency-outage","invalid-input","already-applied","limit-reached","application-pending","attachment-required","attachment-pending","ask-answered","ask-closed","ask-due-passed"]},"recovery":{"enum":["refresh","revise","retry","rebase","correct-input","receipt-only"]}},"required":["available","observedRevision"],"then":{"required":["reason","recovery"]},"type":"object"},"ifMatch":{"type":"string"},"method":{"enum":["GET","POST"]},"operation":{"type":"string"},"path":{"type":"string"}},"required":["method","path","accessProfile","operation"],"type":"object"},"type":"object"},"partyRole":{"enum":["owner","subject"]},"revision":{"minimum":1,"type":"integer"},"state":{"enum":["draft","submitted","applied","cancelled","rejected"]},"status":{"enum":["draft","awaiting-party","in-review","approved","processing","applied","rejected","cancelled"]},"submissionVersion":{"minimum":0,"type":"integer"},"title":{"maxLength":1024,"type":"string"},"turn":{"enum":["party","official","nobody"]}},"required":["id","actionId","actionRevision","submissionVersion","revision","state","turn","links"],"type":"object"}}},"description":"Authorized Proposal operation"},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["access-profile.ambiguous","request.invalid"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["authentication.refused"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"proposal.subject-not-caller":{"value":{"code":"proposal.subject-not-caller","detail":"This Proposal names someone other than you as the person it is about, and your access profile files only for yourself.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-not-caller"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["profile.not-authorized","proposal.subject-not-caller"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["resource.not-found"]}},"type":"object"}]}}},"description":"Resource unavailable to this caller","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"attachment.verification-pending":{"value":{"code":"attachment.verification-pending","detail":"The attachment is awaiting verification. Refresh the Proposal before submitting.","fieldPath":"/attachments/support","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/verification-pending"}},"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}},"proposal.rejected":{"value":{"code":"proposal.rejected","detail":"The review rejected this Proposal, and a rejection is final. A review result of changes-requested is what lets a Proposal be revised for another attempt.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/rejected"}},"proposal.subject-changed":{"value":{"code":"proposal.subject-changed","detail":"The person this Proposal is about changed since it was first submitted. Cancel it and file a new Proposal.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/proposal/subject-changed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.verification-pending","idempotency.key-reused","mutation.conflict","proposal.rejected","proposal.subject-changed"]}},"type":"object"}]}}},"description":"The Proposal was rejected, or the idempotency key was reused with a different request","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["idempotency.expired"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"412":{"content":{"application/problem+json":{"examples":{"precondition.failed":{"value":{"code":"precondition.failed","detail":"The mutation precondition failed.","status":412,"title":"Precondition Failed","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/failed"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.failed"]}},"type":"object"}]}}},"description":"Observed authority or lifecycle condition changed, or a Record revision guard failed (`precondition.failed`); a failed field commit guard answers `action.guard-failed` when the selected profile can read it","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["unsupported.media-type"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"422":{"content":{"application/problem+json":{"examples":{"attachment.required":{"value":{"code":"attachment.required","detail":"The required attachment slot is empty.","fieldPath":"/attachments/support","status":422,"title":"Unprocessable Entity","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/attachment/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["attachment.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"428":{"content":{"application/problem+json":{"examples":{"precondition.required":{"value":{"code":"precondition.required","detail":"The mutation precondition is required.","status":428,"title":"Precondition Required","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/precondition/required"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["precondition.required"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}},"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["service.unavailable","source.unavailable"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"code":{"enum":["request.timeout"]}},"type":"object"}]}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"x-registry-accessProfiles":["clerk"]}},"/v1/records/targets":{"get":{"operationId":"records.target.list","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Strict Registry read filter expression over compiled filterable API properties.","explode":false,"in":"query","name":"$filter","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"One compiled sortable property, ascending only.","explode":false,"in":"query","name":"$orderby","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Bounded page size.","explode":false,"in":"query","name":"limit","required":false,"schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Request count when the selected compiled query profile allows it.","explode":false,"in":"query","name":"$count","required":false,"schema":{"type":"boolean"}},{"description":"Opaque continuation cursor for the next page.","explode":false,"in":"query","name":"cursor","required":false,"schema":{"maxLength":10978,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"count":{"format":"int64","minimum":0,"type":"integer"},"items":{"items":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"type":"array"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"},"pageInfo":{"additionalProperties":false,"properties":{"nextCursor":{"maxLength":10978,"type":["string","null"]}},"required":["nextCursor"],"type":"object"}},"required":["items","pageInfo","meta","@context"],"type":"object"}}},"description":"Records returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"query.cursor-invalid":{"value":{"code":"query.cursor-invalid","detail":"The query cursor is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/cursor-invalid"}},"query.invalid":{"value":{"code":"query.invalid","detail":"The query request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/query/invalid"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"list","x-registry-queryKind":"list","x-registry-queryProfiles":{"clerk":{"allowCount":false,"filterableProperties":[],"kind":"list","maximumPageSize":100,"profile":"clerk","requiredFilters":[],"selectableProperties":["jurisdiction","name"],"selectorProperties":[],"sortableProperties":[],"temporal":null}},"x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordCollectionV1"},"post":{"operationId":"records.target.create","parameters":[{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Idempotency key bound to method, route, caller, target record, package revision, request body, and response field set.","in":"header","name":"Idempotency-Key","required":true,"schema":{"maxLength":256,"minLength":1,"pattern":"^[\\x21-\\x2B\\x2D-\\x3A\\x3C-\\x7E]+$","type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"$ref":"#/components/schemas/target-create-input"}},"required":["data"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/target"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"$ref":"#/components/schemas/target"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record created","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Location":{"description":"Relative URL of the created record.","schema":{"type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}},"write.outside-boundary":{"value":{"code":"write.outside-boundary","detail":"The write falls outside what the selected access profile may write: its row boundary or a disclosure condition.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/write/outside-boundary"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"409":{"content":{"application/problem+json":{"examples":{"idempotency.key-reused":{"value":{"code":"idempotency.key-reused","detail":"The idempotency key is bound to another request.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/key-reused"}},"mutation.conflict":{"value":{"code":"mutation.conflict","detail":"The mutation conflicts with current state.","status":409,"title":"Conflict","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/mutation/conflict"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"410":{"content":{"application/problem+json":{"examples":{"idempotency.expired":{"value":{"code":"idempotency.expired","detail":"The held response of the idempotency key expired; the key stays spent.","status":410,"title":"Gone","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/idempotency/expired"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"415":{"content":{"application/problem+json":{"examples":{"unsupported.media-type":{"value":{"code":"unsupported.media-type","detail":"The request media type is not supported.","status":415,"title":"Unsupported Media Type","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/unsupported/media-type"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"service.unavailable":{"value":{"code":"service.unavailable","detail":"The Registry mutation service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/service/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"create","x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/records/targets/{record_id}":{"get":{"operationId":"records.target.get","parameters":[{"description":"Canonical record UUID.","in":"path","name":"record_id","required":true,"schema":{"format":"uuid","type":"string"}},{"description":"Optional W3C trace context. Responses carry Registry trace context for the request.","in":"header","name":"traceparent","required":false,"schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}},{"description":"Select one compiled access profile. When omitted, the sole admitting profile or the route default is used; if several admit with no default, the route answers 400 access-profile.ambiguous.","explode":false,"in":"query","name":"accessProfile","required":false,"schema":{"maxLength":128,"type":"string"}},{"description":"Comma-separated subset of readable API property names.","explode":false,"in":"query","name":"$select","required":false,"schema":{"maxLength":16384,"type":"string"}},{"description":"Choose the ordinary JSON or JSON-LD Registry Record representation.","in":"header","name":"Accept","required":false,"schema":{"enum":["application/json","application/ld+json"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta"],"type":"object"}},"application/ld+json":{"schema":{"additionalProperties":false,"properties":{"@context":{"const":"https://id.registrystack.org/contexts/registry-record/v1"},"data":{"additionalProperties":false,"properties":{"domainData":{"additionalProperties":false,"properties":{"jurisdiction":{"maxLength":64,"minLength":0,"type":"string"},"name":{"maxLength":64,"minLength":0,"type":"string"}},"type":"object"},"recordId":{"format":"uuid","type":"string"},"revisionId":{"pattern":"^[1-9][0-9]*$","type":"string"}},"required":["recordId","revisionId","domainData"],"type":"object"},"meta":{"additionalProperties":false,"properties":{"datasetId":{"const":"directory"},"recordTypeId":{"const":"target"},"registryId":{"const":"required-attachment"}},"required":["registryId","datasetId","recordTypeId"],"type":"object"}},"required":["data","meta","@context"],"type":"object"}}},"description":"Record returned","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"ETag":{"description":"Strong Registry ETag bound to the record, package revision, caller profile, and response field set.","schema":{"pattern":"^\\\"breg-[\\x21\\x23-\\x7E]+\\\"$","type":"string"}},"Link":{"description":"Emitted only for application/json and application/ld+json Registry Record responses and omitted for application/geo+json. Carries the Registry Record profile and caller-visible record type schema. The describedby target includes the configured deployment prefix and is never derived from Host or forwarded headers.","schema":{"example":"; rel=\"profile\", ; rel=\"describedby\"","type":"string"}},"Vary":{"description":"Responses vary by authorization and negotiated representation.","schema":{"type":"string"}},"traceparent":{"description":"Trace context for this response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"400":{"content":{"application/problem+json":{"examples":{"access-profile.ambiguous":{"value":{"accessProfiles":["profile-a","profile-b"],"code":"access-profile.ambiguous","detail":"Multiple access profiles admit this request on this route; select one with accessProfile.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/access-profile/ambiguous"}},"request.invalid":{"value":{"code":"request.invalid","detail":"The request is invalid.","status":400,"title":"Bad Request","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/invalid"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"401":{"content":{"application/problem+json":{"examples":{"authentication.refused":{"value":{"code":"authentication.refused","detail":"The bearer token or delivery signature was not accepted.","status":401,"title":"Unauthorized","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/authentication/refused"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"WWW-Authenticate":{"description":"The authentication scheme the route accepts. The challenge is the same for every refused credential.","schema":{"const":"Bearer","type":"string"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"403":{"content":{"application/problem+json":{"examples":{"profile.not-authorized":{"value":{"code":"profile.not-authorized","detail":"No access profile admits this caller for this request.","status":403,"title":"Forbidden","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/profile/not-authorized"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"404":{"content":{"application/problem+json":{"examples":{"resource.not-found":{"value":{"code":"resource.not-found","detail":"The requested resource was not found.","status":404,"title":"Not Found","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/resource/not-found"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"503":{"content":{"application/problem+json":{"examples":{"source.unavailable":{"value":{"code":"source.unavailable","detail":"The Registry data service is unavailable.","status":503,"title":"Service Unavailable","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/source/unavailable"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}},"504":{"content":{"application/problem+json":{"examples":{"request.timeout":{"value":{"code":"request.timeout","detail":"The request timed out.","status":504,"title":"Gateway Timeout","traceId":"11111111111111111111111111111111","type":"https://id.registrystack.org/problems/registry-breg/request/timeout"}}},"schema":{"$ref":"#/components/schemas/Problem"}}},"description":"Problem response","headers":{"Cache-Control":{"description":"Caller-dependent responses must not be stored.","schema":{"const":"no-store"}},"traceparent":{"description":"Trace context for this problem response.","example":"00-11111111111111111111111111111111-2222222222222222-01","schema":{"maxLength":55,"minLength":55,"pattern":"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$","type":"string"}}}}},"security":[{"bearerAuth":[]}],"x-registry-accessProfiles":["clerk"],"x-registry-operation":"get","x-registry-recordType":"target","x-registry-responseProfile":"https://id.registrystack.org/profiles/registry-record/v1","x-registry-responseRecordType":"target","x-registry-responseShape":"RegistryRecordSingleV1"}},"/v1/review-completions":{"post":{"description":"Available when a review authority configures a completion block.","operationId":"receiveReviewCompletion","parameters":[{"in":"header","name":"Registry-Recipient-Binding","required":true,"schema":{"maxLength":256,"minLength":1,"type":"string"}},{"description":"Must equal eventId.","in":"header","name":"webhook-id","required":true,"schema":{"format":"uuid","type":"string"}},{"in":"header","name":"webhook-timestamp","required":true,"schema":{"pattern":"^(0|[1-9][0-9]{0,19})$","type":"string"}},{"in":"header","name":"webhook-signature","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewCompletion"}}},"required":true},"responses":{"204":{"description":"Completion accepted or already recorded."},"400":{"description":"The completion is invalid or eventId differs from webhook-id."},"401":{"description":"The completion authority could not be authenticated.","headers":{"WWW-Authenticate":{"schema":{"const":"Registry-Signature scheme=\"standard-webhooks\", version=\"v1\"","type":"string"}}}},"413":{"description":"The completion body exceeds 2048 bytes. The response body is empty."},"415":{"description":"The request is not application/json."},"503":{"description":"The completion could not be durably recorded."}},"security":[{"reviewCompletion":[]}],"summary":"Receive a Casework review completion"}}}} \ No newline at end of file From 207ceac80b43489a2fb2ab0a89e711aac60a05d3 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 06:58:28 +0000 Subject: [PATCH 44/96] fix(typescript): encode live audit keys for text secret providers Signed-off-by: Jeremi Joslin --- .../typescript/tests/live-audit-key.test.ts | 21 +++++++++++++++++++ clients/typescript/tests/live/harness.ts | 8 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 clients/typescript/tests/live-audit-key.test.ts diff --git a/clients/typescript/tests/live-audit-key.test.ts b/clients/typescript/tests/live-audit-key.test.ts new file mode 100644 index 0000000000..efd299d469 --- /dev/null +++ b/clients/typescript/tests/live-audit-key.test.ts @@ -0,0 +1,21 @@ +import assert from 'node:assert/strict' +import { mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import test from 'node:test' +import { writeTextAuditKey } from './live/harness.ts' + +test('the live text audit fixture writes 32 bytes as private hex text', t => { + const root = mkdtempSync(join(tmpdir(), 'rstack-ts-audit-key-test-')) + t.after(() => rmSync(root, { recursive: true, force: true })) + const path = join(root, 'audit-key') + + writeTextAuditKey(path) + + const key = readFileSync(path, 'utf8') + assert.ok(/^[0-9a-f]{64}$/u.test(key), 'expected exactly 64 lowercase hex characters') + assert.equal(Buffer.from(key, 'hex').length, 32) + if (process.platform !== 'win32') { + assert.equal(statSync(path).mode & 0o777, 0o600) + } +}) diff --git a/clients/typescript/tests/live/harness.ts b/clients/typescript/tests/live/harness.ts index a430a53fd3..4e627648e6 100644 --- a/clients/typescript/tests/live/harness.ts +++ b/clients/typescript/tests/live/harness.ts @@ -120,6 +120,10 @@ function writePrivateFile(path: string, content: string | Uint8Array): void { chmodSync(path, 0o600) } +export function writeTextAuditKey(path: string): void { + writePrivateFile(path, randomBytes(32).toString('hex')) +} + type IssuerEndpoints = Pick export function oid4vpTokenRoles(issuer: IssuerEndpoints, audience: string): string { @@ -1287,7 +1291,7 @@ export async function startLiveEnvironment(options: StartLiveEnvironmentOptions const mcpDir = join(root, 'mcp') const mcpSecrets = join(mcpDir, 'secrets') mkdirSync(mcpSecrets, { recursive: true, mode: 0o700 }) - writePrivateFile(join(mcpSecrets, 'audit-key'), randomBytes(32)) + writeTextAuditKey(join(mcpSecrets, 'audit-key')) writePrivateFile(join(mcpSecrets, 'adapter-token'), adapterReaderTokens.adapter!) const contractFilePath = join(mcpDir, 'adapter-contract.json') writePrivateFile(contractFilePath, contractDocument.bytes) @@ -1385,7 +1389,7 @@ export async function startLiveEnvironment(options: StartLiveEnvironmentOptions mkdirSync(sessionAuditDir, { recursive: true, mode: 0o700 }) writePrivateFile(join(sessionSecrets, 'staff-secret'), staffClientSecret) writePrivateFile(join(sessionSecrets, 'evidence-secret'), evidenceClientSecret) - writePrivateFile(join(sessionSecrets, 'audit-key'), randomBytes(32)) + writeTextAuditKey(join(sessionSecrets, 'audit-key')) const sessionConfigPath = join(sessionDir, 'runtime.yaml') writePrivateFile(sessionConfigPath, [ 'apiVersion: id.registrystack.org/formats/platform/session-runtime/v1alpha1', From 772949711bd3af43534e5daf7047654ee46be881 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 07:08:18 +0000 Subject: [PATCH 45/96] fix(breg): refresh Evidence source export provenance Signed-off-by: Jeremi Joslin --- products/breg/examples/formats/source-export.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/breg/examples/formats/source-export.json b/products/breg/examples/formats/source-export.json index 5fb1f383e6..060a37219a 100644 --- a/products/breg/examples/formats/source-export.json +++ b/products/breg/examples/formats/source-export.json @@ -1 +1 @@ -{"apiVersion":"id.registrystack.org/formats/breg/evidence-source-export/v1alpha1","kind":"BRegEvidenceSourceExport","sourceId":"registry-status","provenance":{"accessProfile":"evidence-source","behaviorRevision":"sha256:0fe08665e856376805945509e0bb0a232e9e0d956d4237b3f46c97296ba68358","entity":"record","producer":"bregctl","registryId":"registry","registryRevision":"sha256:240d65cde1c90ca61d9c363be04815b1736290031e815e34186195851e31cb6c"},"artifacts":[{"path":"adapter-packs/registry-status/pack.yaml","digest":"sha256:595d966808bed106ebd8bce96be7d21aca84ea1ec8d51700a538becd79d75fa7"},{"path":"adapter-packs/registry-status/protocols/registry-lookup.json","digest":"sha256:de5da14df16cbd9f8fc37a8580330242d50409aa15d28749904bc9c2823b41b2"},{"path":"adapter-packs/registry-status/schemas/facts.json","digest":"sha256:53d95c4a0be36815e2eddca510e8469e2d8aa5f57843436c7d97e8dd5f03fd12"},{"path":"adapter-packs/registry-status/schemas/inputs.json","digest":"sha256:458373dc1cda44d10f328dfaaa809ebaaffda45bd7b4292274e99326f877640a"},{"path":"adapter-packs/registry-status/schemas/response.json","digest":"sha256:80ceace892a817dcf12560d16ebe37fea09544a0b7c5f147fa11e9635fda9b9a"},{"path":"adapter-packs/registry-status/scripts/lookup.rhai","digest":"sha256:4c4d865446578334e6d9e774986dc5e68e9cdfe000c103e9cf325eda45842c45"},{"path":"selectors/breg-8-registry-6-record-22-by-registration-number.yaml","digest":"sha256:41eac0fcc67de6564be9447971c1291f271817ea3018e25d401810ac4fafc300"},{"path":"selectors/breg-8-registry-6-record-7-by-code.yaml","digest":"sha256:3912ec5c8bfeb077878266397a2c0f9f8cb991a200de92acba5bc31036c30300"},{"path":"sources/registry-status.yaml","digest":"sha256:841f1a0d8c5fb15c6e78c294454a6d3ef33cf9fa1c93e327e44a120fd98ee0e7"}]} \ No newline at end of file +{"apiVersion":"id.registrystack.org/formats/breg/evidence-source-export/v1alpha1","kind":"BRegEvidenceSourceExport","sourceId":"registry-status","provenance":{"accessProfile":"evidence-source","behaviorRevision":"sha256:0fe08665e856376805945509e0bb0a232e9e0d956d4237b3f46c97296ba68358","entity":"record","producer":"bregctl","registryId":"registry","registryRevision":"sha256:8e47fb95ccd49abafa34a26801ae32962b274020caba8fdaac5183e50fc7f71d"},"artifacts":[{"path":"adapter-packs/registry-status/pack.yaml","digest":"sha256:595d966808bed106ebd8bce96be7d21aca84ea1ec8d51700a538becd79d75fa7"},{"path":"adapter-packs/registry-status/protocols/registry-lookup.json","digest":"sha256:de5da14df16cbd9f8fc37a8580330242d50409aa15d28749904bc9c2823b41b2"},{"path":"adapter-packs/registry-status/schemas/facts.json","digest":"sha256:53d95c4a0be36815e2eddca510e8469e2d8aa5f57843436c7d97e8dd5f03fd12"},{"path":"adapter-packs/registry-status/schemas/inputs.json","digest":"sha256:458373dc1cda44d10f328dfaaa809ebaaffda45bd7b4292274e99326f877640a"},{"path":"adapter-packs/registry-status/schemas/response.json","digest":"sha256:80ceace892a817dcf12560d16ebe37fea09544a0b7c5f147fa11e9635fda9b9a"},{"path":"adapter-packs/registry-status/scripts/lookup.rhai","digest":"sha256:4c4d865446578334e6d9e774986dc5e68e9cdfe000c103e9cf325eda45842c45"},{"path":"selectors/breg-8-registry-6-record-22-by-registration-number.yaml","digest":"sha256:41eac0fcc67de6564be9447971c1291f271817ea3018e25d401810ac4fafc300"},{"path":"selectors/breg-8-registry-6-record-7-by-code.yaml","digest":"sha256:3912ec5c8bfeb077878266397a2c0f9f8cb991a200de92acba5bc31036c30300"},{"path":"sources/registry-status.yaml","digest":"sha256:841f1a0d8c5fb15c6e78c294454a6d3ef33cf9fa1c93e327e44a120fd98ee0e7"}]} \ No newline at end of file From e597206468c94931476c3b37ac612b8cf2d8fd29 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Wed, 2 Dec 2026 23:29:12 +0000 Subject: [PATCH 46/96] fix(breg): admit additive Action response members Signed-off-by: Jeremi Joslin --- crates/registry-breg-client/src/actions.rs | 40 +--- .../action_recovery_registry_revision.rs | 221 +++++++++++++++++- 2 files changed, 218 insertions(+), 43 deletions(-) diff --git a/crates/registry-breg-client/src/actions.rs b/crates/registry-breg-client/src/actions.rs index 4b3d91b690..9c7606df34 100644 --- a/crates/registry-breg-client/src/actions.rs +++ b/crates/registry-breg-client/src/actions.rs @@ -589,6 +589,7 @@ impl BaseRegistryClient { let restored = BRegActionInvocationRequest::new(action, original_inputs.clone(), conditions.as_ref()) .map_err(|_| action_recovery_refusal())?; + // Recovery requires the exact canonical body, including closed condition objects. if restored.body.as_slice() != saved.body.as_bytes() { return Err(action_recovery_refusal()); } @@ -832,28 +833,11 @@ fn decode_availability( ) -> Result { let value = crate::strict_json::from_slice(bytes).map_err(|_| BRegActionError::InvalidResponse)?; - let outer = value - .as_object() - .filter(|object| object.len() == 1) - .ok_or(BRegActionError::InvalidResponse)?; + let outer = value.as_object().ok_or(BRegActionError::InvalidResponse)?; let availability = outer .get("availability") .and_then(Value::as_object) .ok_or(BRegActionError::InvalidResponse)?; - if availability.keys().any(|key| { - !matches!( - key.as_str(), - "available" - | "observedRevision" - | "reason" - | "recovery" - | "missingInputs" - | "guardReason" - | "guardLabel" - ) - }) { - return Err(BRegActionError::InvalidResponse); - } let available = match availability.get("available") { Some(Value::Bool(value)) => Some(*value), Some(Value::Null) => None, @@ -944,10 +928,7 @@ fn decode_conditions( ) -> Result { let value = crate::strict_json::from_slice(bytes).map_err(|_| BRegActionError::InvalidResponse)?; - let object = value - .as_object() - .filter(|object| object.len() == 1) - .ok_or(BRegActionError::InvalidResponse)?; + let object = value.as_object().ok_or(BRegActionError::InvalidResponse)?; let conditions = object .get("preconditions") .and_then(Value::as_object) @@ -962,10 +943,7 @@ fn decode_conditions( let preconditions = conditions .iter() .map(|(name, value)| { - let condition = value - .as_object() - .filter(|condition| condition.len() == 1) - .ok_or(BRegActionError::InvalidResponse)?; + let condition = value.as_object().ok_or(BRegActionError::InvalidResponse)?; let if_match = condition .get("ifMatch") .and_then(Value::as_str) @@ -992,10 +970,7 @@ fn decode_receipt( ) -> Result { let value = crate::strict_json::from_slice(bytes).map_err(|_| BRegActionError::InvalidResponse)?; - let object = value - .as_object() - .filter(|object| object.len() == 3) - .ok_or(BRegActionError::InvalidResponse)?; + let object = value.as_object().ok_or(BRegActionError::InvalidResponse)?; if object.get("action").and_then(Value::as_str) != Some(action.action_identifier()) { return Err(BRegActionError::InvalidResponse); } @@ -1020,10 +995,7 @@ fn decode_receipt( let results = values .iter() .map(|(effect, value)| { - let result = value - .as_object() - .filter(|result| result.len() == 3) - .ok_or(BRegActionError::InvalidResponse)?; + let result = value.as_object().ok_or(BRegActionError::InvalidResponse)?; let entity = result .get("recordType") .and_then(Value::as_str) diff --git a/crates/registry-breg-client/tests/action_recovery_registry_revision.rs b/crates/registry-breg-client/tests/action_recovery_registry_revision.rs index f3115f8689..a65fb67376 100644 --- a/crates/registry-breg-client/tests/action_recovery_registry_revision.rs +++ b/crates/registry-breg-client/tests/action_recovery_registry_revision.rs @@ -16,8 +16,9 @@ use axum::http::{Request, Response, StatusCode}; use axum::routing::any; use axum::Router; use registry_breg_client::{ - BRegActionInvocationRequest, BRegIdempotencyKey, BaseRegistryClient, BaseRegistryClientConfig, - BaseRegistryClientError, + BRegActionAvailabilityRequest, BRegActionInvocationRequest, BRegActionTargetConditionsRequest, + BRegIdempotencyKey, BRegPreparedAction, BRegProtocolFailure, BaseRegistryClient, + BaseRegistryClientConfig, BaseRegistryClientError, }; use registry_platform_httputil::client::{BearerToken, TokenError, TokenProvider}; use serde_json::{json, Map, Value}; @@ -72,23 +73,31 @@ impl TokenProvider for StaticToken { #[derive(Clone)] struct MockState { - responses: Arc>>, + responses: Arc>>, served: Arc, } -async fn handler(State(state): State, _request: Request) -> Response { +async fn handler(State(state): State, request: Request) -> Response { state.served.fetch_add(1, Ordering::SeqCst); let body = state .responses .lock() .expect("response queue lock") .pop_front() - .expect("a queued metadata response"); - let mut response = Response::new(Body::from(serde_json::to_vec(&body).expect("body"))); + .expect("a queued response"); + let mut response = Response::new(Body::from(body)); *response.status_mut() = StatusCode::OK; response .headers_mut() .insert("content-type", "application/json".parse().expect("header")); + if request.method() == axum::http::Method::POST { + response + .headers_mut() + .insert("cache-control", "no-store".parse().expect("header")); + response + .headers_mut() + .insert("vary", "authorization, accept".parse().expect("header")); + } response .headers_mut() .insert("traceparent", TRACEPARENT.parse().expect("header")); @@ -107,7 +116,7 @@ async fn caller_metadata_vocabulary_codes_prepare_and_recover_exactly() { }); let served = Arc::new(AtomicUsize::new(0)); let state = MockState { - responses: Arc::new(Mutex::new(VecDeque::from([metadata]))), + responses: Arc::new(Mutex::new(VecDeque::from([metadata.to_string()]))), served: served.clone(), }; let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); @@ -174,8 +183,8 @@ async fn saved_command_refuses_after_registry_revision_change() { let served = Arc::new(AtomicUsize::new(0)); let state = MockState { responses: Arc::new(Mutex::new(VecDeque::from([ - action_metadata(REVISION_A), - action_metadata(REVISION_B), + action_metadata(REVISION_A).to_string(), + action_metadata(REVISION_B).to_string(), ]))), served: served.clone(), }; @@ -255,3 +264,197 @@ async fn saved_command_refuses_after_registry_revision_change() { "prepare and recover perform no exchange" ); } + +#[tokio::test] +async fn action_responses_admit_additions_with_exact_bindings() { + let mut metadata = action_metadata(REVISION_A); + let action = &mut metadata["actions"][0]; + action["inputs"][0]["schema"] = json!({"type":"string","format":"uuid"}); + action["inputs"][0]["fieldType"] = + json!({"type":"reference","target":"incorporation","onDelete":"restrict"}); + action["referenceInputs"] = + json!([{"input":"reference","apiName":"reference","targetRecordType":"incorporation"}]); + action["requiredConditionKeys"] = json!(["reference"]); + for route in ["target-conditions", "availability"] { + let path = format!("/v1/actions/incorporate-company/{route}"); + let key = if route == "availability" { + "availability" + } else { + action["conditionRoute"] = json!(path); + "targetConditions" + }; + action["routes"][key] = json!({ + "method": "POST", "path": path, + "operationId": format!("actions.incorporate-company.{route}"), + "requiresIdempotencyKey": false, + "inputSchema": format!("action-incorporate-company-{route}-input"), + "responseSchema": format!("action-incorporate-company-{route}-response") + }); + } + + let invalid_availability = [ + r#"{"availability":{"available":true}}"#, + r#"{"availability":{"available":true,"observedRevision":3,"reason":"not-disclosed"}}"#, + r#"{"availability":{"available":true,"observedRevision":3,"extra":{"x":1,"x":2}}}"#, + ]; + let invalid_conditions = [ + r#"{"preconditions":{"reference":{"extra":true}}}"#, + r#"{"preconditions":{"reference":{"ifMatch":"W/\"r3\""}}}"#, + r#"{"preconditions":{"reference":{"ifMatch":"\"r3\""},"extra":{"ifMatch":"\"r3\""}}}"#, + r#"{"preconditions":{"reference":{"ifMatch":"\"r3\"","ifMatch":"\"r3\""}}}"#, + ]; + let invalid_receipts = [ + r#"{"action":"incorporate-company","applicationId":"00000000-0000-4000-8000-000000000010","results":{"record-incorporation":{"recordType":"incorporation","recordId":"00000000-0000-4000-8000-000000000001"}}}"#, + r#"{"action":"incorporate-company","applicationId":"00000000-0000-4000-8000-000000000010","results":{"record-incorporation":{"recordType":"other","recordId":"00000000-0000-4000-8000-000000000001","revision":4}}}"#, + r#"{"action":"incorporate-company","applicationId":"00000000-0000-4000-8000-000000000010","results":{"extra":{"recordType":"incorporation","recordId":"00000000-0000-4000-8000-000000000001","revision":4}}}"#, + r#"{"action":"incorporate-company","applicationId":"00000000-0000-4000-8000-000000000010","results":{"record-incorporation":{"recordType":"incorporation","recordId":"00000000-0000-4000-8000-000000000001","revision":4,"revision":4}}}"#, + ]; + let availability = + r#"{"availability":{"available":true,"observedRevision":3,"extra":true},"extra":{}}"#; + let conditions = + r#"{"preconditions":{"reference":{"ifMatch":"\"r3\"","extra":true}},"extra":{}}"#; + let receipt = r#"{"action":"incorporate-company","applicationId":"00000000-0000-4000-8000-000000000010","results":{"record-incorporation":{"recordType":"incorporation","recordId":"00000000-0000-4000-8000-000000000001","revision":4,"extra":true}},"extra":{}}"#; + let responses = [metadata.to_string()] + .into_iter() + .chain( + invalid_availability + .into_iter() + .chain([availability]) + .chain(invalid_conditions) + .chain([conditions]) + .chain(invalid_receipts) + .chain([receipt]) + .map(str::to_owned), + ) + .collect(); + let state = MockState { + responses: Arc::new(Mutex::new(responses)), + served: Arc::new(AtomicUsize::new(0)), + }; + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let address = listener.local_addr().unwrap(); + let router = Router::new() + .fallback(any(handler)) + .with_state(state.clone()); + let server = tokio::spawn(async move { axum::serve(listener, router).await.unwrap() }); + let client = BaseRegistryClient::new( + BaseRegistryClientConfig::new_without_peer_policy( + format!("http://{address}/").parse().unwrap(), + ) + .with_token_provider(Arc::new(StaticToken(AtomicUsize::new(0)))) + .with_maximum_mutation_retries(0), + ) + .unwrap(); + let action = client + .registry_contract(Some("preparer")) + .await + .unwrap() + .value + .select_action("incorporate-company", "preparer") + .unwrap(); + let inputs = Map::from_iter([( + "reference".to_owned(), + json!("00000000-0000-4000-8000-000000000001"), + )]); + + let request = BRegActionAvailabilityRequest::new(&action, "reference", inputs.clone()).unwrap(); + for _ in invalid_availability { + let error = client + .action_availability(&action, &request) + .await + .err() + .unwrap(); + assert_action_body_error(error); + } + let availability = client + .action_availability(&action, &request) + .await + .expect("additive availability") + .value; + assert_eq!(availability.available(), Some(true)); + assert_eq!(availability.observed_revision(), Some(3)); + + let request = BRegActionTargetConditionsRequest::new(&action, inputs.clone()).unwrap(); + for _ in invalid_conditions { + let error = client + .action_target_conditions(&action, &request) + .await + .err() + .unwrap(); + assert_action_body_error(error); + } + let conditions = client + .action_target_conditions(&action, &request) + .await + .expect("additive target conditions") + .value; + assert_eq!( + serde_json::to_value(&conditions).unwrap(), + json!({"preconditions":{"reference":{"ifMatch":"\"r3\""}}}) + ); + let other_inputs = Map::from_iter([( + "reference".to_owned(), + json!("00000000-0000-4000-8000-000000000002"), + )]); + assert!(BRegActionInvocationRequest::new(&action, other_inputs, Some(&conditions)).is_err()); + + let request = + BRegActionInvocationRequest::new(&action, inputs.clone(), Some(&conditions)).unwrap(); + let key = BRegIdempotencyKey::parse("incorporate-1").unwrap(); + + // A caller-held prepared command still requires the exact canonical body. + let prepared = client.prepare_action(&action, &request, &key).unwrap(); + let mut saved: Value = serde_json::from_slice(prepared.as_bytes()).unwrap(); + let body = saved["body"].as_str().unwrap(); + let extended = body.replace( + r#"{"ifMatch":"\"r3\""}"#, + r#"{"ifMatch":"\"r3\"","extra":true}"#, + ); + assert_ne!(extended, body); + saved["body"] = json!(extended); + let saved = BRegPreparedAction::from_slice(&serde_json::to_vec(&saved).unwrap()).unwrap(); + assert!(client + .recover_action(&action, &saved, &inputs, &key) + .is_err()); + + for _ in invalid_receipts { + let error = client + .invoke_action(&action, &request, &key) + .await + .err() + .unwrap(); + assert!(error.is_outcome_unknown()); + assert_action_body_error(error); + } + let receipt = client + .invoke_action(&action, &request, &key) + .await + .expect("additive receipt") + .value; + let result = &receipt.results()["record-incorporation"]; + assert_eq!(result.revision(), 4); + assert_eq!( + result.record_identifier().to_string(), + inputs["reference"].as_str().unwrap() + ); + assert_eq!( + receipt.application_identifier().to_string(), + "00000000-0000-4000-8000-000000000010" + ); + assert!(state.responses.lock().unwrap().is_empty()); + server.abort(); +} + +fn assert_action_body_error(error: BaseRegistryClientError) { + assert!( + matches!( + error, + BaseRegistryClientError::Protocol { + status: 200, + failure: BRegProtocolFailure::Body, + .. + } + ), + "{error}" + ); +} From 4bf1aa41da30359df42059d8cef9f1a63c185a57 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:41:24 +0000 Subject: [PATCH 47/96] fix(breg): admit Proposal callers before reporting request faults Signed-off-by: Jeremi Joslin --- crates/registry-breg/src/api/proposals.rs | 11 +- .../src/api/proposals/answers.rs | 19 ++- .../registry-breg/src/api/proposals/forms.rs | 5 + .../src/api/proposals/messages.rs | 128 +++++++++++------ .../src/mutation/proposal/forms.rs | 15 +- crates/registry-breg/src/problem_location.rs | 14 +- .../registry-breg/src/proposal_artifacts.rs | 8 +- .../registry-breg/tests/postgres_proposal.rs | 3 +- .../tests/postgres_proposal_messages.rs | 135 +++++++++++++++++- .../tests/proposal_messages_compiler.rs | 6 + .../tests/support/proposal_additions.rs | 33 ++++- .../tests/support/proposal_review_asks.rs | 35 +++++ 12 files changed, 338 insertions(+), 74 deletions(-) diff --git a/crates/registry-breg/src/api/proposals.rs b/crates/registry-breg/src/api/proposals.rs index 3bef869d84..e5fb636dd3 100644 --- a/crates/registry-breg/src/api/proposals.rs +++ b/crates/registry-breg/src/api/proposals.rs @@ -2318,7 +2318,7 @@ pub(super) async fn list( let Some(mutations) = &service.mutations else { return concealed(FailedCheck::Visibility); }; - let selected = match proposal_list_admission_profile(raw_query.as_deref()) { + let selected = match proposal_admission_profile(raw_query.as_deref()) { Ok(selected) => selected, Err(()) => { return audited_list_concealment( @@ -2400,7 +2400,7 @@ pub(super) async fn list( Ok(query) => query, Err(QueryParseError::InvalidAt("top")) => { return invalid_query_at_with_detail( - "top", + "query", "The Proposal list takes `limit` for its page size; `top` is not accepted.", ); } @@ -2416,7 +2416,7 @@ pub(super) async fn list( } } -fn proposal_list_admission_profile(raw: Option<&str>) -> Result, ()> { +fn proposal_admission_profile(raw: Option<&str>) -> Result, ()> { let Some(raw) = raw else { return Ok(None) }; if raw.len() > MAX_RAW_QUERY_BYTES { return Err(()); @@ -2454,7 +2454,6 @@ fn proposal_list_parameter(name: &str) -> Option<&'static str> { "target" => Some("target"), "cursor" => Some("cursor"), "limit" => Some("limit"), - "top" => Some("top"), _ => None, } } @@ -2476,6 +2475,9 @@ fn parse_proposal_list_query(raw: Option<&str>) -> Result) -> Result return Err(QueryParseError::InvalidAt("top")), _ if proposal_list_parameter(&name).is_some() => { return Err(proposal_list_error(&name)); } diff --git a/crates/registry-breg/src/api/proposals/answers.rs b/crates/registry-breg/src/api/proposals/answers.rs index b74db5166f..80317f10c1 100644 --- a/crates/registry-breg/src/api/proposals/answers.rs +++ b/crates/registry-breg/src/api/proposals/answers.rs @@ -58,12 +58,21 @@ pub(in crate::api) async fn answer( .await .map_err(|_| invalid_request())?; let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; - if value.get("text").is_some_and(Value::is_null) { - return Err(proposal_problem(MutationError::InvalidRequestAt( - crate::problem_location::RequestLocation::proposal_answer_text(), - ))); + if value.get("text").is_some_and(|text| !text.is_string()) { + return Err(invalid_request_at( + &crate::problem_location::RequestLocation::proposal_answer_text(), + )); } - let answer: AnswerBody = serde_json::from_value(value).map_err(|_| invalid_request())?; + let answer: AnswerBody = serde_path_to_error::deserialize(value).map_err(|error| { + match error.path().iter().next() { + Some(serde_path_to_error::Segment::Map { key }) if key == "formEntries" => { + invalid_request_at( + &crate::problem_location::RequestLocation::proposal_answer_form_entries(), + ) + } + _ => invalid_request(), + } + })?; Ok((key, etag, answer)) } .await; diff --git a/crates/registry-breg/src/api/proposals/forms.rs b/crates/registry-breg/src/api/proposals/forms.rs index 2edcc7f470..7c0627340f 100644 --- a/crates/registry-breg/src/api/proposals/forms.rs +++ b/crates/registry-breg/src/api/proposals/forms.rs @@ -82,6 +82,11 @@ pub(in crate::api) async fn add_form( .await .map_err(|_| invalid_request())?; let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; + if !value.get("input").is_some_and(Value::is_object) { + return Err(invalid_request_at( + &crate::problem_location::RequestLocation::input(), + )); + } let body: AddFormBody = serde_json::from_value(value).map_err(|_| invalid_request())?; Ok((key, etag, body.input)) } diff --git a/crates/registry-breg/src/api/proposals/messages.rs b/crates/registry-breg/src/api/proposals/messages.rs index 84e471e037..0fb53208fe 100644 --- a/crates/registry-breg/src/api/proposals/messages.rs +++ b/crates/registry-breg/src/api/proposals/messages.rs @@ -10,7 +10,7 @@ async fn admit( service: &HttpService, id: &str, claims: &VerifiedRequestClaims, - raw: Option<&str>, + selected: Result, ()>, method: HttpMethod, correlation: &RequestCorrelation, ) -> Result<(Uuid, CompiledAction, ProposalAuthority), Response> { @@ -21,7 +21,7 @@ async fn admit( Ok(id) if !id.is_nil() => id, _ => return Err(concealed(FailedCheck::Visibility)), }; - let selected = selected_profile(raw).map_err(|_| concealed(FailedCheck::Visibility))?; + let selected = selected.map_err(|_| concealed(FailedCheck::Visibility))?; let (action, authority) = authorize_target( service, mutations, @@ -109,7 +109,7 @@ pub(in crate::api) async fn write( &service, &id, &claims, - raw_query.as_deref(), + selected_profile(raw_query.as_deref()), HttpMethod::Post, &correlation, ) @@ -136,7 +136,7 @@ pub(in crate::api) async fn write( .map_err(|_| invalid_request())?; let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; let text = match value.as_object() { - Some(object) if object.len() == 1 => object.get("text"), + Some(object) if object.len() <= 1 => object.get("text"), _ => return Err(invalid_request()), }; let text = text @@ -205,31 +205,11 @@ pub(in crate::api) async fn list( Authenticated(claims): Authenticated, RawQuery(raw_query): RawQuery, ) -> Response { - // `after` and `limit` page the thread; every other parameter selects - // the access profile as on any Proposal read. - let mut after = None; - let mut limit = None; - let mut ordinary = Vec::new(); - for pair in raw_query.as_deref().unwrap_or("").split('&') { - if pair.is_empty() { - continue; - } - let Some((name, value)) = pair.split_once('=') else { - return concealed(FailedCheck::Visibility); - }; - match name { - "after" if after.is_none() => after = Some(value.to_owned()), - "limit" if limit.is_none() => limit = Some(value.to_owned()), - "after" | "limit" => return invalid_request(), - _ => ordinary.push(pair), - } - } - let ordinary = (!ordinary.is_empty()).then(|| ordinary.join("&")); let (id, _, authority) = match admit( &service, &id, &claims, - ordinary.as_deref(), + proposal_admission_profile(raw_query.as_deref()), HttpMethod::Get, &correlation, ) @@ -241,30 +221,15 @@ pub(in crate::api) async fn list( let Some(mutations) = &service.mutations else { return concealed(FailedCheck::Visibility); }; - let before = match after.as_deref().map(str::parse::) { - None => None, - Some(Ok(position)) if position > 0 => Some(position), - Some(_) => { + let (before, limit) = match page_inputs(raw_query.as_deref()) { + Ok(page) => page, + Err(error) => { return admitted_http_refusal( mutations, &authority, HttpMethod::Get, &correlation, - fixed_problem(crate::problem::ProblemCode::QueryCursorInvalid), - ) - .await - } - }; - let limit = match limit.as_deref().map(str::parse::) { - None => crate::proposal_messages::DOCUMENT_ITEMS, - Some(Ok(limit)) if (1..=crate::proposal_messages::MAX_PAGE_ITEMS).contains(&limit) => limit, - Some(_) => { - return admitted_http_refusal( - mutations, - &authority, - HttpMethod::Get, - &correlation, - invalid_request(), + error.problem(), ) .await } @@ -280,6 +245,77 @@ pub(in crate::api) async fn list( } } +/// Parse the page inputs only after the bounded profile selection and visibility check. +fn page_inputs(raw: Option<&str>) -> Result<(Option, i64), PageError> { + let mut cursor = None; + let mut limit = None; + for pair in raw.into_iter().flat_map(|query| query.split('&')) { + let (name, value) = pair.split_once('=').ok_or(PageError::InvalidQuery)?; + let name = percent_decode(name).map_err(|_| PageError::InvalidQuery)?; + let (slot, parameter) = match name.as_str() { + "accessProfile" => continue, + "cursor" => (&mut cursor, "cursor"), + "limit" => (&mut limit, "limit"), + "after" => return Err(PageError::RetiredAfter), + _ => return Err(PageError::InvalidQuery), + }; + if slot.replace(value).is_some() { + return Err(PageError::Parameter(ProblemCode::RequestInvalid, parameter)); + } + } + let position = |value| { + percent_decode(value) + .ok() + .and_then(|value| value.parse::().ok()) + }; + let before = cursor + .map(|value| { + percent_decode(value) + .ok() + .filter(|value| matches!(value.as_bytes().first(), Some(b'1'..=b'9'))) + .and_then(|value| value.parse::().ok()) + .ok_or(PageError::Parameter( + ProblemCode::QueryCursorInvalid, + "cursor", + )) + }) + .transpose()?; + let limit = limit + .map(|value| { + position(value) + .filter(|limit| (1..=crate::proposal_messages::MAX_PAGE_ITEMS).contains(limit)) + .ok_or(PageError::Parameter(ProblemCode::RequestInvalid, "limit")) + }) + .transpose()? + .unwrap_or(crate::proposal_messages::DOCUMENT_ITEMS); + Ok((before, limit)) +} + +enum PageError { + InvalidQuery, + RetiredAfter, + Parameter(ProblemCode, &'static str), +} + +impl PageError { + fn problem(self) -> Response { + match self { + Self::InvalidQuery => invalid_query_at("query"), + Self::RetiredAfter => invalid_query_at_with_detail( + "query", + "The Proposal thread takes `cursor` for its page position; `after` is not accepted.", + ), + Self::Parameter(code, parameter) => crate::correlation::problem_response_with_field_path( + StatusCode::BAD_REQUEST, + code.title(), + code.description(), + code.code(), + parameter, + ), + } + } +} + pub(in crate::api) async fn mark_read( State(service): State>, Path(id): Path, @@ -293,7 +329,7 @@ pub(in crate::api) async fn mark_read( &service, &id, &claims, - raw_query.as_deref(), + selected_profile(raw_query.as_deref()), HttpMethod::Post, &correlation, ) @@ -314,7 +350,7 @@ pub(in crate::api) async fn mark_read( .map_err(|_| invalid_request())?; let value = parse_json_strict(&bytes).map_err(|_| invalid_request())?; match value.as_object() { - Some(object) if object.len() == 1 => object + Some(object) if object.len() <= 1 => object .get("through") .and_then(Value::as_str) .and_then(|id| Uuid::parse_str(id).ok()) diff --git a/crates/registry-breg/src/mutation/proposal/forms.rs b/crates/registry-breg/src/mutation/proposal/forms.rs index 0a45a78cbd..7a9400044d 100644 --- a/crates/registry-breg/src/mutation/proposal/forms.rs +++ b/crates/registry-breg/src/mutation/proposal/forms.rs @@ -53,15 +53,12 @@ pub(super) async fn insert( FailedCheck::AccessProfile, )); } - for key in entry.values.keys() { - if !form.inputs.iter().any(|input| &input.api_name == key) { - let path = if crate::logical_names::valid_api_name(key) { - RequestLocation::action_input(key) - } else { - return Err(MutationError::InvalidRequest); - }; - return Err(MutationError::InvalidRequestAt(path)); - } + if entry + .values + .keys() + .any(|key| !form.inputs.iter().any(|input| &input.api_name == key)) + { + return Err(MutationError::InvalidRequestAt(RequestLocation::input())); } for input in &form.inputs { let valid = entry diff --git a/crates/registry-breg/src/problem_location.rs b/crates/registry-breg/src/problem_location.rs index a79f751c94..37c844bc31 100644 --- a/crates/registry-breg/src/problem_location.rs +++ b/crates/registry-breg/src/problem_location.rs @@ -182,6 +182,15 @@ impl RequestLocation { } } + /// The `input` member of an Action or Proposal body. + #[must_use] + pub fn input() -> Self { + Self { + pointer: "/input".to_owned(), + scope: Scope::Input, + } + } + /// One declared input of an Action or Proposal body. The caller passes /// only a compiled input API name; an over-long name falls back to /// `/input`. @@ -189,10 +198,7 @@ impl RequestLocation { pub fn action_input(api_name: &str) -> Self { let pointer = format!("/input/{}", escape_segment(api_name)); if pointer.chars().count() > MAX_FIELD_PATH_CHARS { - return Self { - pointer: "/input".to_owned(), - scope: Scope::Input, - }; + return Self::input(); } Self { pointer, diff --git a/crates/registry-breg/src/proposal_artifacts.rs b/crates/registry-breg/src/proposal_artifacts.rs index 450b1ad498..d5469a6fc9 100644 --- a/crates/registry-breg/src/proposal_artifacts.rs +++ b/crates/registry-breg/src/proposal_artifacts.rs @@ -568,7 +568,7 @@ fn append_message_openapi( let path = "/v1/proposals/{proposal_id}/messages"; let mut list = operation_document("proposals.list-messages", "get", profiles, false, additions); list["parameters"].as_array_mut().expect("query parameters").extend([ - json!({"name":"after","in":"query","schema":{"type":"string","pattern":"^[1-9][0-9]*$"}}), + json!({"name":"cursor","in":"query","schema":{"type":"string","pattern":"^[1-9][0-9]*$"}}), json!({"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}), ]); list["responses"]["200"]["content"]["application/json"]["schema"] = json!({ @@ -962,7 +962,11 @@ pub(super) fn append_operation_problems(operation: &mut Value, method: &str) { codes.push(ProblemCode::ProposalMessageLimitReached); } if id == "proposals.list-messages" { - codes.extend([ProblemCode::QueryCursorInvalid, ProblemCode::RequestInvalid]); + codes.extend([ + ProblemCode::QueryCursorInvalid, + ProblemCode::QueryInvalid, + ProblemCode::RequestInvalid, + ]); } if id == "proposals.list" { codes.push(ProblemCode::QueryInvalid); diff --git a/crates/registry-breg/tests/postgres_proposal.rs b/crates/registry-breg/tests/postgres_proposal.rs index c24c9f9594..ae39a50fa0 100644 --- a/crates/registry-breg/tests/postgres_proposal.rs +++ b/crates/registry-breg/tests/postgres_proposal.rs @@ -2215,7 +2215,8 @@ async fn proposal_list_query_refusals_follow_authority_and_audit_concealment() { ("limit=0", "limit"), ("cursor=not-a-uuid", "cursor"), ("owner=another", "owner"), - ("top=1", "top"), + ("top=1", "query"), + ("limit=1&%74op=2", "query"), ] { let response = reqwest::get(format!( "{}/v1/proposals?accessProfile=clerk&{query}", diff --git a/crates/registry-breg/tests/postgres_proposal_messages.rs b/crates/registry-breg/tests/postgres_proposal_messages.rs index 2bfaa0a7b8..85823afed0 100644 --- a/crates/registry-breg/tests/postgres_proposal_messages.rs +++ b/crates/registry-breg/tests/postgres_proposal_messages.rs @@ -782,11 +782,12 @@ async fn the_applicant_and_the_reviewer_exchange_messages_and_an_unread_answer_i .as_str() .expect("a second page") .to_owned(); + let encoded_cursor: String = cursor.bytes().map(|byte| format!("%{byte:02X}")).collect(); let (status, _, rest) = request( &fixture, citizen(CITIZEN), "GET", - &format!("/v1/proposals/{id}/messages?accessProfile=citizen&limit=1&after={cursor}"), + &format!("/v1/proposals/{id}/messages?accessProfile=citizen&%6Cimit=%2B1&%63ursor={encoded_cursor}"), None, None, Value::Null, @@ -916,6 +917,124 @@ async fn the_owner_and_the_subject_post_and_read_and_a_neighbour_gets_not_found( fixture.finish().await; } +#[tokio::test] +async fn thread_page_faults_follow_visibility_and_are_audited() { + let fixture = fixture().await; + let id = filed( + &fixture, + citizen(CITIZEN), + "apply-for-licence", + CITIZEN, + "page-faults", + ) + .await; + let unknown = Uuid::new_v4(); + for (query, code, location) in [ + ("limit=1&%6Cimit=2", "request.invalid", "limit"), + ("limit=1&limit=2", "request.invalid", "limit"), + ("limit=%GG", "request.invalid", "limit"), + ("limit=0", "request.invalid", "limit"), + ("limit=51", "request.invalid", "limit"), + ("cursor=01", "query.cursor-invalid", "cursor"), + ("cursor=%2B1", "query.cursor-invalid", "cursor"), + ("cursor=1&%63ursor=2", "request.invalid", "cursor"), + ("cursor=opaque-canary", "query.cursor-invalid", "cursor"), + ("cursor=1&after=opaque-canary", "query.invalid", "query"), + ("cursor=1&%61fter=%GG", "query.invalid", "query"), + ("malformed-canary", "query.invalid", "query"), + ] { + let path = |id| format!("/v1/proposals/{id}/messages?{query}&accessProfile=citizen"); + let concealed = |mut body: Value| { + body.as_object_mut().unwrap().remove("traceId"); + body + }; + let (status, _, hidden) = request( + &fixture, + citizen(NEIGHBOUR), + "GET", + &path(id), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{query}: {hidden}"); + let (status, _, missing) = request( + &fixture, + citizen(NEIGHBOUR), + "GET", + &path(unknown), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{query}: {missing}"); + assert_eq!(hidden["code"], "resource.not-found"); + assert_eq!(concealed(hidden), concealed(missing)); + + let audit_start = fixture.audit_capture.entries().len(); + let (status, _, fault) = request( + &fixture, + citizen(CITIZEN), + "GET", + &path(id), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{query}: {fault}"); + assert_eq!(fault["code"], code, "{query}: {fault}"); + assert_eq!(fault["fieldPath"], location, "{query}: {fault}"); + assert!(!fault.to_string().contains("canary"), "{fault}"); + let entries = fixture.audit_capture.entries(); + let entries = &entries[audit_start..]; + assert!( + entries.iter().any(|entry| { + let record = &entry["record"]; + record["traceId"] == fault["traceId"] + && record["phase"] == "refusal" + && record["operationId"] == "proposals.apply-for-licence.message" + && record["selectedAccessProfile"] == "citizen" + }), + "{entries:?}" + ); + let audit = serde_json::to_string(entries).unwrap(); + assert!(!audit.contains("opaque-canary") && !audit.contains("malformed-canary")); + } + let (_, etag, _) = get(&fixture, citizen(CITIZEN), id).await; + for (suffix, location) in [("", "/text"), ("/read", "/through")] { + let (status, _, fault) = request( + &fixture, + citizen(CITIZEN), + "POST", + &format!("/v1/proposals/{id}/messages{suffix}?accessProfile=citizen"), + etag.as_deref(), + Some("missing-thread-body-member"), + json!({}), + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{fault}"); + assert_eq!(fault["code"], "request.invalid", "{fault}"); + assert_eq!(fault["fieldPath"], location, "{fault}"); + } + fixture.audit_capture.fail_after(0); + let (status, _, fault) = request( + &fixture, + citizen(CITIZEN), + "GET", + &format!("/v1/proposals/{id}/messages?accessProfile=citizen&limit=1&limit=2"), + None, + None, + Value::Null, + ) + .await; + assert_eq!(status, StatusCode::SERVICE_UNAVAILABLE, "{fault}"); + assert!(fault.get("fieldPath").is_none(), "{fault}"); + fixture.finish().await; +} + /// D6: an Action without review carries a thread. The office talks to the /// applicant and applies by hand; applying closes the thread for writes and /// leaves it readable. @@ -1866,6 +1985,20 @@ async fn bounded_office_staff_get_the_same_answer_for_a_hidden_proposal_and_an_u None, Value::Null, ), + ( + "GET", + format!("/v1/proposals/{target}/messages?limit=1&limit=2&accessProfile=district"), + None, + None, + Value::Null, + ), + ( + "GET", + format!("/v1/proposals/{target}/messages?cursor=%GG&accessProfile=district"), + None, + None, + Value::Null, + ), ( "POST", format!("/v1/proposals/{target}/messages/read?accessProfile=district"), diff --git a/crates/registry-breg/tests/proposal_messages_compiler.rs b/crates/registry-breg/tests/proposal_messages_compiler.rs index 3c7493de92..eb54336c90 100644 --- a/crates/registry-breg/tests/proposal_messages_compiler.rs +++ b/crates/registry-breg/tests/proposal_messages_compiler.rs @@ -226,6 +226,12 @@ fn message_openapi_describes_the_three_routes_and_their_preconditions() { let thread = &api["paths"]["/v1/proposals/{proposal_id}/messages"]; let send = &thread["post"]; assert_eq!(thread["get"]["operationId"], "proposals.list-messages"); + let parameters = thread["get"]["parameters"].as_array().unwrap(); + assert!(parameters.iter().any(|entry| entry["name"] == "cursor")); + assert!(parameters.iter().all(|entry| entry["name"] != "after")); + assert!(thread["get"] + .pointer("/responses/400/content/application~1problem+json/examples/query.invalid") + .is_some()); assert_eq!(send["operationId"], "proposals.message"); for header in ["If-Match", "Idempotency-Key"] { assert!(send["parameters"].as_array().unwrap().iter().any(|entry| { diff --git a/crates/registry-breg/tests/support/proposal_additions.rs b/crates/registry-breg/tests/support/proposal_additions.rs index 3d2c69d096..4a29b11cd7 100644 --- a/crates/registry-breg/tests/support/proposal_additions.rs +++ b/crates/registry-breg/tests/support/proposal_additions.rs @@ -1015,7 +1015,9 @@ async fn adding_a_form_entry_preserves_the_submission_and_fences_replay_and_limi for (input, field) in [ (json!({}), "/input/householdSize"), (json!({"householdSize":"four"}), "/input/householdSize"), - (json!({"householdSize":4,"unknown":true}), "/input/unknown"), + (json!({"householdSize":4,"unknownCanary":true}), "/input"), + (json!({"householdSize":4,"unknown/canary":true}), "/input"), + (json!(["malformed-canary"]), "/input"), ] { let response = add(Some(etag), "invalid-form", input).await.unwrap(); assert_eq!(response.status(), 400); @@ -1023,6 +1025,35 @@ async fn adding_a_form_entry_preserves_the_submission_and_fences_replay_and_limi assert_eq!(problem["code"], "request.invalid", "{problem}"); assert_eq!(problem["fieldPath"], field, "{problem}"); } + for (body, location) in [ + (json!({}), Some("/input")), + (json!({"input":null}), Some("/input")), + ( + json!({"input":{"householdSize":4},"extraCanary":true}), + None, + ), + ] { + let response = http + .post(&url) + .header("if-match", etag) + .header("idempotency-key", "malformed-form-envelope") + .json(&body) + .send() + .await + .unwrap(); + assert_eq!(response.status(), 400); + let problem: Value = response.json().await.unwrap(); + assert_eq!(problem["code"], "request.invalid", "{problem}"); + assert_eq!( + problem.get("fieldPath").and_then(Value::as_str), + location, + "{problem}" + ); + if location.is_none() { + assert!(problem.get("fieldPath").is_none(), "{problem}"); + assert!(!problem.to_string().contains("extraCanary"), "{problem}"); + } + } let input = json!({"householdSize":4}); let missing = add(None, "missing-if-match", input.clone()).await.unwrap(); assert_eq!(missing.status(), 428); diff --git a/crates/registry-breg/tests/support/proposal_review_asks.rs b/crates/registry-breg/tests/support/proposal_review_asks.rs index 9d042615e2..2ab35cbd62 100644 --- a/crates/registry-breg/tests/support/proposal_review_asks.rs +++ b/crates/registry-breg/tests/support/proposal_review_asks.rs @@ -3141,9 +3141,44 @@ async fn a_form_want_discloses_only_the_cited_entry_in_live_review_context() { } let answer_path = format!("{path}/asks/{ask}/answer"); + let mut concealed = Vec::new(); + for target in [id, Uuid::new_v4()] { + let (status, _, mut problem) = request_as( + &fixture, + caller_claims("other-applicant", registry_platform_oidc::ActorKind::Human), + "POST", + &format!("/v1/proposals/{target}/asks/{ask}/answer"), + Some(&etag), + Some("hidden-form-answer"), + json!({"formEntries":"malformed-canary"}), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{problem}"); + assert_eq!(problem["code"], "resource.not-found", "{problem}"); + problem.as_object_mut().unwrap().remove("traceId"); + concealed.push(problem); + } + assert_eq!(concealed[0], concealed[1]); + for text in [json!(null), json!(false), json!(1), json!([]), json!({})] { + let (status, _, problem) = request( + &fixture, + "POST", + &answer_path, + Some(&etag), + Some("answer-malformed-text"), + json!({"text":text,"formEntries":[entries[2]]}), + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{problem}"); + assert_eq!(problem["code"], "request.invalid", "{problem}"); + assert_eq!(problem["fieldPath"], "/text", "{problem}"); + } for (key, cited) in [ ("missing-form", json!([])), ("answer-wrong-form", json!([entries[0]])), + ("answer-form-wrong-type", json!("malformed-canary")), + ("answer-form-wrong-id-type", json!([false])), + ("answer-form-malformed-id", json!(["malformed-canary"])), ] { let (status, _, problem) = request( &fixture, From 05eefb364f199676b783cef5f9f55be5f9cb6ec2 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Thu, 3 Dec 2026 01:44:39 +0000 Subject: [PATCH 48/96] fix(breg): admit native reads before refusing retired paging Signed-off-by: Jeremi Joslin --- crates/registry-breg-client/src/geojson.rs | 15 +- crates/registry-breg-client/src/query.rs | 6 +- .../registry-breg/src/api/external_views.rs | 13 +- crates/registry-breg/src/api/gis.rs | 29 +- crates/registry-breg/src/api/mod.rs | 143 ++++++++- crates/registry-breg/src/cursor.rs | 9 +- .../src/postgres/external_runtime.rs | 85 ++++- crates/registry-breg/src/query.rs | 107 +++---- .../registry-breg/tests/disclosure/history.rs | 4 +- crates/registry-breg/tests/http_read_only.rs | 291 ++++++++++++++++-- .../tests/postgres_access_log.rs | 52 +++- .../tests/postgres_consent_access.rs | 16 +- .../tests/postgres_historical.rs | 10 +- .../tests/postgres_list_page_plans.rs | 6 +- .../tests/postgres_membership_access.rs | 10 +- .../registry-breg/tests/postgres_mutation.rs | 4 +- crates/registry-breg/tests/postgres_read.rs | 98 ++++-- .../tests/postgres_read_dependencies.rs | 6 +- .../tests/postgres_required_filters.rs | 6 +- .../tests/postgres_spatial_read.rs | 79 +++-- .../tests/postgres_statistics_http.rs | 2 +- .../tests/postgres_statistics_stock.rs | 4 +- products/breg/loadtest/support/loadenv.py | 2 +- .../breg/loadtest/support/test_harness.py | 2 +- .../breg/quickstart/support/quickstart.py | 4 +- .../scripts/test_check_client_capabilities.py | 2 +- products/platform/CONFIG-CONVENTIONS.md | 1 - 27 files changed, 802 insertions(+), 204 deletions(-) diff --git a/crates/registry-breg-client/src/geojson.rs b/crates/registry-breg-client/src/geojson.rs index cbce43fb39..06afc7c01d 100644 --- a/crates/registry-breg-client/src/geojson.rs +++ b/crates/registry-breg-client/src/geojson.rs @@ -227,7 +227,6 @@ pub struct BRegGeoJsonPage { #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct BRegGeoJsonContinuationProjection { pub route: String, - #[serde(alias = "skiptoken")] pub cursor: String, #[serde(skip_serializing_if = "Option::is_none")] pub access_profile: Option, @@ -581,6 +580,20 @@ mod tests { use super::*; use serde_json::json; + #[test] + fn retired_saved_geojson_cursor_name_is_refused() { + let saved = json!({"route": "assets", "cursor": "opaque", "accessProfile": "reader"}); + let continuation = + serde_json::from_value::(saved.clone()).unwrap(); + assert_eq!(serde_json::to_value(continuation).unwrap(), saved); + for retired in [ + json!({"route": "assets", "skiptoken": "opaque"}), + json!({"route": "assets", "cursor": "opaque", "skiptoken": "opaque"}), + ] { + assert!(serde_json::from_value::(retired).is_err()); + } + } + #[test] fn feature_preserves_null_geometry_and_has_no_mutation_metadata() { let feature = decode_feature(json!({ diff --git a/crates/registry-breg-client/src/query.rs b/crates/registry-breg-client/src/query.rs index ca392aaede..477e7bd2b2 100644 --- a/crates/registry-breg-client/src/query.rs +++ b/crates/registry-breg-client/src/query.rs @@ -454,7 +454,6 @@ pub struct BRegContinuationProjection { /// Logical Base Registry Engine record route segment. pub route: String, /// Opaque Base Registry Engine `cursor`. - #[serde(alias = "skiptoken")] pub cursor: String, /// Representation selected for the original page. pub format: BRegRecordFormat, @@ -1222,10 +1221,7 @@ mod tests { let fields = legacy.as_object_mut().unwrap(); let cursor = fields.remove("cursor").unwrap(); fields.insert("skiptoken".to_owned(), cursor.clone()); - assert_eq!( - serde_json::from_value::(legacy.clone()).unwrap(), - continuation - ); + assert!(serde_json::from_value::(legacy.clone()).is_err()); legacy["cursor"] = cursor; assert!(serde_json::from_value::(legacy).is_err()); } diff --git a/crates/registry-breg/src/api/external_views.rs b/crates/registry-breg/src/api/external_views.rs index 05b4610a7d..0ae6a6409e 100644 --- a/crates/registry-breg/src/api/external_views.rs +++ b/crates/registry-breg/src/api/external_views.rs @@ -564,7 +564,15 @@ async fn handle( } else { Operation::List }; - let profile_selection = admission_profile(raw.as_deref()); + let retired_paging = has_retired_page_parameter(raw.as_deref()); + let profile_selection = if retired_paging { + match retired_page_admission_profile(raw.as_deref()) { + Ok(selection) => selection, + Err(_) => return concealed(FailedCheck::AccessProfile), + } + } else { + admission_profile(raw.as_deref()) + }; let context = match root_context( service, view, @@ -612,6 +620,9 @@ async fn handle( }, None => None, }; + if retired_paging { + return invalid_query_at("query"); + } let options = match QueryOptions::parse(raw.as_deref(), true) { Ok(value) => value, Err(error) => return error.problem(), diff --git a/crates/registry-breg/src/api/gis.rs b/crates/registry-breg/src/api/gis.rs index e8566a4117..663f5bbbea 100644 --- a/crates/registry-breg/src/api/gis.rs +++ b/crates/registry-breg/src/api/gis.rs @@ -19,10 +19,10 @@ use serde_json::{json, Map, Value}; use super::{ audited_read_concealment, audited_read_refusal, authorize_route_with_reason, concealed, - data_field_type, exact_non_record_no_store, invalid_query, percent_decode, - profile_not_authorized, read_query, unavailable, Authenticated, AuthorizedSurface, HttpService, - QueryOptions, QueryParseError, ReadQueryError, RecordReadKind, RecordReadRequest, - VerifiedRequestClaims, MAX_RAW_QUERY_BYTES, + data_field_type, exact_non_record_no_store, has_retired_page_parameter, invalid_query, + percent_decode, profile_not_authorized, read_query, unavailable, Authenticated, + AuthorizedSurface, HttpService, QueryOptions, QueryParseError, ReadQueryError, RecordReadKind, + RecordReadRequest, VerifiedRequestClaims, MAX_RAW_QUERY_BYTES, }; use crate::audit::ReadRefusalReason; use crate::contract::{FieldTypeSource, Operation}; @@ -304,17 +304,16 @@ async fn items( ) .await; } - // The feature surface speaks its own parameter names, so a refusal here - // stays unlocated rather than naming a native query parameter. + // GIS query errors use the feature surface's parameter contract. let query = match parse_items_query(raw_query.as_deref()) { Ok(query) => query, - Err(QueryParseError::Invalid | QueryParseError::InvalidAt(_)) => { + Err(error) => { return audited_read_refusal( &service, authorized.route, &authorized.surface, None, - invalid_query(), + error.problem(), &correlation, ) .await; @@ -760,6 +759,9 @@ fn parse_items_query(raw: Option<&str>) -> Result MAX_RAW_QUERY_BYTES { return Err(QueryParseError::Invalid); } + if has_retired_page_parameter(Some(raw)) { + return Err(QueryParseError::InvalidAt("query")); + } let pairs = decode_query_pairs(raw)?; let mut seen = BTreeSet::new(); let mut query = GisItemsQuery::default(); @@ -947,9 +949,16 @@ mod tests { assert_eq!(query.limit, Some(1000)); assert_eq!(query.cursor, None); - for raw in ["%24top=2", "%24skiptoken=opaque", "limit=2&limit=2"] { - assert_eq!(parse_items_query(Some(raw)), Err(QueryParseError::Invalid)); + for raw in ["%24top=2", "%24skiptoken=opaque"] { + assert_eq!( + parse_items_query(Some(raw)), + Err(QueryParseError::InvalidAt("query")) + ); } + assert_eq!( + parse_items_query(Some("limit=2&limit=2")), + Err(QueryParseError::Invalid) + ); assert_eq!( parse_items_query(Some("cursor=opaque&bbox=100,13,101,14")), Err(QueryParseError::Invalid) diff --git a/crates/registry-breg/src/api/mod.rs b/crates/registry-breg/src/api/mod.rs index 0a793c8d39..704ed7d13f 100644 --- a/crates/registry-breg/src/api/mod.rs +++ b/crates/registry-breg/src/api/mod.rs @@ -1009,8 +1009,26 @@ async fn read_dispatch( headers: HeaderMap, Path(path): Path>, ) -> Response { - let options = match QueryOptions::parse(raw_query.as_deref(), true) { + let retired_paging = has_retired_page_parameter(raw_query.as_deref()); + let parsed = if retired_paging { + QueryOptions::for_admission(raw_query.as_deref()) + } else { + QueryOptions::parse(raw_query.as_deref(), true) + }; + let options = match parsed { Ok(options) => options, + Err(_) if retired_paging => { + return audited_read_concealment( + &service, + &route, + &QueryOptions::default(), + &claims, + path.get("record_id"), + &correlation, + RouteRefusal::admission_check(FailedCheck::AccessProfile), + ) + .await; + } Err(error) => { return audited_known_read_refusal( &service, @@ -1129,6 +1147,17 @@ async fn read_dispatch( ) .await; } + if retired_paging { + return audited_read_refusal( + &service, + &route, + &surface, + Some(record_id), + invalid_query_at("query"), + &correlation, + ) + .await; + } let request = RecordReadRequest { entity_id: route.entity_id.clone(), operation_id: route.id.clone(), @@ -1175,6 +1204,24 @@ async fn read_dispatch( ) .await; } + if retired_paging { + let response = if representation == CursorRepresentation::GeoJson + && !geojson_available(&surface) + { + profile_not_authorized(FailedCheck::Disclosure) + } else { + invalid_query_at("query") + }; + return audited_read_refusal( + &service, + &route, + &surface, + path.get("record_id"), + response, + &correlation, + ) + .await; + } let query = match read_query( &service, &route, @@ -1298,8 +1345,26 @@ async fn lookup_dispatch( headers: HeaderMap, body: Body, ) -> Response { - let options = match QueryOptions::parse(raw_query.as_deref(), true) { + let retired_paging = has_retired_page_parameter(raw_query.as_deref()); + let parsed = if retired_paging { + QueryOptions::for_admission(raw_query.as_deref()) + } else { + QueryOptions::parse(raw_query.as_deref(), true) + }; + let options = match parsed { Ok(options) => options, + Err(_) if retired_paging => { + return audited_read_concealment( + &service, + &route, + &QueryOptions::default(), + &claims, + None, + &correlation, + RouteRefusal::admission_check(FailedCheck::AccessProfile), + ) + .await; + } Err(error) => { return audited_known_read_refusal( &service, @@ -1347,6 +1412,17 @@ async fn lookup_dispatch( if let Some(refusal) = field_encryption_refusal(&service, surface.entity) { return refusal; } + if retired_paging { + return audited_read_refusal( + &service, + &route, + &surface, + None, + invalid_query_at("query"), + &correlation, + ) + .await; + } if surface.read_path.is_some() || options.has_non_projection_query_members() { return audited_read_refusal( &service, @@ -1731,7 +1807,13 @@ async fn snapshot_dispatch( let Some(snapshots) = &service.snapshots else { return concealed(FailedCheck::Visibility); }; - let options = match QueryOptions::parse_snapshot(raw_query.as_deref()) { + let retired_paging = has_retired_page_parameter(raw_query.as_deref()); + let parsed = if retired_paging { + QueryOptions::for_admission(raw_query.as_deref()) + } else { + QueryOptions::parse_snapshot(raw_query.as_deref()) + }; + let options = match parsed { Ok(options) => options, Err(_) => { return audited_known_read_refusal( @@ -1780,6 +1862,17 @@ async fn snapshot_dispatch( if let Some(refusal) = field_encryption_refusal(&service, surface.entity) { return refusal; } + if retired_paging { + return audited_read_refusal( + &service, + &route, + &surface, + None, + invalid_query_at("query"), + &correlation, + ) + .await; + } let query = match read_query( &service, &route, @@ -5267,6 +5360,12 @@ struct HistoricalQueryOptions { } impl QueryOptions { + fn for_admission(raw: Option<&str>) -> Result { + let mut options = Self::default(); + options.parsed.access_profile = retired_page_admission_profile(raw)?; + Ok(options) + } + fn parse(raw: Option<&str>, allow_read_query: bool) -> Result { let Some(raw) = raw else { return Ok(Self::default()); @@ -5478,6 +5577,44 @@ impl ReadQueryError { } } +/// Detect retired page names independently of other query faults. Ignore +/// values here so aliases remain identifiable alongside malformed input. +fn has_retired_page_parameter(raw: Option<&str>) -> bool { + raw.filter(|raw| raw.len() <= MAX_RAW_QUERY_BYTES) + .is_some_and(|raw| { + raw.split('&').any(|pair| { + let name = pair.split_once('=').map_or(pair, |(name, _)| name); + matches!( + percent_decode(name).ok().as_deref(), + Some("$top" | "$skiptoken") + ) + }) + }) +} + +/// Read the explicit selector without allowing a malformed or repeated +/// selector to fall back to default profile selection. +fn retired_page_admission_profile(raw: Option<&str>) -> Result, QueryParseError> { + let Some(raw) = raw else { return Ok(None) }; + if raw.len() > MAX_RAW_QUERY_BYTES { + return Err(QueryParseError::Invalid); + } + let mut selected = None; + for pair in raw.split('&') { + let (name, value) = pair + .split_once('=') + .map_or((pair, None), |(name, value)| (name, Some(value))); + if percent_decode(name).ok().as_deref() != Some("accessProfile") { + continue; + } + let value = percent_decode(value.ok_or(QueryParseError::Invalid)?)?; + if !strict_query::valid_config_identifier(&value) || selected.replace(value).is_some() { + return Err(QueryParseError::Invalid); + } + } + Ok(selected) +} + /// Extract only the selector needed for admission. Full validation follows /// authorization, so malformed options cannot reveal an inaccessible target. fn admission_profile(raw: Option<&str>) -> Option { diff --git a/crates/registry-breg/src/cursor.rs b/crates/registry-breg/src/cursor.rs index 6c836f67d4..ae50cef932 100644 --- a/crates/registry-breg/src/cursor.rs +++ b/crates/registry-breg/src/cursor.rs @@ -707,7 +707,7 @@ mod tests { assert_eq!(token.len(), MAX_TOKEN_BYTES); assert_eq!(token.len(), crate::query::MAX_CURSOR_TOKEN_BYTES); assert!(codec.decode(&token, 1_001).is_ok()); - assert!(crate::query::parse_read_query([("$skiptoken", token.as_str())]).is_ok()); + assert!(crate::query::parse_read_query([("cursor", token.as_str())]).is_ok()); assert!(registry_breg_client::BRegContinuation::try_from_projection( registry_breg_client::BRegContinuationProjection { route: "assets".to_owned(), @@ -909,6 +909,13 @@ mod tests { let wire = URL_SAFE_NO_PAD.decode(token).expect("golden is base64url"); assert_eq!(wire[0], WIRE_VERSION); assert_eq!(wire[1..=NONCE_BYTES], [nonce; NONCE_BYTES]); + let query = crate::query::parse_read_query([("cursor", token)]) + .expect("preexisting cursor can be carried by the canonical parameter"); + assert!(matches!( + query.mode, + crate::query::ParsedReadQueryMode::SkipToken { token: parsed } if parsed == token + )); + assert!(crate::query::parse_read_query([("$skiptoken", token)]).is_err()); assert_eq!(codec.decode(token, 1_001).expect("golden opens"), payload()); } } diff --git a/crates/registry-breg/src/postgres/external_runtime.rs b/crates/registry-breg/src/postgres/external_runtime.rs index 738f449715..b36e2beb19 100644 --- a/crates/registry-breg/src/postgres/external_runtime.rs +++ b/crates/registry-breg/src/postgres/external_runtime.rs @@ -3124,12 +3124,71 @@ mod postgres_tests { } } + #[tokio::test] + async fn retired_external_paging_is_disclosed_only_for_admitted_views() { + use axum::http::StatusCode; + + let served = Served::new(Duration::from_secs(2)).await; + served.publish_all().await; + let caller = reader("reader-principal", &["allowed"]); + let (status, page) = served.get("&limit=1", caller.clone()).await; + assert_eq!(status, StatusCode::OK, "{page}"); + let cursor = page["nextCursor"].as_str().unwrap(); + let (status, page) = served + .get(&format!("&cursor={cursor}"), caller.clone()) + .await; + assert_eq!(status, StatusCode::OK, "{page}"); + + for query in [ + "&$top=1".to_owned(), + "&limit=1&%24top=private-canary".to_owned(), + format!("&%24skiptoken={cursor}"), + "&$skiptoken=one&$skiptoken=two".to_owned(), + ] { + let (status, problem) = served.get(&query, caller.clone()).await; + assert_eq!(status, StatusCode::BAD_REQUEST, "{query}"); + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + assert!(!problem.to_string().contains("private-canary")); + let (status, _, problem) = served + .send( + &format!("/v1/external-views/view/link/records?accessProfile=unknown{query}"), + caller.clone(), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND, "{problem}"); + assert_ne!(problem["code"], "query.invalid"); + } + for selection in [ + "", + "&accessProfile", + "&%61ccessProfile=%ff", + "&accessProfile=", + "&accessProfile=reader&%61ccessProfile=reader", + ] { + let (status, _, problem) = served + .send( + &format!("/v1/external-views/view/link/records?%24top=1{selection}"), + caller.clone(), + ) + .await; + if selection.is_empty() { + assert_eq!(status, StatusCode::BAD_REQUEST); + assert_eq!(problem["fieldPath"], "query"); + } else { + assert_eq!(status, StatusCode::NOT_FOUND, "{selection}"); + assert_eq!(problem["code"], "resource.not-found"); + } + } + served.fixture.cleanup().await; + } + #[tokio::test] async fn a_scope_lock_timeout_is_unavailable_never_incomplete_or_an_invalid_cursor() { let served = Served::new(Duration::from_millis(300)).await; served.publish_all().await; let caller = reader("reader-principal", &["allowed"]); - let (status, first) = served.get("&$top=1", caller.clone()).await; + let (status, first) = served.get("&limit=1", caller.clone()).await; assert_eq!(status, axum::http::StatusCode::OK, "{first}"); let cursor = first["nextCursor"].as_str().unwrap().to_owned(); @@ -3144,11 +3203,11 @@ mod postgres_tests { ) .await .unwrap(); - let (status, problem) = served.get("&$top=1", caller.clone()).await; + let (status, problem) = served.get("&limit=1", caller.clone()).await; assert_eq!(status, axum::http::StatusCode::SERVICE_UNAVAILABLE); assert_eq!(problem["code"], "source.unavailable", "{problem}"); let (status, problem) = served - .get(&format!("&$skiptoken={cursor}"), caller.clone()) + .get(&format!("&cursor={cursor}"), caller.clone()) .await; assert_eq!(status, axum::http::StatusCode::SERVICE_UNAVAILABLE); assert_eq!(problem["code"], "source.unavailable", "{problem}"); @@ -3160,7 +3219,7 @@ mod postgres_tests { .await .unwrap(); - let (status, next) = served.get(&format!("&$skiptoken={cursor}"), caller).await; + let (status, next) = served.get(&format!("&cursor={cursor}"), caller).await; assert_eq!(status, axum::http::StatusCode::OK, "{next}"); assert_eq!(labels(&next).len(), 1); served.fixture.cleanup().await; @@ -3171,7 +3230,7 @@ mod postgres_tests { let served = Served::new(Duration::from_secs(2)).await; served.publish_all().await; let caller = reader("reader-principal", &["allowed"]); - let ordered = "&$top=1&$orderby=label%20asc&$count=true"; + let ordered = "&limit=1&$orderby=label%20asc&$count=true"; let (status, first) = served.get(ordered, caller.clone()).await; assert_eq!(status, axum::http::StatusCode::OK, "{first}"); assert_eq!(labels(&first), ["first"]); @@ -3185,13 +3244,13 @@ mod postgres_tests { .publish_label(&served.scope, "third", "thirdly") .await; let (status, second) = served - .get(&format!("&$skiptoken={cursor}"), caller.clone()) + .get(&format!("&cursor={cursor}"), caller.clone()) .await; assert_eq!(status, axum::http::StatusCode::OK, "{second}"); assert_eq!(labels(&second), ["second"]); assert_eq!(second["count"], 3); let cursor = second["nextCursor"].as_str().unwrap().to_owned(); - let (status, third) = served.get(&format!("&$skiptoken={cursor}"), caller).await; + let (status, third) = served.get(&format!("&cursor={cursor}"), caller).await; assert_eq!(status, axum::http::StatusCode::OK, "{third}"); assert_eq!(labels(&third), ["thirdly"]); assert!(third.get("nextCursor").is_none()); @@ -3304,12 +3363,12 @@ mod postgres_tests { // A continuation of a plain list is as plain as its first page. let mut seen = BTreeMap::new(); - let (status, first) = served.get("&$top=2", caller.clone()).await; + let (status, first) = served.get("&limit=2", caller.clone()).await; assert_eq!(status, axum::http::StatusCode::OK, "{first}"); seen.extend(availabilities(&first)); let cursor = first["nextCursor"].as_str().unwrap().to_owned(); let (status, second) = served - .get(&format!("&$skiptoken={cursor}"), caller.clone()) + .get(&format!("&cursor={cursor}"), caller.clone()) .await; assert_eq!(status, axum::http::StatusCode::OK, "{second}"); assert_eq!(second["status"], "unavailable", "{second}"); @@ -3468,7 +3527,7 @@ mod postgres_tests { let served = Served::new(Duration::from_secs(2)).await; served.publish_all().await; let (status, first) = served - .get("&$top=1", reader("reader-principal", &["allowed"])) + .get("&limit=1", reader("reader-principal", &["allowed"])) .await; assert_eq!(status, axum::http::StatusCode::OK, "{first}"); let cursor = first["nextCursor"].as_str().unwrap().to_owned(); @@ -3482,7 +3541,7 @@ mod postgres_tests { "another row boundary", ), ] { - let (status, problem) = served.get(&format!("&$skiptoken={cursor}"), caller).await; + let (status, problem) = served.get(&format!("&cursor={cursor}"), caller).await; assert_eq!( status, axum::http::StatusCode::BAD_REQUEST, @@ -3495,7 +3554,7 @@ mod postgres_tests { } let (status, next) = served .get( - &format!("&$skiptoken={cursor}"), + &format!("&cursor={cursor}"), reader("reader-principal", &["allowed"]), ) .await; @@ -4860,7 +4919,7 @@ mod postgres_tests { ), (root_refresh(ROOTS[3].0, "desk"), desk_client()), ( - format!("{}&$top=1", root_refresh(ROOTS[0].0, "desk")), + format!("{}&limit=1", root_refresh(ROOTS[0].0, "desk")), desk_client(), ), ] { diff --git a/crates/registry-breg/src/query.rs b/crates/registry-breg/src/query.rs index e962e604e1..b6aafeafc3 100644 --- a/crates/registry-breg/src/query.rs +++ b/crates/registry-breg/src/query.rs @@ -623,13 +623,11 @@ where } /// The fixed query parameter names a refusal may name as its location. -pub const QUERY_PARAMETERS: [&str; 13] = [ +pub const QUERY_PARAMETERS: [&str; 11] = [ "$select", "$filter", "$orderby", - "$top", "$count", - "$skiptoken", "bbox", "accessProfile", "asOf", @@ -741,7 +739,7 @@ struct QueryBuilder { top: Option, count: Option, bbox: Option, - skiptoken: Option<(String, &'static str)>, + skiptoken: Option, } impl QueryBuilder { @@ -770,7 +768,7 @@ impl QueryBuilder { ensure_absent(self.orderby.is_none())?; self.orderby = Some(parse_orderby(value)?); } - "limit" | "$top" => { + "limit" => { ensure_absent(self.top.is_none())?; self.top = Some(parse_top(value)?); } @@ -782,14 +780,9 @@ impl QueryBuilder { ensure_absent(self.bbox.is_none())?; self.bbox = Some(parse_bbox(value)?); } - "cursor" | "$skiptoken" => { + "cursor" => { ensure_absent(self.skiptoken.is_none())?; - let name = if key == "cursor" { - "cursor" - } else { - "$skiptoken" - }; - self.skiptoken = Some((parse_opaque_value(value, MAX_CURSOR_TOKEN_BYTES)?, name)); + self.skiptoken = Some(parse_opaque_value(value, MAX_CURSOR_TOKEN_BYTES)?); } "fields" | "filter" | "sort" | "pageSize" | "$skip" | "$apply" | "$expand" | "$batch" => { @@ -804,7 +797,7 @@ impl QueryBuilder { } fn cursor_parameter(&self) -> Option<&'static str> { - self.skiptoken.as_ref().map(|(_, parameter)| *parameter) + self.skiptoken.as_ref().map(|_| "cursor") } /// A continuation carries its whole query, so a conflict names the @@ -824,7 +817,7 @@ impl QueryBuilder { bbox: self.bbox, }; let mode = match self.skiptoken { - Some((token, _)) => { + Some(token) => { if self.as_of.is_some() || options.has_any_option() { return Err(QueryParseError::ConflictingOptions); } @@ -1825,7 +1818,7 @@ mod tests { ("$select", "case-code,status"), ("$filter", "status eq 'open'"), ("$orderby", "opened-on desc"), - ("$top", "50"), + ("limit", "50"), ("$count", "false"), ]) .expect("query parses"); @@ -1901,27 +1894,36 @@ mod tests { ); } assert_eq!( - parse([("$top", "10"), ("$top", "11")]), + parse([("limit", "10"), ("limit", "11")]), Err(QueryParseError::DuplicateOption) ); } #[test] - fn pagination_names_share_query_and_cursor_rules() { - assert_eq!(parse([("limit", "10")]), parse([("$top", "10")])); - assert_eq!( - parse([("accessProfile", "reader"), ("cursor", "opaque-token")]), - parse([("accessProfile", "reader"), ("$skiptoken", "opaque-token"),]) - ); - for (parameters, duplicate) in [ - ([("$top", "10"), ("limit", "10")], "limit"), - ([("limit", "10"), ("$top", "10")], "$top"), - ([("$skiptoken", "same"), ("cursor", "same")], "cursor"), - ([("cursor", "same"), ("$skiptoken", "same")], "$skiptoken"), + fn retired_page_names_have_no_public_parameter_location() { + for (alias, value) in [("$top", "10"), ("$skiptoken", "opaque")] { + assert_eq!( + parse_read_query_located([(alias, value)]).unwrap_err().1, + None + ); + assert_eq!( + parse_snapshot_query_located([(alias, value)]) + .unwrap_err() + .1, + None + ); + } + } + + #[test] + fn canonical_page_names_keep_their_fault_locations() { + for (parameters, member) in [ + ([("limit", "10"), ("limit", "11")], "limit"), + ([("cursor", "same"), ("cursor", "same")], "cursor"), ] { assert_eq!( parse_read_query_located(parameters), - Err((QueryParseError::DuplicateOption, Some(duplicate))) + Err((QueryParseError::DuplicateOption, Some(member))) ); } assert_eq!( @@ -1932,18 +1934,16 @@ mod tests { parse_read_query_located([("cursor", "opaque-token"), ("limit", "10")]), Err((QueryParseError::ConflictingOptions, Some("cursor"))) ); - for key in ["cursor", "$skiptoken"] { - assert_eq!( - parse_snapshot_query_located([(key, "opaque-token"), ("validAt", "later")]), - Err((QueryParseError::ConflictingOptions, Some(key))) - ); - } + assert_eq!( + parse_snapshot_query_located([("cursor", "opaque-token"), ("validAt", "later")]), + Err((QueryParseError::ConflictingOptions, Some("cursor"))) + ); } #[test] - fn skiptoken_only_allows_access_profile() { - let query = parse([("accessProfile", "reader"), ("$skiptoken", "opaque-token")]) - .expect("skiptoken query parses"); + fn cursor_only_allows_access_profile() { + let query = parse([("accessProfile", "reader"), ("cursor", "opaque-token")]) + .expect("cursor query parses"); assert!(matches!(query.mode, ParsedReadQueryMode::SkipToken { .. })); for pair in [ @@ -1951,11 +1951,11 @@ mod tests { ("$select", "field"), ("$filter", "field eq 'value'"), ("$orderby", "field"), - ("$top", "10"), + ("limit", "10"), ("$count", "true"), ] { assert_eq!( - parse([("$skiptoken", "opaque-token"), pair]), + parse([("cursor", "opaque-token"), pair]), Err(QueryParseError::ConflictingOptions) ); } @@ -1963,16 +1963,19 @@ mod tests { #[test] fn top_and_count_are_strict() { - assert!(parse([("$top", "1")]) + assert!(parse([("limit", "1")]) .unwrap() .canonical() .contains("top=1")); - assert!(parse([("$top", "100")]) + assert!(parse([("limit", "100")]) .unwrap() .canonical() .contains("top=100")); for value in ["", "0", "101", "-1", "1.0", "+1", "true"] { - assert_eq!(parse([("$top", value)]), Err(QueryParseError::InvalidValue)); + assert_eq!( + parse([("limit", value)]), + Err(QueryParseError::InvalidValue) + ); } assert!(parse([("$count", "true")]) .unwrap() @@ -2162,8 +2165,8 @@ mod tests { ); let token = "a".repeat(MAX_CURSOR_TOKEN_BYTES); - assert!(parse_read_query([("$skiptoken", token.as_str())]).is_ok()); - assert!(parse_snapshot_query([("$skiptoken", token.as_str())]).is_ok()); + assert!(parse_read_query([("cursor", token.as_str())]).is_ok()); + assert!(parse_snapshot_query([("cursor", token.as_str())]).is_ok()); assert!(parse_snapshot_query([("snapshot", "a".repeat(MAX_OPAQUE_VALUE_BYTES))]).is_ok()); assert_eq!( parse_snapshot_query([("snapshot", token.as_str())]), @@ -2171,7 +2174,7 @@ mod tests { ); let large_token = "a".repeat(MAX_CURSOR_TOKEN_BYTES + 1); assert_eq!( - parse_read_query([("$skiptoken", large_token.as_str())]), + parse_read_query([("cursor", large_token.as_str())]), Err(QueryParseError::InvalidValue) ); } @@ -2233,7 +2236,7 @@ mod tests { #[test] fn bbox_conflicts_with_skiptoken_and_is_value_free_in_debug() { assert_eq!( - parse([("$skiptoken", "cursor-canary"), ("bbox", "0,0,1,1")]), + parse([("cursor", "cursor-canary"), ("bbox", "0,0,1,1")]), Err(QueryParseError::ConflictingOptions) ); let parsed = parse([("bbox", "100.1,10.2,100.3,10.4")]).expect("bbox parses"); @@ -2315,7 +2318,7 @@ mod tests { ("$select", "household_id,valid_from"), ("$filter", "status eq 'active'"), ("$orderby", "valid_from"), - ("$top", "20"), + ("limit", "20"), ("$count", "true"), ]) .expect("snapshot query syntax"); @@ -2344,20 +2347,20 @@ mod tests { fn snapshot_continuations_cannot_override_the_bound_query() { assert!(parse_snapshot_query([ ("accessProfile", "caseworker"), - ("$skiptoken", "cursor-canary"), + ("cursor", "cursor-canary"), ]) .is_ok()); for key in [ - "snapshot", "validAt", "$select", "$filter", "$orderby", "$top", "$count", + "snapshot", "validAt", "$select", "$filter", "$orderby", "limit", "$count", ] { let value = match key { "$filter" => "field eq 'value'", - "$top" => "10", + "limit" => "10", "$count" => "true", _ => "value", }; assert_eq!( - parse_snapshot_query([("$skiptoken", "cursor-canary"), (key, value)]), + parse_snapshot_query([("cursor", "cursor-canary"), (key, value)]), Err(QueryParseError::ConflictingOptions) ); } @@ -2411,7 +2414,7 @@ mod tests { assert!(!debug.contains("secret")); assert!(!debug.contains("literal-canary")); - let cursor = parse([("$skiptoken", "cursor-canary")]).expect("cursor query parses"); + let cursor = parse([("cursor", "cursor-canary")]).expect("cursor query parses"); assert!(!format!("{cursor:?}").contains("cursor-canary")); } diff --git a/crates/registry-breg/tests/disclosure/history.rs b/crates/registry-breg/tests/disclosure/history.rs index 827eb15c02..fb02bb846b 100644 --- a/crates/registry-breg/tests/disclosure/history.rs +++ b/crates/registry-breg/tests/disclosure/history.rs @@ -306,7 +306,7 @@ impl History { async fn snapshot(&self, route: &str, profile: &str) -> Reply { self.get( - &format!("/v1/records/{route}:snapshot?$count=true&$top=100"), + &format!("/v1/records/{route}:snapshot?$count=true&limit=100"), profile, ) .await @@ -866,7 +866,7 @@ async fn an_old_snapshot_reference_does_not_read_a_record_marked_since() { history .get( &format!( - "/v1/records/{route}:snapshot?$count=true&$top=100&snapshot={reference}" + "/v1/records/{route}:snapshot?$count=true&limit=100&snapshot={reference}" ), REGISTRAR, ) diff --git a/crates/registry-breg/tests/http_read_only.rs b/crates/registry-breg/tests/http_read_only.rs index eb555471c8..29fbb52590 100644 --- a/crates/registry-breg/tests/http_read_only.rs +++ b/crates/registry-breg/tests/http_read_only.rs @@ -725,7 +725,7 @@ async fn snapshot_route_requires_its_own_current_authority_and_never_calls_live_ } assert!(snapshots.requests.lock().unwrap().is_empty()); let response = send_to(&app, Method::GET, - "/v1/records/assignments:snapshot?validAt=2026-06-05&$select=label&$filter=label%20eq%20'A'&$top=3&$count=true", + "/v1/records/assignments:snapshot?validAt=2026-06-05&$select=label&$filter=label%20eq%20'A'&limit=3&$count=true", Some(caseworker_claims("case-management"))).await; assert_eq!(response.status(), StatusCode::OK); assert_eq!(response.headers()["cache-control"], "no-store"); @@ -913,6 +913,179 @@ async fn snapshot_validity_is_typed_optional_and_has_no_clock_default() { assert!(snapshots.requests.lock().unwrap().is_empty()); } +#[tokio::test] +async fn retired_snapshot_paging_is_disclosed_only_to_the_selected_profile() { + let (app, records, snapshots) = snapshot_harness(SNAPSHOT_PROJECT, &[]); + for query in [ + "$top=1", + "%24top=private-canary&limit=1", + "cursor=opaque&%24skiptoken=private-canary", + "$top=1&$top=2", + ] { + for (profile, claims, expected) in [ + ("history", public_claims(), StatusCode::FORBIDDEN), + ( + "live-only", + caseworker_claims("case-management"), + StatusCode::FORBIDDEN, + ), + ] { + let response = send_to( + &app, + Method::GET, + &format!("/v1/records/assignments:snapshot?accessProfile={profile}&{query}"), + Some(claims), + ) + .await; + assert_eq!(response.status(), expected, "{query}"); + assert_ne!(body_json(response).await["code"], "query.invalid"); + } + let response = send_to( + &app, + Method::GET, + &format!("/v1/records/assignments:snapshot?{query}"), + Some(caseworker_claims("case-management")), + ) + .await; + assert_eq!(response.status(), StatusCode::BAD_REQUEST, "{query}"); + let problem = body_json(response).await; + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + assert!(!problem.to_string().contains("private-canary")); + } + assert!(snapshots.requests.lock().unwrap().is_empty()); + assert_eq!(records.calls(), 0); +} + +#[tokio::test] +async fn retired_get_paging_waits_for_admission_and_audit() { + assert_retired_exact_paging( + Method::GET, + "/v1/records/households/00000000-0000-4000-8000-000000000001", + ) + .await; +} + +#[tokio::test] +async fn retired_lookup_paging_waits_for_admission_and_audit() { + assert_retired_exact_paging(Method::POST, "/v1/records/households:lookup").await; +} + +async fn assert_retired_exact_paging(method: Method, route: &str) { + let harness = Harness::from_project(LOOKUP_PATH_PROJECT, true); + for (profile, claims, status, code) in [ + ( + "accessProfile=unknown&", + caseworker_claims("case-management"), + StatusCode::FORBIDDEN, + "profile.not-authorized", + ), + ( + "accessProfile=operator&", + caseworker_claims("wrong-purpose"), + StatusCode::FORBIDDEN, + "profile.not-authorized", + ), + ( + "", + caseworker_claims("case-management"), + StatusCode::BAD_REQUEST, + "query.invalid", + ), + ( + "%61ccessProfile=operator&", + caseworker_claims("case-management"), + StatusCode::BAD_REQUEST, + "query.invalid", + ), + ] { + let before = harness.records.refusal_calls(); + let response = harness + .send_json( + method.clone(), + &format!("{route}?{profile}%24top=private-canary"), + Some(claims), + json!({"selector": "by-household-code", "values": {"householdCode": "example"}}), + ) + .await; + assert_eq!(response.status(), status, "{route} {profile}"); + let problem = body_json(response).await; + assert_eq!(problem["code"], code); + if code == "query.invalid" { + assert_eq!(problem["fieldPath"], "query"); + } + assert!(!problem.to_string().contains("private-canary")); + assert_eq!(harness.records.refusal_calls(), before + 1); + } + assert_eq!(harness.records.calls(), 0); +} + +#[tokio::test] +async fn retired_paging_refuses_malformed_explicit_profile_selection() { + let harness = Harness::from_project(LOOKUP_PATH_PROJECT, true); + let (snapshots_app, snapshot_records, snapshots) = snapshot_harness(SNAPSHOT_PROJECT, &[]); + for selector in [ + "accessProfile", + "%61ccessProfile=%ff", + "accessProfile=", + "accessProfile=badProfile", + "accessProfile=operator&%61ccessProfile=operator", + "accessProfile=history&%61ccessProfile=history", + ] { + let claims = Some(caseworker_claims("case-management")); + let response = harness + .send( + Method::GET, + &format!("/v1/records/households?$top=1&{selector}"), + claims.clone(), + ) + .await; + assert_eq!(response.status(), StatusCode::FORBIDDEN, "{selector}"); + assert_eq!(body_json(response).await["code"], "profile.not-authorized"); + + let response = send_to( + &snapshots_app, + Method::GET, + &format!("/v1/records/assignments:snapshot?$top=1&{selector}"), + claims, + ) + .await; + assert_eq!(response.status(), StatusCode::NOT_FOUND, "{selector}"); + assert_eq!(body_json(response).await["code"], "resource.not-found"); + } + assert_eq!(harness.records.calls(), 0); + assert_eq!(snapshot_records.calls(), 0); + assert!(snapshots.requests.lock().unwrap().is_empty()); +} + +#[tokio::test] +async fn retired_record_paging_has_a_fixed_location_after_admission() { + let harness = Harness::new(true); + for accept in [Some("application/json"), Some("application/ld+json")] { + for query in [ + "$top=1", + "limit=1&%24top=private-canary", + "%24skiptoken=private-canary&cursor=opaque", + "$skiptoken=one&$skiptoken=two", + ] { + let response = harness + .send_with_accept( + Method::GET, + &format!("/v1/records/cases?{query}"), + Some(public_claims()), + accept, + ) + .await; + assert_eq!(response.status(), StatusCode::BAD_REQUEST, "{query}"); + let problem = body_json(response).await; + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + assert!(!problem.to_string().contains("private-canary")); + } + } + assert_eq!(harness.records.calls(), 0); +} + #[tokio::test] async fn snapshot_rejects_ambiguous_time_and_cursor_overrides_before_history_io() { let (app, records, snapshots) = snapshot_harness(SNAPSHOT_PROJECT, &[]); @@ -922,11 +1095,11 @@ async fn snapshot_rejects_ambiguous_time_and_cursor_overrides_before_history_io( "snapshot=forged-canary", "snapshot=a&snapshot=b", "validAt=2026-06-05&validAt=2026-07-05", - "$skiptoken=canary&validAt=2026-06-05", - "$skiptoken=canary&snapshot=canary", + "cursor=canary&validAt=2026-06-05", + "cursor=canary&snapshot=canary", "$expand=household", "$select=hidden", - "$top=101", + "limit=101", ] { let response = send_to( &app, @@ -1047,7 +1220,7 @@ async fn closed_query_grammar_reaches_record_service_as_compiled_query() { let accepted = harness .send( Method::GET, - "/v1/records/cases?$select=label&$filter=startswith(label,'Visible')&$orderby=label&$top=25", + "/v1/records/cases?$select=label&$filter=startswith(label,'Visible')&$orderby=label&limit=25", Some(public_claims()), ) .await; @@ -1115,7 +1288,7 @@ async fn bbox_reaches_record_service_only_with_declared_spatial_grant() { let accepted = harness .send_with_accept( Method::GET, - "/v1/records/sites?bbox=100,10,101,11&$filter=code%20eq%20'SITE-A'&$top=25", + "/v1/records/sites?bbox=100,10,101,11&$filter=code%20eq%20'SITE-A'&limit=25", Some(public_claims()), Some("application/geo+json"), ) @@ -1690,7 +1863,7 @@ async fn relationship_route_uses_path_grant_not_direct_target_rights() { .send( Method::GET, &format!( - "/v1/records/households/{root}/people?accessProfile=operator&$select=personCode&$filter=startswith(personCode,'P-')&$orderby=personCode&$top=5&$count=true" + "/v1/records/households/{root}/people?accessProfile=operator&$select=personCode&$filter=startswith(personCode,'P-')&$orderby=personCode&limit=5&$count=true" ), Some(caseworker_claims("case-management")), ) @@ -2047,7 +2220,7 @@ async fn derived_fields_are_discoverable_as_read_only_response_properties() { async fn continuation_requests_refuse_query_overrides_before_record_io() { let harness = Harness::new(true); let before = harness.records.calls(); - for parameter in ["cursor", "$skiptoken"] { + for parameter in ["cursor", "%63ursor"] { let response = harness .send( Method::GET, @@ -2058,7 +2231,7 @@ async fn continuation_requests_refuse_query_overrides_before_record_io() { assert_eq!(response.status(), StatusCode::BAD_REQUEST); let problem = body_json(response).await; assert_eq!(problem["code"], "query.invalid"); - assert_eq!(problem["fieldPath"], parameter); + assert_eq!(problem["fieldPath"], "cursor"); } assert_eq!(harness.records.calls(), before); } @@ -2118,9 +2291,9 @@ fn retired_proposal_history_query_name_is_not_advertised() { } #[tokio::test] -async fn record_list_accepts_limit_and_top_and_refuses_ambiguous_sizes() { +async fn record_list_accepts_limit_and_refuses_ambiguous_sizes() { let harness = Harness::new(true); - for query in ["limit=0", "$top=1&limit=1"] { + for query in ["limit=0", "limit=1&%6cimit=1"] { let response = harness .send( Method::GET, @@ -2135,7 +2308,7 @@ async fn record_list_accepts_limit_and_top_and_refuses_ambiguous_sizes() { } assert_eq!(harness.records.calls(), 0); - for query in ["limit=1", "$top=1"] { + for query in ["limit=1", "%6cimit=1"] { let accepted = harness .send( Method::GET, @@ -2149,7 +2322,7 @@ async fn record_list_accepts_limit_and_top_and_refuses_ambiguous_sizes() { } #[tokio::test] -async fn count_requires_compiled_permission_and_top_is_bounded() { +async fn count_requires_compiled_permission_and_limit_is_bounded() { let harness = Harness::new(true); let public_count = harness .send( @@ -2164,7 +2337,7 @@ async fn count_requires_compiled_permission_and_top_is_bounded() { let caseworker_count = harness .send( Method::GET, - "/v1/records/cases?accessProfile=caseworker&$count=true&$top=1", + "/v1/records/cases?accessProfile=caseworker&$count=true&limit=1", Some(caseworker_claims("case-management")), ) .await; @@ -2315,7 +2488,7 @@ async fn a_list_that_satisfies_an_alternative_runs() { async fn a_list_that_pins_no_alternative_is_refused_before_any_query() { for query in [ "", - "&$top=5", + "&limit=5", "&$filter=startswith(label,'Vis')", "&$filter=label%20ne%20'x'", "&$filter=label%20eq%20null", @@ -2450,7 +2623,7 @@ async fn continuation_keeps_the_criteria_and_cannot_drop_them() { let first_query = request_query(&first_request); let token = required_filters_cursor(first_query); - for parameter in ["cursor", "$skiptoken"] { + for parameter in ["cursor", "%63ursor"] { let next = required_filters_list(&harness, &format!("&{parameter}={token}")).await; assert_eq!(next.status(), StatusCode::OK, "{parameter}"); let next_request = harness.records.last_request(); @@ -2459,6 +2632,14 @@ async fn continuation_keeps_the_criteria_and_cannot_drop_them() { assert_eq!(single_filter_predicate(next_query).field_id, "label"); } + let calls = harness.records.calls(); + let retired = required_filters_list(&harness, &format!("&%24skiptoken={token}")).await; + assert_eq!(retired.status(), StatusCode::BAD_REQUEST); + let problem = body_json(retired).await; + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + assert_eq!(harness.records.calls(), calls); + // The same cursor without its filter no longer matches its own binding. let mut stripped = serde_json::to_value(&first_query.cursor_query).expect("query serializes"); stripped["filter"] = Value::Null; @@ -2478,7 +2659,7 @@ async fn continuation_keeps_the_criteria_and_cannot_drop_them() { let _ = &mut payload; let forged = codec.encode(&payload).expect("cursor encodes"); let calls = harness.records.calls(); - let refused = required_filters_list(&harness, &format!("&$skiptoken={forged}")).await; + let refused = required_filters_list(&harness, &format!("&cursor={forged}")).await; assert_eq!(refused.status(), StatusCode::BAD_REQUEST); assert_eq!(body_json(refused).await["code"], "query.cursor-invalid"); assert_eq!(harness.records.calls(), calls); @@ -2572,8 +2753,8 @@ fn strict_query_debug_output_redacts_identifiers_literals_and_tokens() { assert!(!rendered.contains("secret")); assert!(!rendered.contains("literal-canary")); - let token_query = strict_query::parse_read_query([("$skiptoken", "cursor-canary")]) - .expect("cursor query parses"); + let token_query = + strict_query::parse_read_query([("cursor", "cursor-canary")]).expect("cursor query parses"); assert!(!format!("{token_query:?}").contains("cursor-canary")); } @@ -3293,7 +3474,7 @@ async fn projection_can_only_reduce_the_authorized_profile() { let caller_limit = harness .send( Method::GET, - "/v1/records/cases?$top=101", + "/v1/records/cases?limit=101", Some(public_claims()), ) .await; @@ -3917,7 +4098,7 @@ async fn real_router_serves_only_authorized_explicit_revision_routes() { let malformed_query = send_to( &app, Method::GET, - &format!("{list_path}?accessProfile=caseworker&$top"), + &format!("{list_path}?accessProfile=caseworker&limit"), Some(caseworker_claims("case-management")), ) .await; @@ -4007,7 +4188,7 @@ async fn real_router_serves_only_authorized_explicit_revision_routes() { let audit_failure = send_to( &app, Method::GET, - &format!("{list_path}?$top=2"), + &format!("{list_path}?limit=2"), Some(caseworker_claims("case-management")), ) .await; @@ -4754,7 +4935,7 @@ async fn workspace_temporal_capabilities_and_no_store_cover_success_and_refusal( "/v1/records/public-records/00000000-0000-4000-8000-000000000001", "/v1/registry?accessProfile=unknown", "/v1/schemas/protected-ledger", - "/v1/records/public-records?$top=0", + "/v1/records/public-records?limit=0", "/missing", ] { let response = harness.send(Method::GET, uri, Some(public_claims())).await; @@ -4846,6 +5027,70 @@ async fn missing_row_boundary_claim_refuses_list_current_and_as_of_reads() { } } +#[tokio::test] +async fn retired_temporal_page_names_do_not_bypass_row_boundary_admission() { + let harness = Harness::from_project(TEMPORAL_ROW_BOUNDARY_PROJECT, true); + for uri in [ + "/v1/records/licences:current?%24top=1", + "/v1/records/licences:as-of?asOf=2026-06-05&%24skiptoken=opaque", + ] { + let response = harness + .send(Method::GET, uri, Some(claims_without_jurisdictions())) + .await; + assert_eq!(response.status(), StatusCode::FORBIDDEN, "{uri}"); + assert_eq!(body_json(response).await["code"], "profile.not-authorized"); + let response = harness + .send( + Method::GET, + uri, + Some(caseworker_claims_with_direct("case-management", [])), + ) + .await; + assert_eq!(response.status(), StatusCode::BAD_REQUEST, "{uri}"); + let problem = body_json(response).await; + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + } + assert_eq!(harness.records.calls(), 0); +} + +#[tokio::test] +async fn retired_related_page_names_follow_path_admission_and_root_format_checks() { + let harness = Harness::from_project(LOOKUP_PATH_PROJECT, true); + let root = "00000000-0000-4000-8000-000000000001"; + for (root_id, path, profile, expected) in [ + (root, "people", "operator", StatusCode::BAD_REQUEST), + (root, "people", "viewer", StatusCode::FORBIDDEN), + (root, "unknown-path", "operator", StatusCode::NOT_FOUND), + ("bad-root", "people", "operator", StatusCode::NOT_FOUND), + ] { + let response = harness + .send( + Method::GET, + &format!( + "/v1/records/households/{root_id}/{path}?accessProfile={profile}&%24top=1" + ), + Some(caseworker_claims_with_direct( + "case-management", + [( + "household_id", + VerifiedClaimValue::direct_string(root).unwrap(), + )], + )), + ) + .await; + assert_eq!(response.status(), expected, "{root_id}/{path} {profile}"); + let problem = body_json(response).await; + if expected == StatusCode::BAD_REQUEST { + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "query"); + } else { + assert_ne!(problem["code"], "query.invalid"); + } + } + assert_eq!(harness.records.calls(), 0); +} + /// Every public refusal names a problem type on the shared Registry Stack /// identifier host, so an adopter can resolve the type it was handed. A dot in /// the code separates path segments under the product prefix. diff --git a/crates/registry-breg/tests/postgres_access_log.rs b/crates/registry-breg/tests/postgres_access_log.rs index c41c65470b..df5b6e5065 100644 --- a/crates/registry-breg/tests/postgres_access_log.rs +++ b/crates/registry-breg/tests/postgres_access_log.rs @@ -494,7 +494,7 @@ async fn subject_access_log_requires_current_record_ownership_and_records_each_r &app, &agency, Method::GET, - "/v1/records/entries?$top=1", + "/v1/records/entries?limit=1", None, None ) @@ -551,7 +551,7 @@ async fn subject_access_log_requires_current_record_ownership_and_records_each_r &app, &agency, Method::GET, - "/v1/records/entries?$top=2", + "/v1/records/entries?limit=2", None, None ) @@ -1265,7 +1265,7 @@ async fn head_on_record_reads_is_refused_without_a_journaled_read() { let agency = token(&idp, "agency", "officer"); for uri in [ format!("/v1/records/entries/{RECORD_A}"), - "/v1/records/entries?$top=1".to_owned(), + "/v1/records/entries?limit=1".to_owned(), ] { assert_head_is_refused_like_an_unaccepted_method(&db, &app, &agency, &uri).await; } @@ -1405,7 +1405,7 @@ async fn a_request_without_its_required_access_reason_is_refused_before_any_reco &app, &agency, Method::GET, - "/v1/records/entries?accessProfile=reasoned&$top=1", + "/v1/records/entries?accessProfile=reasoned&limit=1", None, None, ) @@ -1429,6 +1429,46 @@ async fn a_request_without_its_required_access_reason_is_refused_before_any_reco db.cleanup().await; } +#[tokio::test] +async fn retired_exact_and_lookup_paging_waits_for_required_attribution() { + let (db, app, idp) = setup_registry(compiled_with_access_reason()).await; + let agency = token(&idp, "agency", "officer"); + let reason = reason_header("Review the synthetic record"); + for (method, route, body) in [ + (Method::GET, format!("/v1/records/entries/{RECORD_A}"), None), + ( + Method::POST, + "/v1/records/entries:lookup".to_owned(), + Some(json!({"selector":"by-subject","values":{"subject":SUBJECT}})), + ), + ] { + for (header, code) in [ + (None, "request.access-reason-required"), + (Some("not base64url!"), "request.access-reason-required"), + (Some(reason.as_str()), "query.invalid"), + ] { + let (status, problem) = send_reasoned( + &app, + &agency, + method.clone(), + &format!("{route}?accessProfile=reasoned&%24skiptoken=private-canary"), + body.clone(), + header, + ) + .await; + assert_eq!(status, StatusCode::BAD_REQUEST); + assert_eq!(problem["code"], code); + if code == "query.invalid" { + assert_eq!(problem["fieldPath"], "query"); + } + } + } + assert_eq!(access_log_rows(&db).await, 0); + drop(app); + drop(idp); + db.cleanup().await; +} + #[tokio::test] async fn an_invalid_access_reason_is_refused_like_a_missing_one() { let (db, app, idp) = setup_registry(compiled_with_access_reason()).await; @@ -1621,7 +1661,7 @@ async fn a_read_under_an_alerting_profile_emits_one_event_per_access_log_entry() &app, &agency, Method::GET, - "/v1/records/entries?accessProfile=reasoned&$top=2", + "/v1/records/entries?accessProfile=reasoned&limit=2", None, Some(&reason_header(reason)), ) @@ -1674,7 +1714,7 @@ async fn a_read_under_a_profile_the_hook_does_not_name_emits_none() { let agency = token(&idp, "agency", "officer"); for uri in [ format!("/v1/records/entries/{RECORD_A}"), - "/v1/records/entries?$top=2".to_owned(), + "/v1/records/entries?limit=2".to_owned(), ] { let (status, _) = send_reasoned(&app, &agency, Method::GET, &uri, None, None).await; assert_eq!(status, StatusCode::OK); diff --git a/crates/registry-breg/tests/postgres_consent_access.rs b/crates/registry-breg/tests/postgres_consent_access.rs index 521953d1bd..281217c34d 100644 --- a/crates/registry-breg/tests/postgres_consent_access.rs +++ b/crates/registry-breg/tests/postgres_consent_access.rs @@ -469,7 +469,7 @@ async fn real_postgres_consent_gates_every_read_operation_on_id_and_on_reference assert_eq!(ids(&page), expected, "{route}"); let first = h .get( - &format!("/v1/records/{route}?accessProfile={SCOPE}&$top=1&$count=true"), + &format!("/v1/records/{route}?accessProfile={SCOPE}&limit=1&$count=true"), &wfp, ) .await; @@ -629,7 +629,7 @@ async fn real_postgres_consent_gates_every_read_operation_on_id_and_on_reference for (route, cursor) in &cursors { let page = h .get( - &format!("/v1/records/{route}?accessProfile={SCOPE}&$skiptoken={cursor}"), + &format!("/v1/records/{route}?accessProfile={SCOPE}&cursor={cursor}"), &wfp, ) .await; @@ -950,7 +950,7 @@ async fn real_postgres_consent_matches_recipient_sets_purpose_and_scope_exactly( let alpha_give = h.decide(decision(&alpha_only, "ngo-alpha", "given")).await; let feed = h .get( - "/v1/records/consent-decisions?accessProfile=recipient-feed&$top=100", + "/v1/records/consent-decisions?accessProfile=recipient-feed&limit=100", &h.feed(WFP_CLIENT), ) .await; @@ -998,7 +998,7 @@ async fn real_postgres_consent_matches_recipient_sets_purpose_and_scope_exactly( ); let alpha_feed = h .get( - "/v1/records/consent-decisions?accessProfile=recipient-feed&$top=100", + "/v1/records/consent-decisions?accessProfile=recipient-feed&limit=100", &h.feed(ALPHA_CLIENT), ) .await; @@ -1019,7 +1019,7 @@ async fn real_postgres_consent_matches_recipient_sets_purpose_and_scope_exactly( let (status, body) = send( &h.app, Method::GET, - "/v1/records/consent-decisions?accessProfile=recipient-feed&$top=100", + "/v1/records/consent-decisions?accessProfile=recipient-feed&limit=100", Value::Null, None, &forged_feed, @@ -1105,7 +1105,7 @@ async fn real_postgres_consent_refusals_reach_no_recipient_through_an_authored_s let beta = h.feed(BETA_CLIENT); let feed = h .get( - "/v1/records/consent-decisions?accessProfile=recipient-feed&$top=100", + "/v1/records/consent-decisions?accessProfile=recipient-feed&limit=100", &beta, ) .await; @@ -1360,7 +1360,7 @@ async fn real_postgres_consent_probe_runs_once_per_list_and_count() { let wfp = h.reader(WFP_CLIENT, PURPOSE); let page = h .get( - &format!("/v1/records/persons?accessProfile={SCOPE}&$top=100&$count=true"), + &format!("/v1/records/persons?accessProfile={SCOPE}&limit=100&$count=true"), &wfp, ) .await; @@ -1585,7 +1585,7 @@ async fn real_postgres_consent_gated_list_latency_budget() { admin_task.abort(); let token = h.reader(WFP_CLIENT, PURPOSE); - let uri = format!("/v1/records/persons?accessProfile={SCOPE}&$top=100&$count=true"); + let uri = format!("/v1/records/persons?accessProfile={SCOPE}&limit=100&$count=true"); h.get(&uri, &token).await; let mut samples = Vec::with_capacity(SAMPLES); for _ in 0..SAMPLES { diff --git a/crates/registry-breg/tests/postgres_historical.rs b/crates/registry-breg/tests/postgres_historical.rs index d6363ac379..969b693eb3 100644 --- a/crates/registry-breg/tests/postgres_historical.rs +++ b/crates/registry-breg/tests/postgres_historical.rs @@ -124,7 +124,7 @@ async fn snapshot_http_reconstructs_before_filters_and_keeps_pages_pinned() { let vocabulary_search = send( &app, &format!( - "/v1/records/memberships:snapshot?snapshot={}&validAt=2026-06-05&$select=jurisdiction&$filter=contains(jurisdiction,'ONE-A')&$top=1", + "/v1/records/memberships:snapshot?snapshot={}&validAt=2026-06-05&$select=jurisdiction&$filter=contains(jurisdiction,'ONE-A')&limit=1", snapshot_ref(OLD_REFERENCE_UUID) ), Some(history_claims(["zone-a"])), @@ -207,7 +207,7 @@ async fn snapshot_http_reconstructs_before_filters_and_keeps_pages_pinned() { let first_page = send( &app, - "/v1/records/memberships:snapshot?validAt=2026-06-05&$select=householdCode&$orderby=householdCode&$top=1&$count=true", + "/v1/records/memberships:snapshot?validAt=2026-06-05&$select=householdCode&$orderby=householdCode&limit=1&$count=true", Some(history_claims(["zone-a"])), ) .await; @@ -225,7 +225,7 @@ async fn snapshot_http_reconstructs_before_filters_and_keeps_pages_pinned() { let second_page = send( &app, - &format!("/v1/records/memberships:snapshot?$skiptoken={cursor}"), + &format!("/v1/records/memberships:snapshot?cursor={cursor}"), Some(history_claims(["zone-a"])), ) .await; @@ -483,7 +483,7 @@ async fn snapshot_count_filter_probe_stays_bounded_and_pinned() { let started = Instant::now(); let first_page = send( &app, - "/v1/records/memberships:snapshot?$select=householdCode&$filter=householdCode%20eq%20'probe-even'&$orderby=householdCode&$top=100&$count=true", + "/v1/records/memberships:snapshot?$select=householdCode&$filter=householdCode%20eq%20'probe-even'&$orderby=householdCode&limit=100&$count=true", Some(history_claims(["zone-a"])), ) .await; @@ -504,7 +504,7 @@ async fn snapshot_count_filter_probe_stays_bounded_and_pinned() { let second_page = send( &app, - &format!("/v1/records/memberships:snapshot?$skiptoken={cursor}"), + &format!("/v1/records/memberships:snapshot?cursor={cursor}"), Some(history_claims(["zone-a"])), ) .await; diff --git a/crates/registry-breg/tests/postgres_list_page_plans.rs b/crates/registry-breg/tests/postgres_list_page_plans.rs index dade7fa7b1..0ce5e9a90a 100644 --- a/crates/registry-breg/tests/postgres_list_page_plans.rs +++ b/crates/registry-breg/tests/postgres_list_page_plans.rs @@ -200,7 +200,7 @@ impl Fixture { let (status, mut body) = send( &self.app, &format!( - "/v1/records/assets?accessProfile=reader&$filter=kind%20eq%20'kind-1'{order}&$top={PAGE}" + "/v1/records/assets?accessProfile=reader&$filter=kind%20eq%20'kind-1'{order}&limit={PAGE}" ), ) .await; @@ -217,7 +217,7 @@ impl Fixture { self.take_plan(); let (status, next) = send( &self.app, - &format!("/v1/records/assets?accessProfile=reader&$skiptoken={cursor}"), + &format!("/v1/records/assets?accessProfile=reader&cursor={cursor}"), ) .await; assert_eq!(status, StatusCode::OK, "{next}"); @@ -230,7 +230,7 @@ impl Fixture { while let Some(cursor) = body["pageInfo"]["nextCursor"].as_str().map(str::to_owned) { let (status, next) = send( &self.app, - &format!("/v1/records/assets?accessProfile=reader&$skiptoken={cursor}"), + &format!("/v1/records/assets?accessProfile=reader&cursor={cursor}"), ) .await; assert_eq!(status, StatusCode::OK, "{next}"); diff --git a/crates/registry-breg/tests/postgres_membership_access.rs b/crates/registry-breg/tests/postgres_membership_access.rs index 23b65d599a..84be848426 100644 --- a/crates/registry-breg/tests/postgres_membership_access.rs +++ b/crates/registry-breg/tests/postgres_membership_access.rs @@ -221,7 +221,7 @@ async fn real_postgres_membership_reads_recheck_live_membership_and_hide_process let (_, _, page) = send( &app, Method::GET, - &format!("/v1/records/{route}?accessProfile=member&$top=1&$count=true"), + &format!("/v1/records/{route}?accessProfile=member&limit=1&$count=true"), Value::Null, None, &member, @@ -232,7 +232,7 @@ async fn real_postgres_membership_reads_recheck_live_membership_and_hide_process let (_, _, snapshot) = send( &app, Method::GET, - &format!("/v1/records/{route}:snapshot?accessProfile=member&$count=true&$top=1"), + &format!("/v1/records/{route}:snapshot?accessProfile=member&$count=true&limit=1"), Value::Null, None, &member, @@ -353,11 +353,9 @@ async fn real_postgres_membership_reads_recheck_live_membership_and_hide_process ); for uri in [ format!("/v1/records/{route}?accessProfile=member&$count=true"), - format!("/v1/records/{route}?accessProfile=member&$skiptoken={cursor}"), + format!("/v1/records/{route}?accessProfile=member&cursor={cursor}"), format!("/v1/records/{route}:snapshot?accessProfile=member&$count=true"), - format!( - "/v1/records/{route}:snapshot?accessProfile=member&$skiptoken={snapshot_cursor}" - ), + format!("/v1/records/{route}:snapshot?accessProfile=member&cursor={snapshot_cursor}"), ] { let (status, _, body) = send(&app, Method::GET, &uri, Value::Null, None, &member).await; assert_eq!(status, StatusCode::OK, "{body}"); diff --git a/crates/registry-breg/tests/postgres_mutation.rs b/crates/registry-breg/tests/postgres_mutation.rs index 1c860ce21e..b144d4dc63 100644 --- a/crates/registry-breg/tests/postgres_mutation.rs +++ b/crates/registry-breg/tests/postgres_mutation.rs @@ -3743,8 +3743,8 @@ async fn record_and_query_refusals_name_only_fixed_members_and_admitted_fields() assert_identical_problems(&filter_unknown, &filter_withheld); let filter_syntax = problem(query("/v1/records/widgets?$filter=label%20eq").await).await; assert_query_invalid_at(&filter_syntax, Some("$filter")); - let top = problem(query("/v1/records/widgets?$top=0").await).await; - assert_query_invalid_at(&top, Some("$top")); + let limit = problem(query("/v1/records/widgets?limit=0").await).await; + assert_query_invalid_at(&limit, Some("limit")); let orderby = problem(query("/v1/records/widgets?$orderby=secret").await).await; assert_query_invalid_at(&orderby, Some("$orderby")); let invented = problem(query("/v1/records/widgets?noSuchParameter=1").await).await; diff --git a/crates/registry-breg/tests/postgres_read.rs b/crates/registry-breg/tests/postgres_read.rs index cf03dfac4b..eb3fb019a5 100644 --- a/crates/registry-breg/tests/postgres_read.rs +++ b/crates/registry-breg/tests/postgres_read.rs @@ -135,7 +135,7 @@ async fn benchmark_audited_record_read(workload: ReadBenchmark) { ReadBenchmark::ListCountContinuation => { let first = send( &app, - "/v1/records/widgets?$select=label&$filter=jurisdiction%20in%20('zone-b','zone-a')&$orderby=ordinal&$top=100&$count=true", + "/v1/records/widgets?$select=label&$filter=jurisdiction%20in%20('zone-b','zone-a')&$orderby=ordinal&limit=100&$count=true", Some(read_claims(["zone-a"])), ) .await; @@ -177,7 +177,7 @@ async fn benchmark_audited_record_read(workload: ReadBenchmark) { }); ( "audited_record_list_count_continuation", - format!("/v1/records/widgets?$skiptoken={cursor}"), + format!("/v1/records/widgets?cursor={cursor}"), serde_json::to_vec(&expected).expect("expected list response serializes"), ) } @@ -429,7 +429,7 @@ async fn real_postgres_read_is_authorized_bounded_minimized_and_audit_gated() { let repeated_in = send( &app, - "/v1/records/widgets?$select=label&$filter=jurisdiction%20in%20('zone-b','zone-a')&$top=2", + "/v1/records/widgets?$select=label&$filter=jurisdiction%20in%20('zone-b','zone-a')&limit=2", Some(read_claims(["zone-a"])), ) .await; @@ -483,7 +483,7 @@ async fn real_postgres_read_is_authorized_bounded_minimized_and_audit_gated() { } let vocabulary_search = send( &app, - "/v1/records/widgets?$select=jurisdiction&$filter=contains(jurisdiction,'ONE-A')&$top=1", + "/v1/records/widgets?$select=jurisdiction&$filter=contains(jurisdiction,'ONE-A')&limit=1", Some(read_claims(["zone-a"])), ) .await; @@ -522,7 +522,7 @@ async fn real_postgres_read_is_authorized_bounded_minimized_and_audit_gated() { let continuation = send( &app, - &format!("/v1/records/widgets?$skiptoken={next_cursor}"), + &format!("/v1/records/widgets?cursor={next_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -550,7 +550,7 @@ async fn real_postgres_read_is_authorized_bounded_minimized_and_audit_gated() { let tampered = String::from_utf8(tampered).expect("cursor remains UTF-8"); let refused_cursor = send( &app, - &format!("/v1/records/widgets?$skiptoken={tampered}"), + &format!("/v1/records/widgets?cursor={tampered}"), Some(read_claims(["zone-a"])), ) .await; @@ -793,9 +793,48 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { assert!(current["items"][0]["domainData"].get("valid-to").is_none()); assert!(!current.to_string().contains(TEMPORAL_OTHER_BOUNDARY_RECORD)); + let as_of_route = "/v1/records/assignments:as-of"; + let at = "2020-05-31T23:59:59Z"; + let claims = Some(read_claims(["zone-a", "zone-b"])); + let first = send( + &app, + &format!( + "{as_of_route}?accessProfile=operator&asOf={at}&$select=label&$orderby=label&limit=1" + ), + claims.clone(), + ) + .await; + assert_eq!(first.status(), StatusCode::OK); + let first = body_json(first).await; + assert_eq!(first["meta"]["asOf"], at); + let cursor = first["pageInfo"]["nextCursor"].as_str().unwrap(); + let continuation = format!("{as_of_route}?accessProfile=operator&cursor={cursor}"); + let second = send(&app, &continuation, claims.clone()).await; + assert_eq!(second.status(), StatusCode::OK); + let second = body_json(second).await; + assert_eq!(second["meta"]["asOf"], at); + assert!(second["pageInfo"]["nextCursor"].is_null()); + assert_eq!( + second["items"][0]["domainData"], + json!({"label": "lease-b"}) + ); + assert_ids(first, &[TEMPORAL_OLD_RECORD]); + assert_ids(second, &[TEMPORAL_OTHER_BOUNDARY_RECORD]); + + let override_time = send( + &app, + &format!("{continuation}&asOf=2020-06-01T00:00:00Z"), + claims, + ) + .await; + assert_eq!(override_time.status(), StatusCode::BAD_REQUEST); + let problem = body_json(override_time).await; + assert_eq!(problem["code"], "query.invalid"); + assert_eq!(problem["fieldPath"], "cursor"); + let sorted_first = send( &app, - "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&$top=2", + "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&limit=2", Some(read_claims(["zone-a"])), ) .await; @@ -811,7 +850,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { .to_owned(); let sorted_second = send( &app, - &format!("/v1/records/widgets?$skiptoken={sorted_second_cursor}"), + &format!("/v1/records/widgets?cursor={sorted_second_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -828,7 +867,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { .to_owned(); let sorted_third = send( &app, - &format!("/v1/records/widgets?$skiptoken={sorted_third_cursor}"), + &format!("/v1/records/widgets?cursor={sorted_third_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -839,7 +878,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { let counted_first = send( &app, - "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&$top=2&$count=true", + "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&limit=2&$count=true", Some(read_claims(["zone-a"])), ) .await; @@ -859,7 +898,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { .to_owned(); let counted_second = send( &app, - &format!("/v1/records/widgets?$skiptoken={counted_cursor}"), + &format!("/v1/records/widgets?cursor={counted_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -883,29 +922,29 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { let replay_cursor = next_cursor( &app, - "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&$top=2", + "/v1/records/widgets?$select=label,rank&$filter=startswith(label,'sort-key-')&$orderby=rank&limit=2", Some(read_claims(["zone-a"])), ) .await; for (uri, claims) in [ ( - format!("/v1/records/widgets?$skiptoken={replay_cursor}"), + format!("/v1/records/widgets?cursor={replay_cursor}"), read_claims_with(PRINCIPAL_CANARY, "audit-review", ["zone-a"]), ), ( - format!("/v1/records/widgets?$skiptoken={replay_cursor}"), + format!("/v1/records/widgets?cursor={replay_cursor}"), read_claims_with("other-principal-value", "case-management", ["zone-a"]), ), ( - format!("/v1/records/widgets?$skiptoken={replay_cursor}"), + format!("/v1/records/widgets?cursor={replay_cursor}"), read_claims_with(PRINCIPAL_CANARY, "case-management", ["zone-b"]), ), ( - format!("/v1/records/widgets?accessProfile=auditor&$skiptoken={replay_cursor}"), + format!("/v1/records/widgets?accessProfile=auditor&cursor={replay_cursor}"), read_claims(["zone-a"]), ), ( - format!("/v1/records/assignments?$skiptoken={replay_cursor}"), + format!("/v1/records/assignments?cursor={replay_cursor}"), read_claims(["zone-a"]), ), ] { @@ -928,14 +967,14 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { ); assert_cursor_invalid( &package_changed_app, - &format!("/v1/records/widgets?$skiptoken={replay_cursor}"), + &format!("/v1/records/widgets?cursor={replay_cursor}"), Some(read_claims(["zone-a"])), ) .await; let projection_cursor = next_cursor( &app, - "/v1/records/widgets?$select=label,amount&$filter=startswith(label,'label-')&$orderby=ordinal&$top=2", + "/v1/records/widgets?$select=label,amount&$filter=startswith(label,'label-')&$orderby=ordinal&limit=2", Some(read_claims(["zone-a"])), ) .await; @@ -952,7 +991,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { ); assert_cursor_invalid( &projection_changed_app, - &format!("/v1/records/widgets?$skiptoken={projection_cursor}"), + &format!("/v1/records/widgets?cursor={projection_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -974,7 +1013,7 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { ); assert_cursor_invalid( &changed_app, - &format!("/v1/records/widgets?$skiptoken={replay_cursor}"), + &format!("/v1/records/widgets?cursor={replay_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -993,13 +1032,13 @@ async fn real_postgres_temporal_keyset_and_cursor_binding_edges_are_enforced() { ); let expired_cursor = next_cursor( &expiring_app, - "/v1/records/widgets?$select=label&$orderby=ordinal&$top=1", + "/v1/records/widgets?$select=label&$orderby=ordinal&limit=1", Some(read_claims(["zone-a"])), ) .await; assert_cursor_invalid( &expiring_app, - &format!("/v1/records/widgets?$skiptoken={expired_cursor}"), + &format!("/v1/records/widgets?cursor={expired_cursor}"), Some(read_claims(["zone-a"])), ) .await; @@ -1506,6 +1545,19 @@ async fn seed_records( ] { insert_assignment_row(transaction.transaction_for_test(), registry, row).await; } + } else { + insert_assignment_row( + transaction.transaction_for_test(), + registry, + AssignmentRow { + record_id: TEMPORAL_OTHER_BOUNDARY_RECORD, + jurisdiction, + label: "lease-b", + valid_from: "2020-01-01T00:00:00Z", + valid_to: None, + }, + ) + .await; } transaction .commit() diff --git a/crates/registry-breg/tests/postgres_read_dependencies.rs b/crates/registry-breg/tests/postgres_read_dependencies.rs index 68e440203e..a4ec61f56e 100644 --- a/crates/registry-breg/tests/postgres_read_dependencies.rs +++ b/crates/registry-breg/tests/postgres_read_dependencies.rs @@ -259,7 +259,7 @@ async fn exercise_read_dependencies(case: &str, invalid_population: bool, active // still reach their derived relation, including its cardinality guard. for query in [ "/v1/records/entries?$select=code&$filter=not%20(population%20lt%2032%20or%20population%20gt%2032)&$count=true", - "/v1/records/entries?$select=code&$orderby=population&$top=1", + "/v1/records/entries?$select=code&$orderby=population&limit=1", ] { let (status, body) = send(&app, query, false, "visible").await; if invalid_population { @@ -279,7 +279,7 @@ async fn exercise_combined_dependencies(app: &axum::Router, plans: &Mutex