IF Commons GitHub

approvalRequest

concept

A request for a person to approve one action of an agent, bound to a hash of its arguments, usable once

Model identityAgent. Written in commons/data/models/identity-agent/mod.ts:184. Identified by approvalRequestId.

Governance: attributes

actionKeytextrequired

The permission the action needs

Becomes the column action_key of approval_request.

Written at commons/data/models/identity-agent/mod.ts:188

approvalRequestIdidentifierrequired

What identifies the request, made by the application

Becomes the column approval_request_id of approval_request.

Written at commons/data/models/identity-agent/mod.ts:187

approverRulecode of approverRulerequired

Who may approve

Becomes the column approver_rule of approval_request.

Written at commons/data/models/identity-agent/mod.ts:194

argsHashtextrequired

A hash of the arguments, so that an approval is for exactly this call

Becomes the column args_hash of approval_request.

Written at commons/data/models/identity-agent/mod.ts:191

consumedAtinstantoptional

When it was used

Becomes the column consumed_at of approval_request.

Written at commons/data/models/identity-agent/mod.ts:200

decidedAtinstantoptional

When it was decided

Becomes the column decided_at of approval_request.

Written at commons/data/models/identity-agent/mod.ts:198

decisionReasontextoptional

Why it was decided so

Becomes the column decision_reason of approval_request.

Written at commons/data/models/identity-agent/mod.ts:199

expiresAtinstantrequired

When it stops being valid

Becomes the column expires_at of approval_request.

Written at commons/data/models/identity-agent/mod.ts:197

requestedAtinstantrequired

When it was asked for

Becomes the column requested_at of approval_request.

Written at commons/data/models/identity-agent/mod.ts:196

resourceIdtextoptional

The resource it is about

Becomes the column resource_id of approval_request.

Written at commons/data/models/identity-agent/mod.ts:190

resourceTypetextoptional

The kind of resource it is about

Becomes the column resource_type of approval_request.

Written at commons/data/models/identity-agent/mod.ts:189

riskLevelcode of riskLevelrequired

How risky it is

Becomes the column risk_level of approval_request.

Written at commons/data/models/identity-agent/mod.ts:193

statuscode of approvalStatusrequired

Where the request is

Becomes the column status of approval_request.

Annotations: quality.transitions={"allowed":{"pending":["approved","denied","expired","cancelled"],"approved":["consumed","expired","cancelled"],"denied":[],"expired":[],"cancelled":[],"cons...

Written at commons/data/models/identity-agent/mod.ts:195

summarytextrequired

What will happen, redacted

Becomes the column summary of approval_request.

Written at commons/data/models/identity-agent/mod.ts:192

Governance: relationships

agentone

The agent that asks To principal. Written at commons/data/models/identity-agent/mod.ts:205

approverRoleoptional

The role whose holders may approve, where the rule says so To accessRole. Written at commons/data/models/identity-agent/mod.ts:206

decidedByoptional

The person who decided To principal. Written at commons/data/models/identity-agent/mod.ts:207

runone

The run To agentRun. Written at commons/data/models/identity-agent/mod.ts:204

Logical: the table

Projects to the table approval_request with the primary key approval_request_id.

ColumnTypeNullRoleFrom
action_keytextfalseattributeapprovalRequest.actionKey
agent_principal_idtextfalsereferenceapprovalRequest.agent
approval_request_idtextfalseattributeapprovalRequest.approvalRequestId
approver_role_access_role_role_idtexttruereferenceapprovalRequest.approverRole
approver_ruletextfalseattributeapprovalRequest.approverRule
args_hashtextfalseattributeapprovalRequest.argsHash
consumed_attimestamptrueattributeapprovalRequest.consumedAt
decided_attimestamptrueattributeapprovalRequest.decidedAt
decided_by_principal_idtexttruereferenceapprovalRequest.decidedBy
decision_reasontexttrueattributeapprovalRequest.decisionReason
expires_attimestampfalseattributeapprovalRequest.expiresAt
requested_attimestampfalseattributeapprovalRequest.requestedAt
resource_idtexttrueattributeapprovalRequest.resourceId
resource_typetexttrueattributeapprovalRequest.resourceType
risk_leveltextfalseattributeapprovalRequest.riskLevel
run_agent_run_run_idtextfalsereferenceapprovalRequest.run
statustextfalseattributeapprovalRequest.status
summarytextfalseattributeapprovalRequest.summary

Physical: SQL

CREATE TABLE IF NOT EXISTS "approval_request" (
    "approval_request_id" VARCHAR NOT NULL PRIMARY KEY,
    "action_key" VARCHAR NOT NULL,
    "resource_type" VARCHAR,
    "resource_id" VARCHAR,
    "args_hash" VARCHAR NOT NULL,
    "summary" VARCHAR NOT NULL,
    "risk_level" VARCHAR NOT NULL,
    "approver_rule" VARCHAR NOT NULL,
    "status" VARCHAR NOT NULL,
    "requested_at" TIMESTAMPTZ NOT NULL,
    "expires_at" TIMESTAMPTZ NOT NULL,
    "decided_at" TIMESTAMPTZ,
    "decision_reason" VARCHAR,
    "consumed_at" TIMESTAMPTZ,
    "run_agent_run_run_id" VARCHAR NOT NULL,
    "agent_principal_id" VARCHAR NOT NULL,
    "approver_role_access_role_role_id" VARCHAR,
    "decided_by_principal_id" VARCHAR,
    CONSTRAINT "approval_request_run_agent_run_run_id_fk" FOREIGN KEY ("run_agent_run_run_id") REFERENCES "agent_run" ("run_id"),
    CONSTRAINT "approval_request_agent_principal_id_fk" FOREIGN KEY ("agent_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "approval_request_approver_role_access_role_role_id_fk" FOREIGN KEY ("approver_role_access_role_role_id") REFERENCES "access_role" ("role_id"),
    CONSTRAINT "approval_request_decided_by_principal_id_fk" FOREIGN KEY ("decided_by_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "approval_request_risk_level_ck" CHECK ("risk_level" IN ('low', 'medium', 'high', 'critical')),
    CONSTRAINT "approval_request_approver_rule_ck" CHECK ("approver_rule" IN ('owner', 'delegator', 'role_holder')),
    CONSTRAINT "approval_request_status_ck" CHECK ("status" IN ('pending', 'approved', 'denied', 'expired', 'cancelled', 'consumed'))
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { approvalRequest } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-agent.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { approvalRequest } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(approvalRequest).select((s) => ({ approvalRequestId: s.approvalRequest.approvalRequestId, actionKey: s.approvalRequest.actionKey })).run(runner);

Titles, headings, exports, tables, columns and requirements. Esc closes.