Unclassified

Action Completion Architecture

How actions flow from insight to execution in IntegrateWise.
Canonical reference for agents working on the HITL/approval/execution layer.
Last updated: April 12, 2026


Design Principle

The workspace (L1) is the daily driver. Users manage accounts, track tasks, run workflows here.
The cognitive layer (L2) accelerates what they're already doing — surfaces the right action at the right time.

Demo story: "Here are your at-risk accounts. Click. See why. Approve the action. Done."

The product is NOT "look what our AI can do." It IS "this is your workspace. The AI makes you faster."


The Action Pipeline

Signal → Think → Propose → Govern → HITL → Act → Learn → Repeat
StageServiceWhat happens
SignalThinkExternal data triggers a signal rule (e.g., health score < 60)
ThinkThinkSignal engine escalates → creates ProposedAction
ProposeThink (Queue)Queue handler persists action to actions table as pending_approval
GovernGovernPolicy check — can this action execute? RBAC, guardrails
HITLWorkflowHuman reviews in PendingApprovalsCard → ApprovalModal
ActActMandatory approval token + governance double-check → execute
LearnThinkOutcome feedback → decision_memory → pattern extraction

Two HITL Paths

1. Spine DB-based (primary — production flow)

  • GET /api/v1/cognitive/hitl/queue → reads actions table where status = 'pending_approval'
  • POST /api/v1/cognitive/hitl/queue → approve/deny, writes to actions, sends to ACT_QUEUE on approve, writes to decision_memory on deny
  • GET /api/v1/cognitive/hitl/history → reads approved/denied actions

2. Durable Object-based (signal-level, real-time)

  • POST /hitl/create → creates pending HITL record in DO storage
  • POST /hitl/resolve → if approved, generates approval_token, calls Act directly
  • GET /hitl/count → pending count for badges

Where Actions Surface (L1 Workspace)

Actions are NOT a separate feature — they're embedded in the views users already use daily.

SurfaceComponentData Source
CS Today ViewPendingApprovalsCard + ExecutionStatusCarduseL2Recommendations(CUSTOMER_SUCCESS)
CS At-Risk ViewPendingApprovalsCard + ApprovalModaluseL2Recommendations(CUSTOMER_SUCCESS, at-risk)
BizOps DashboardPendingApprovalsCarduseL2Recommendations(BIZOPS)
Twin Chat (inline)Quick Action Buttons + ActionDraftCardcognitive.twinAct() API
L2 Drawer (ActSurface)Approve/Reject buttonsgetHITLQueue() from l2-client
RevOps Pending ReviewPendingApprovalsCard + ApprovalModaluseL2Recommendations(REVOPS)
Finance Invoice ApprovalsDomain-specific approval UILocal state (needs wiring)
Admin Approval WorkflowsRBAC approval systemMock data (needs wiring)

Twin Chat — Action Trigger Flow

The Twin Chat is the demo closer. The flow:

  1. User asks Twin about an at-risk account (entity-scoped via entityId prop)
  2. Twin responds with grounded analysis from Entity 360
  3. Quick Action Buttons appear below the response (domain-contextual)
  4. User clicks "Schedule Health Call" → calls POST /api/v1/cognitive/twin/act with draft_only: true
  5. ActionDraftCard shows suggested summary + next steps
  6. User clicks "Approve & Execute" → calls with draft_only: false
  7. Goes through Govern check → Act execution → outcome learning

Domain Actions

DomainAction KeyLabelDescription
CSschedule_health_callSchedule Health CallBook check-in with primary stakeholder
CSdraft_retention_emailDraft Retention EmailAI-drafted email from risk signals
CSescalate_to_leadershipEscalate to LeadershipFlag for executive attention
BizOpscreate_taskCreate TaskTurn insight into actionable task
BizOpstrigger_workflowTrigger WorkflowStart automated workflow
BizOpssend_payment_reminderSend Payment ReminderDraft payment follow-up

Frontend Component Inventory

Reusable Components (apps/web/src/components/l2/approvals/)

ComponentFilePurpose
PendingApprovalsCardpending-approvals-card.tsxCard queue of pending approvals. Accepts approvals prop (PendingApproval[]).
ApprovalModalapproval-modal.tsxFull-screen approval view with evidence, urgency, confidence, entity info.
ExecutionStatusCardexecution-status-card.tsxRunning/completed/failed execution tracker with live timer.
ActionBaraction-bar.tsxInline action card with policy requirements and risk level.
approvalsApiapprovals-api.tsTyped API client for HITL queue. All decisions route through Workflow.

Hooks

HookFilePurpose
useL2Recommendationshooks/use-l2.tsFetches pending recommendations (30s stale).
useL2Decidehooks/use-l2.tsMutation: approve/reject, invalidates queries.
useHITLQueuehooks/use-api.tsPolls HITL queue every 15s.
useHITLActionhooks/use-api.tsMutation for HITL approve/deny.

API Client Methods

MethodFileEndpointPurpose
cognitive.twinAct()lib/api-client.tsPOST /api/v1/cognitive/twin/actDraft or execute action from Twin.
cognitive.hitlQueue()lib/api-client.tsGET /api/v1/cognitive/hitl/queueFetch pending proposals.
cognitive.hitlAction()lib/api-client.tsPOST /api/v1/cognitive/hitl/queueApprove/deny/request changes.
cognitive.act()lib/api-client.tsPOST /api/v1/cognitive/act/executeExecute with approval token.

Database Tables

TablePurposeKey Columns
actionsPrimary action queuestatus (pending_approval/approved/denied/executed), approval_token, target_tool
action_proposalsL2→L1 approval flowstatus (pending/approved/rejected/executed/failed), trust_score, evidence_refs
decisionsCognitive Brain decisionsreasoning_chain, evidence_snapshot, trust_score
decision_memoryOrganizational learningwas_correct, pattern_tags, reusability_score
decision_patternsReusable patternssuccess_rate, recommended_action_type
v_today_queueVIEW: tasks + signals + action_proposalsUNION ALL of pending items

Backend Services

ServiceEndpointsRole
Think (services/think/)POST /v1/twin/act, POST /v1/outcome/feedback, POST /v1/decidePropose actions, receive outcomes, learn
Govern (services/govern/)POST /v1/check, POST /v1/approve, POST /v1/reject, GET /v1/pendingPolicy gate
Act (services/act/)POST /execute, GET /proposals/:situation_idExecute with mandatory approval token
Workflow (services/workflow/)GET/POST /api/v1/cognitive/hitl/queue, HITL DOOrchestrate approval queue

Rules (KT Notes)

  1. No action executes without an approval token — Act service returns 403 without x-approval-token
  2. Governance is mandatory — even with valid token, Act calls Govern for double-check
  3. Fail-safe on governance unavailability — if Govern is down, execution is blocked (not allowed)
  4. Results re-ingest through pipeline — Act does NOT write directly to Spine
  5. Deny writes learning signal — rejection feeds back to Think via decision_memory so AI adjusts
  6. Frontend routes ALL decisions through Workflow HITL queue — never call Act/Govern directly

What's Wired vs. Needs Wiring

ComponentStatus
CS Today View approval queueWired to useL2Recommendations
CS At-Risk ViewFully wired
BizOps Dashboard approval queueWired to useL2Recommendations
Twin Chat quick actionsWired to cognitive.twinAct()
Twin Chat entity scopingWired (entityId prop)
L2 Drawer ActSurfaceWired to getHITLQueue
RevOps Pending ReviewFully wired
Finance Invoice ApprovalsNOT wired (client-side only)
Admin Approval WorkflowsNOT wired (mock data)
ExecutionStatusCard live dataNeeds Act execution stream
Flow C write-back after Twin ChatNot triggered yet