Back to the report center

Behavior-first architecture review

Samora's continuous action system

The machine Samora needs so a person can state an objective in chat, let the system operate any authorized part of Samora, watch it pause and wake as reality changes, and receive a traceable result.

4 Sep 2026Whole-workspace source auditSamora-wide scopeDocumentation onlyQuiz pending

The answer in one sentence

Samora needs a persistent goal control plane that turns a user's objective into an explicit scope and authority contract, creates one or more subject runs, reacts to stored events and deadlines, asks short-lived agents for bounded decisions, and sends approved work through existing Samora services until the goal reaches a recorded resolution.

What happens

A user asks Samora to configure, operate, investigate, communicate, or coordinate. Samora keeps the objective alive even while no process is running.

Why this form is required

Messages, calls, provider callbacks, people, timers, configuration changes, and failures arrive on their own schedule. The system must resume from stored facts.

In simple terms: the persistent machine is the goal plus its recorded state. An OpenAI agent is one temporary thinker inside that machine.

Plain meanings

Goal is the outcome contract. Subject is the Samora thing being worked on. Event is a stored fact. Work is a bounded obligation. Wait is a stored condition that can be satisfied by an event or a deadline. Lease is a temporary worker claim. Idempotency key is a repeat-protection ID. Projection is a view that can be rebuilt from facts.

What did we ask?Derive a continuous operator for all of Samora.
What did the system do?Audited source and specified the machine.
Was any database row changed?No.
Was any Activity row created?No. No product runtime was invoked.
CORE LOOPThe process that appears to stay alive
New factReply, timer, provider result, human direction, or state change
Rebuild contextGoal, subject, history, work, waits, policy, and current versions
DecidePropose action, wait, ask, delegate, revise, or stop
Durable goal and subject runsStored outside every worker and model call
Create workTyped, checked, versioned, and repeat-safe
ExecuteCall an authorized Samora capability
Record and waitStore the result before sleeping or deciding again

Assumptions to reject

A permanent model does not need to own a goal or resource. A generated plan does not need to predict every future step. A model must not receive raw database access or provider credentials. A subagent is not a durable job. Chat history alone is not product state.

Leads are one subject, not the architecture

What happens. A goal names an outcome and a resource scope. The scope may contain contacts, campaigns, conversations, agents, tools, documents, integrations, workflow executions, queues, reports, or workspace settings. Samora creates only the subject runs needed to coordinate that goal.

Why. If the runtime is built around a lead ID, it cannot naturally handle "repair failed workflows," "configure this agent," or "attach the new pricing guide and verify it." The durable model must be about work on typed Samora resources.

DIAGRAM 01User goal to understanding to initial work
User goal"Prepare our renewal agent, fix its knowledge, then launch the campaign."
Goal compilerExtract outcome, scope, authority, limits, success, stop rules, and unknowns
Resource resolverPin agent, tools, documents, workflow, campaign, contacts, and versions
Initial workCreate dependency-linked subject runs and first decision items

Configure

Create or revise agents, channel instructions, escalation rules, tools, knowledge, and integrations.

Operate

Launch, pause, resume, cancel, retry, assign, hand off, schedule, and communicate.

Observe

Read conversations, histories, provider results, workflow state, reports, queue health, and failures.

Reason

Qualify, summarize, compare, diagnose, select next work, detect missing information, and assess completion.

Goal exampleSubject runsLikely work that emerges
"Take these 100 contacts and convert interested people."One run per business pursuit or contact, plus a goal-level coordinator.Research, outreach, waits, replies, calls, approvals, handoffs, stop decisions.
"Set up a support agent for WhatsApp and web chat."Agent run, channel-config runs, tool assignments, and knowledge-document runs.Inspect current config, draft instructions, attach tools, test, request approval, publish, verify.
"Find why yesterday's campaign stalled and safely recover it."Campaign run plus selected workflow-execution runs.Inspect events, classify failure, propose repair, approve retry, watch outcomes, report exceptions.
"Connect Gmail and route billing messages to Priya's queue."Integration run, routing-config run, and human-queue run.Request the person's OAuth step, wait for callback, verify account, update routing, send a test, confirm receipt.

Do not create one run for every row by default

A subject run is a coordination boundary, not a database mirror. A small settings change may need only the goal run. A campaign may need one run per recipient because each can wait and diverge. The goal compiler chooses the smallest set that can progress, wait, fail, and finish independently.

Start with behavior, then choose the machinery

What happens. The user states an outcome rather than drawing every edge. Samora makes its interpretation visible, starts safe work, and chooses later work only after it observes what actually happened.

Why. The unknown is larger than replies. A provider can reject a template, an integration can require a person to sign in, a document can fail to index, another user can edit an agent, or a campaign can exceed its error budget. Any of those facts can change the next move.

Continuity survives process death

A restart may delay work. It must not erase a goal, timer, provider result, approval, or action receipt.

Reality outranks the plan

A new fact can invalidate work that looked correct five minutes earlier. The plan is a hypothesis.

New work may appear late

A reply, test failure, config drift, or human request can create work that did not exist when the goal began.

Facts, judgments, and actions stay separate

A callback is a fact. Interpreting it is analysis. Choosing is a decision. Mutating Samora is an action.

Rules remain fixed code

Authorization, consent, scope, quiet hours, budgets, destructive-change policy, and repeat prevention cannot depend on model persuasion.

Completion is explicit

"The command returned 200" does not mean "the goal succeeded." Each goal records its business and operational result.

EXAMPLEOne goal can span several Samora domains
Inspect agentCurrent instructions, channels, tools, knowledge, recent results
Propose changesVersioned diff and impact summary
Human approvalRequired for customer-facing behavior
Apply and testExisting APIs mutate; test event returns evidence
Launch campaignOnly after dependencies pass

What Samora can already do

What happens today. Samora already lets people configure agents, attach tools and knowledge, connect provider accounts, manage contacts and conversations, communicate across five channels, route work to people, build campaigns and workflow graphs, wait for outcomes, retry failures, and inspect operational history.

Why this matters. The new system should operate these product capabilities. It should not replace them. The missing part is a single control layer that can understand an objective, select authorized Samora actions, watch results, and decide again.

In simple terms: Samora has many working controls and execution paths. It does not yet have one persistent goal-directed operator above them.

Audit method and confidence

This review covered samora-fe, samora-be, samora-workflows, samora-dispatcher, samora-voice-agent, samora-lambdas, and samora-form-portal. It also checked samora-landing-v2 and opencode-slack as adjacent products rather than core workspace services. "Working source" means the UI, API, durable records, and runtime path are evidenced in this checkout. It does not prove that every provider or deployment is configured. "Missing" means no first-class record or active path was found after schema, route, type, and UI review.

Samora-wide action surface

The agentic layer needs a governed way to operate more than contacts. The table below separates actions that exist in the current source from the new planning and continuity layer that does not.

SubjectActions evidenced todayWhat the goal system addsSource
AgentsCreate, read, update, delete, and configure channel instructions, runtime config, and escalation.Reason about requested changes, preview impact, ask for approval, apply through the same permission checks, and verify the result.samora-be/services/agent_service/init.go:20-48
ToolsCreate, test, update, delete, attach to agents, detach, and choose allowed channels.Choose only from a versioned capability snapshot. Never let a model invent an endpoint or expand its own authority.samora-be/services/tools_service/init.go:18-40
KnowledgeUpload, list, delete, attach documents to agents, and limit those attachments by channel.Plan a bounded knowledge update, confirm destructive changes, wait for indexing, and verify that the chosen agent can retrieve it.samora-be/services/kbase_service/init.go:43-65
IntegrationsDiscover providers, start a connection, inspect, update, verify, and delete a workspace account.Diagnose configuration, request a human credential step, wait for callback, and continue without exposing secrets to the model.samora-be/services/integrations_service/init.go:39-61
Campaigns and workflowsBuild versioned graphs, launch cohorts, pause, resume, cancel, retry, wait, and inspect per-subject execution.Translate a higher-level outcome into work, adapt after facts arrive, and decide when the business objective is resolved.samora-be/database/schemas/workflows.sql:1-18,74-170
Conversations and peopleRead histories, send through supported channels, claim work, reassign, escalate, take over, resolve, and transfer.Coordinate actions across conversations and goals while consent, human ownership, and conflict rules stay authoritative.samora-be/database/schemas/conversations.sql:11-156
Outcomes and reportingStore operational statuses, dispositions, campaign rollups, evaluations, exports, and queue metrics.Distinguish execution success from goal success, preserve evidence, and explain exceptions.samora-be/services/disposition_service/init.go:18-60

Current boundary

These routes are user-facing product APIs. They are not yet safe model tools. A tool gateway must keep the same workspace ownership and permission checks, add an immutable capability version, classify risk, require approvals where needed, and record each attempted side effect.

Samora action and lead-lifecycle capability audit

Working Partial Missing Separate or legacy
01

Contacts and leads

Contacts work. Leads do not exist as a first-class record.

What exists and what the user can do

Samora has a workspace contact directory with create, import, edit, delete, search, multiple phone numbers, multiple email addresses, tags, and audience lists. Inbound channel code can find or create a contact by a normalized phone number or email. The frontend also contains a separate legacy dialer-contact model with folders and arbitrary metadata.

How it behaves and what it keeps

The modern backend stores identity in contacts.contacts and related phone, email, tag, list, and list-item rows. Channel conversations reuse contact_id. The legacy frontend calls a different /dialer/contacts API and exposes different fields. These two contact models are not shown as one synchronized record.

How it helps the objective

A stable identity lets calls, messages, campaign membership, and contact memory point to the same person. Lists and tags make audience selection possible.

Incomplete, split, or missing

There is no canonical lead or opportunity, pipeline, stage, score, value, source, consent history, next action, durable owner, or conversion timestamp. A contact is a person or address book entry. It is not the business pursuit called a lead. The two frontend contact families also create deduplication and data-drift risk.

Code evidence

samora-be/services/contacts_service/init.go:18-55; samora-be/services/contacts_service/models.go:53-163; samora-be/database/schemas/contacts.sql:22-69,71-159,179-203; samora-fe/src/api/queries/crm/contacts.ts:15-35; samora-fe/src/api/queries/contacts/workspace-contacts.ts:20-65

02

Lead assignment and ownership

Conversation assignment is strong. Lead ownership is absent.

What exists and what the user can do

Users can route or reassign a conversation among an AI agent, receptionist, human queue, and human agent. They can configure which operators may handle which agents and queues. Assignment screens and channel threads show the active handler and past assignment journey.

How it behaves and what it keeps

Changing assignment ends the current active row and inserts a new row in one database transaction. Compare-and-set checks stop two people from claiming the same queue item. Queue membership, role, and channel state limit who may act. This ownership belongs to one conversation episode, not the whole relationship with the contact.

How it helps the objective

A reply can reach a capable person without losing the channel transcript. The assignment history explains who had responsibility at each point.

Incomplete, split, or missing

No record assigns the lead or opportunity itself to a salesperson. There is no owner history across channels, territory rule, owner-level service deadline, or rule saying one person owns every conversation for this lead. The same contact can have different owners in SMS, WhatsApp, email, and voice.

Code evidence

samora-be/database/schemas/conversations.sql:11-156; samora-be/services/conversations_service/dao.go:263-396; samora-fe/src/routes/company/hil/assignments.tsx:18-155; samora-be/services/human_operations_service/dispatch.go:173-226

03

Calling

Working source, gated by voice providers and runtime configuration.

What exists and what the user can do

Users can start a human browser call from a contact, work dialer lists, inspect call history, monitor live calls, listen, take over, transfer, or route a call to a human queue. Samora also supports AI calls, SIP origination, LiveKit sessions, transcripts, recordings, call attempts, and final call status.

How it behaves and what it keeps

The backend creates a shared conversation and call row. The dispatcher leases a durable job, reserves workspace and provider capacity, and starts the voice path. The voice agent selects its mode, runs the call, uploads optional artifacts, saves the final call, and ends assignment. Workflow code maps provider outcomes to results such as answered, voicemail, unanswered, rejected, or failed.

How it helps the objective

Voice gives Samora a live qualification path, reachability evidence, rich transcript context, and a direct handoff route to a salesperson.

Incomplete, split, or missing

Each call remains a channel episode. Saving a call does not move a canonical lead stage, create a general follow-up task, or record conversion. Transcript and recording writes are best effort. Some tool paths can send outside the central workflow and dispatch correlation path.

Code evidence

samora-be/services/voice_service/service.go:404-535,932-1017; samora-dispatcher/internal/voice/worker.go:313-565; samora-voice-agent/main.py:69-163; samora-voice-agent/tools/hangup.py:108-230,411-480; samora-fe/src/components/agents/human-agent-call-modal.tsx:60-96,230-410

04

SMS

Inbound, workflow, and human handling work. Direct contact send is disabled.

What exists and what the user can do

Samora can receive SMS, create or reuse an open SMS conversation, store messages, route to AI or a person, reply, claim, reassign, resolve, and honor STOP and START. Workflows can send SMS. Operators act from Human Operations, while the Logs screen is intentionally read-only.

How it behaves and what it keeps

Inbound processing normalizes numbers, finds or creates the contact, deduplicates the provider message, writes message and routing state, and wakes AI only when AI owns the thread. A human reply requires active human ownership. Resolve closes the SMS conversation and assignment. A later inbound message starts a new episode.

How it helps the objective

SMS is a low-effort follow-up channel after a missed call. A reply can immediately reactivate work and move to a human handler.

Incomplete, split, or missing

The modern contact sheet marks SMS as coming soon. There is no contact-level reminder, next-action record, or lead outcome. India SMS is a separate template delivery path rather than the same conversation model. SMS reassignment contains an explicit role-enforcement TODO.

Code evidence

samora-be/services/sms_service/init.go:46-100; samora-be/services/sms_service/service.go:181-404,901-1145; samora-be/database/schemas/sms.sql:66-124,149-233,239-291; samora-fe/src/components/sms/sms-conversation-sheet.tsx:197-309,419-529; samora-fe/src/components/company/contacts/workspace-contact-details-sheet.tsx:565-599

05

WhatsApp

Working source, gated by provider, number, template, and session rules.

What exists and what the user can do

Users can configure business numbers, manage templates, send an approved template from a contact, read and reply to conversations, assign or resolve work, run bulk broadcasts, inspect delivery and read state, and cancel queued broadcast recipients.

How it behaves and what it keeps

Inbound processing finds the number and contact, reuses or creates an open conversation, deduplicates the message, writes channel and shared assignment state, then wakes the active handler. Outbound production sends create durable dispatch work. A sandbox send ends without a provider job. Free-form replies depend on the active WhatsApp service window.

How it helps the objective

WhatsApp provides template-led first contact, persistent mobile follow-up, delivery and read evidence, and rapid escalation after a response.

Incomplete, split, or missing

The provider and template gates mean an agent cannot simply invent a free-form first message. A closed ticket does not reopen; the next interaction creates a new episode. No WhatsApp action alone changes lead stage, owner, next step, or conversion result.

Code evidence

samora-be/database/schemas/whatsapp.sql:29-157,179-301,321-377; samora-be/services/whatsapp_service/messaging.go:256-598; samora-be/services/whatsapp_service/service.go:932-1148; samora-fe/src/api/queries/whatsapp/whatsapp-v2.ts:458-654; samora-fe/src/routes/company/campaign-tabs/whatsapp-campaigns-tab.tsx:80-122,142-238,263-333

06

Email

Working source, gated by Gmail and Composio configuration.

What exists and what the user can do

Users can connect a Gmail inbox, inspect threads and tickets, reply, close or reopen tickets, generate a draft, manage templates, and use email in campaigns. Actionable work lives in the escalation or ticket view; the generic log detail is read-only.

How it behaves and what it keeps

The webhook validates its signature and time window, deduplicates provider events, writes a durable email event, claims a processing lease, triages the message, then creates or links a ticket, contact, conversation, and assignment when routing requires them. Monitoring-only or unconfigured email can remain contactless.

How it helps the objective

Email supports long-form answers, pricing, documents, and follow-up that does not fit a short message.

Incomplete, split, or missing

The contact sheet Email action is disabled. Trigger mutation routes return 409 because the Channels page owns watches. Some mail is intentionally skipped before a contact or shared conversation exists. Email still has no canonical lead outcome or next-action record.

Code evidence

samora-be/services/email_service/init.go:53-121; samora-be/services/email_service/server.go:427-537; samora-be/services/email_service/service.go:883-1238,1267-1384; samora-be/database/schemas/email.sql:29-189,309-401; samora-fe/src/components/v1/omnichannel/gmail-tickets.tsx:88-169,192-279

07

Website chat

Working conversation and handoff path.

What exists and what the user can do

A website visitor can start a chat through the widget. AI or a person can respond. Operators can inspect the transcript, observe unread state, see whether the conversation moved through AI, a queue, or a human, and close the conversation.

How it behaves and what it keeps

Chat writes a shared conversation, typed messages, timestamps, and assignment lifecycle. The system updates last-message and last-activity timestamps as messages arrive. Human queues and claims use the same shared assignment idea as the other conversation channels.

How it helps the objective

Chat captures high-intent visitors while they are present and lets AI hand the conversation to a person.

Incomplete, split, or missing

Chat history is still a channel thread, not a lead journey. It does not create a pipeline stage, due task, revenue outcome, or a cross-channel Activity record.

Code evidence

samora-be/services/chat_service/dao_transactions.go:330-371,1693-1731; samora-fe/src/routes/company/log-tabs/chat-logs-tab.tsx:89-113,181-235,318-386; samora-be/database/schemas/conversations.sql:11-65

08

Multiple conversations and history

Multiple episodes work. One business journey does not.

What exists and what the user can do

A contact can have many calls, closed and open SMS or WhatsApp episodes, email threads, and chat conversations. Channel screens show their own messages, statuses, assignments, and timestamps. Workflow executions keep step attempts and events.

How it behaves and what it keeps

A shared parent identifies the contact and channel. Typed tables retain provider details. Assignment rows record who handled an episode. Closing SMS or WhatsApp ends that episode, and later inbound contact creates a new one. Workflow steps can point to the exact conversation and provider record.

How it helps the objective

Operators can review prior touches before replying, and automation can correlate an inbound message to the exact action that invited it.

Incomplete, split, or missing

No lead or opportunity groups all channel episodes under one commercial objective. The product does not show one raw, canonical cross-channel timeline with tasks, notes, stage changes, approvals, and revenue events.

Code evidence

samora-be/database/schemas/conversations.sql:11-156; samora-be/database/schemas/workflows.sql:152-255; samora-workflows/internal/store/replies.go:18-97,262-328; samora-fe/src/routes/company/central-campaigns/hub/contact-runs.tsx:16-121

09

Contact memory and activity timelines

Memory works. A unified Activity ledger is absent.

What exists and what the user can do

Contact Memory stores a rolling summary, interaction count, last channel, profile facts, structured facts with provenance, and append-only memory events. Channel screens and workflow execution views also expose their own timelines.

How it behaves and what it keeps

Eligible conversation endings enqueue memory work. The memory service updates summary and facts while preserving source information. Workflow step_events, chat messages, call rows, and channel message tables each record part of the history. PostgreSQL notifications wake listeners but do not create an audit row.

How it helps the objective

Memory gives the next AI or human a compact account of earlier conversations and known facts.

Incomplete, split, or missing

Memory is derived context, not the authoritative business history. There is no generic Activity table covering message, call, note, task, stage, owner, approval, handoff, and conversion changes. A missed notification must be recovered from durable channel rows or a sweep.

Code evidence

samora-fe/src/api/types/memory/memory-types.ts:1-77; samora-fe/src/components/company/contacts/contact-memory-section.tsx:141-185,210-461; samora-be/database/schemas/workflows.sql:241-255; samora-be/database/schemas/notifications.sql:1-27,30-101,193-338

10

Lead stages and outcomes

Local statuses and disposition definitions exist. A pipeline does not.

What exists and what the user can do

Users can configure disposition questions for call outcome, interest, lead quality, and follow-up requirements. Call details and analytics can show evaluation answers in supported paths. Campaigns and conversations have operational statuses such as running, completed, failed, open, or closed.

How it behaves and what it keeps

Disposition configuration can attach to agents or dialer folders. Some call evaluation paths produce answers and reports. Campaign status says whether processing finished, not whether the lead converted. A definition is a question to ask, not the business answer itself.

How it helps the objective

Outcome questions help a person judge interest and call quality. Operational statuses show whether outreach ran.

Incomplete, split, or missing

There is no governed lead stage, stage-transition history, canonical qualification result, won or lost reason, appointment outcome, or conversion record. Backend source did not show a current per-conversation disposition-result table. The advanced inbound frontend also replaces evaluation arrays with empty arrays on one path.

Code evidence

samora-be/database/schemas/dispositions.sql:12-58; samora-fe/src/routes/company/company-dispositions.tsx:65-145,147-269; samora-fe/src/components/analytics/outcome-analysis.tsx:75-220; samora-fe/src/hooks/data/analyse/use-inbound-calls.tsx:212-245,260-299; samora-be/database/schemas/campaigns.sql:32-53

11

Notes

Notes exist only in narrow local records.

What exists and what the user can do

A dialer-list item can hold notes and a status. The legacy contact model has remarks. Contact Memory can hold structured facts. Workflow nodes can also contain authoring notes.

How it behaves and what it keeps

These values remain attached to the dialer item, legacy record, memory fact, or workflow definition that created them. They do not appear as one chronological note stream for the lead.

How it helps the objective

A dialer operator can leave context for the next attempt. Memory facts can carry stable information into later conversations.

Incomplete, split, or missing

There is no general contact or lead note with author, visibility, created time, edit history, mention, attachment, or link to a goal and conversation. A memory fact is not a human note and should not be used as one.

Code evidence

samora-be/database/schemas/human_operations.sql:251-383; samora-fe/src/components/company/hil/dialer-list-contact-sheet.tsx:200-355; samora-fe/src/api/types/memory/memory-types.ts:1-77; samora-fe/src/api/types/crm/crm-types.ts:3-37

12

Reminders, follow-ups, and tasks

Automation waits exist. General work records do not.

What exists and what the user can do

A workflow can wait, retry, wait for a reply, and run a later node. Campaigns can be scheduled. Dialer items can say callback required. Post-call code can send messages or alerts in some legacy paths.

How it behaves and what it keeps

A Temporal timer keeps workflow progression durable. A reply can beat the timer and choose another graph branch. These are execution mechanics inside one predefined graph. They are not a user-visible due task with assignee, priority, due time, snooze, completion reason, and dependencies.

How it helps the objective

Existing waits and retries prevent some multi-touch sequences from stopping after one attempt.

Incomplete, split, or missing

No generic task, reminder, follow-up, next-best-action queue, or overdue service deadline was found. Callback-required has no general due-time contract. New work cannot yet emerge as a durable product record merely because the model decided it is needed.

Code evidence

samora-workflows/internal/workflows/contact.go:364-459,604-672; samora-be/database/schemas/workflows.sql:102-134,209-255; samora-fe/src/components/company/hil/dialer-list-contact-sheet.tsx:200-355; samora-lambdas/post-call-actions/main.py:157-367

13

Handoffs and human intervention

Strong channel handoff foundation.

What exists and what the user can do

AI can escalate to a queue or person. Operators can claim, answer, reject, reassign, reply, resolve, take over a live call, transfer it, or end takeover. Queue screens show demand, available agents, wait time, answer rate, and service breaches.

How it behaves and what it keeps

Queue escalation changes shared assignment and enqueues dispatch in one transaction. Voice offers require online presence and a fresh heartbeat. Asynchronous email, WhatsApp, and SMS can assign the least-loaded active member without requiring live presence. Timeout and retry logic free abandoned offers.

How it helps the objective

An interested or confused lead can reach a salesperson. The assignment journey remains visible within the conversation.

Incomplete, split, or missing

Human approval of an autonomous action is not yet a general runtime concept. There is no durable request saying what decision is needed, who may answer, when it expires, and which pending work it blocks. Lead ownership also remains separate from conversation handoff.

Code evidence

samora-be/services/human_operations_service/dispatch.go:173-367,417-767; samora-be/services/human_operations_service/dispatch_dao.go:133-201,332-620; samora-fe/src/routes/company/hil/overview.tsx:245-320,399-525; samora-fe/src/api/queries/hil/workspace-queue-offers.ts:17-91,104-235

14

Automations, campaigns, and waits

This is Samora's strongest base, but it is a graph runner.

What exists and what the user can do

Users can draft and publish versioned graphs with voice, SMS, WhatsApp, email, wait, wait-for-reply, condition, split, retry, and end nodes. Campaigns select an audience, pin a workflow version, schedule or launch, pause, resume, cancel, inspect each recipient, and retry a failed node.

How it behaves and what it keeps

Temporal starts one contact workflow per campaign recipient. Each workflow follows a published edge graph. It checks suppression before every attempt, dispatches channel work, waits for a provider result or reply, records node runs and step events, then follows the matching edge. Timers and signals survive process restarts. Reconciliation repairs missed wake notifications.

How it helps the objective

Samora can already run cross-channel sequences for many contacts, correlate replies to the correct outbound attempt, retry safely, and expose execution history.

Incomplete, split, or missing

The next node still comes from a graph authored before execution. The system does not reconsider a high-level goal and invent new work after every event. A campaign objective is descriptive text, not an executable success contract. Current local workflow files also contain uncommitted work, so deployed parity must be checked separately.

Code evidence

samora-be/database/schemas/workflows.sql:1-18,102-255; samora-be/database/schemas/campaigns.sql:1-20,74-164; samora-workflows/internal/workflows/contact.go:180-320,675-840; samora-workflows/internal/triggers/router.go:408-526,927-1093; samora-workflows/cmd/worker/main.go:58-116

15

Notifications

Operational notifications work in parts. One screen is a placeholder.

What exists and what the user can do

The frontend bell can load notifications, show unread count, mark one or all read, expand messages, and navigate using route templates. Channel screens also use polling, WebSockets, server-sent events, or database wake signals.

How it behaves and what it keeps

Backend database notifications are lightweight wake hints. A durable channel row or event remains the fact that a worker re-reads. The UI bell expects a notification API. Human queue offers use authenticated streaming events.

How it helps the objective

Users can notice work that needs attention and see live queue or conversation changes.

Incomplete, split, or missing

The standalone Notifications route is only placeholder text. A wake notification is not a business Activity record. Product and backend route parity for every bell item must be verified before calling this a complete alert center.

Code evidence

samora-fe/src/components/notifications/notification-bell.tsx:16-218; samora-fe/src/api/queries/notifications/notifications.ts:13-88; samora-fe/src/routes/notifications.tsx:1-3; samora-be/database/schemas/notifications.sql:1-338

16

Reporting and attribution

Operational reporting exists. Conversion truth does not.

What exists and what the user can do

Users can inspect calls, transcripts, recordings, campaign status, per-recipient execution, delivery and reply results, outcome-question distributions, queue metrics, workflow node history, and some legacy campaign analysis exports.

How it behaves and what it keeps

Campaign rollups aggregate operational counters such as dispatched, delivered, engaged, no answer, failed, and completed. Channel and workflow rows supply detailed drilldown. A report can say an execution finished even if no sale occurred.

How it helps the objective

Teams can find failed sends, unanswered calls, engaged recipients, slow queues, and weak campaign nodes.

Incomplete, split, or missing

There is no canonical conversion, source attribution, owner attribution, revenue, opportunity value, funnel stage, cohort, cost per converted lead, or multi-touch attribution record. Operational completion must not be reported as business success.

Code evidence

samora-be/database/schemas/campaigns.sql:147-164; samora-fe/src/routes/company/central-campaigns/hub/campaign-detail.tsx:60-131,162-225,292-417; samora-fe/src/components/analytics/agent-disposition.tsx:70-145,180-221; samora-lambdas/campaign-finished-analysis/main.py:26-72

17

Integrations, permissions, and provider gates

Strong control points, with many configuration dependencies.

What exists and what the user can do

Samora has workspace roles and named permissions across contacts, campaigns, calls, channels, memory, and human operations. Users can connect provider accounts through Composio and configure voice, SMS, WhatsApp, email, numbers, templates, queues, and agents.

How it behaves and what it keeps

Authentication establishes workspace and effective role before route permission checks. Services enforce current assignment and record scope. Integration rows keep provider identifiers and safe metadata while Composio owns credentials. Dispatch workers apply quotas, leases, retries, and unknown states rather than blindly sending twice.

How it helps the objective

These controls make real outreach possible while limiting access, cost, provider misuse, and duplicate delivery.

Incomplete, split, or missing

A goal-driven system still needs a single capability registry that tells the decision layer what is available now, for this workspace and lead. It also needs one policy decision for consent, quiet hours, budget, channel rules, approval, and human takeover before any model proposal can become a send.

Code evidence

samora-be/authorization/permissions.go:3-12,15-136; samora-be/authorization/policy.go:3-119; samora-be/services/integrations_service/service.go:143-369,448-503; samora-be/database/schemas/integrations.sql:1-47,127-149; samora-dispatcher/internal/store/jobs.go:194-274,393-503

18

Adjacent and incomplete surfaces

Useful code exists, but it is not one integrated lead system.

What exists and what the user can do

The form portal has a separate case, invitation, OTP, form revision, interview workflow, extraction, review, approval, export, and DocuSign lifecycle. The frontend also contains legacy CRM, campaign, live-monitoring, and analytics screens. The landing application has a public voice demonstration. Operational Lambdas perform post-call actions, learning, memory, reporting, and alerts. The Slack bridge lets engineers operate a coding agent from Slack.

How it behaves and what it keeps

The form portal uses its own PostgreSQL source of truth and per-interview Temporal workflow. Calls and AI extraction are disabled by default until configuration is complete. The landing voice path demonstrates a public session rather than a lead record. The Slack bridge persists thread-to-coding-session mappings, not lead state. Several legacy frontend screens call older contracts or show explicit TODO text. Some Lambdas have separate retry and callback rules.

How it helps the objective

The form portal proves Samora can build durable, audited, human-reviewed work around a long-running customer case. Legacy screens and Lambdas contain reusable ideas and domain logic.

Incomplete, split, or missing

These parts do not form the current cross-channel lead lifecycle. The form portal is a separate vertical. The landing demo and Slack coding bridge are not CRM or conversion runtimes. Live views for non-voice channels, all logs, some campaign tabs, non-voice test, and analysis pages contain placeholders. A feature should count only when UI, API, durable records, and runtime path meet.

Code evidence

samora-form-portal/README.md:1-7,25-109; samora-form-portal/backend/app/applications.py:72-113; samora-form-portal/backend/app/routers.py:413-624,710-744; samora-landing-v2/src/VoiceAssistant.tsx:27-56; opencode-slack/src/index.ts:11-89; opencode-slack/src/bridge.ts:49-169; samora-fe/src/routes/company/company-live.tsx:68-79; samora-fe/src/routes/company/log-tabs/all-logs-tab.tsx:3-7; samora-fe/src/routes/agents/analyze-simple-page.tsx:5-10

19

Agent and channel configuration

Working CRUD and per-channel configuration.

What exists and what the user can do

Users can create, list, inspect, edit, and delete workspace agents. Each agent can carry separate instructions, runtime settings, developer settings, and escalation settings for voice, WhatsApp, email, chat, and SMS.

How it behaves and what it keeps

Agent identity and channel records are stored separately. Route middleware checks read or write permission before a handler runs. A channel update changes durable configuration used by later runtime calls.

How it helps the objective

A Samora-wide operator could create a specialist, change its guidance, or repair an escalation rule as part of a larger goal.

Incomplete, split, or missing

There is no versioned agent-change proposal, impact preview, goal link, approval record, rollback instruction, or post-change behavior check. Direct configuration writes are not yet an agentic work lifecycle.

Code evidence

samora-be/services/agent_service/init.go:20-48; samora-be/database/schemas/agents.sql:11-75; samora-fe/src/app.tsx:216-880

20

Tools and agent-tool assignments

Working management surface. Unsafe as a raw model boundary.

What exists and what the user can do

Users can create, test, inspect, edit, and delete workspace tools. They can attach tools to an agent, choose channels for the association, update that choice, and detach a tool.

How it behaves and what it keeps

Workspace tools store a name, description, and JSON configuration. A separate row joins one tool to one agent and records allowed channels. Unique indexes prevent two active tools with the same workspace name and two active copies of the same assignment.

How it helps the objective

This is the start of a capability catalog. The decision runtime can see a filtered, versioned description of actions available to the current user and subject.

Incomplete, split, or missing

The current generic configuration is not enough for autonomous use. Each callable capability still needs a strict input and output schema, risk class, authorization rule, timeout, retry rule, approval rule, secret policy, and repeat-protection key.

Code evidence

samora-be/services/tools_service/init.go:18-40; samora-be/database/schemas/tools.sql:1-85

21

Knowledge-base documents

Working storage, vector-provider, and agent-assignment path.

What exists and what the user can do

Users can upload, list, and delete workspace documents. They can attach a document to an agent, detach it, and choose which channels may use it.

How it behaves and what it keeps

Samora stores document metadata and a retrieval identifier in PostgreSQL, file content in object storage, and searchable content through the vector service. Agent-document rows keep channel scope.

How it helps the objective

An agentic goal can prepare or repair an agent's knowledge set, wait for processing, and verify retrieval before the agent talks to customers.

Incomplete, split, or missing

Deletion and reassignment need explicit approval and impact checks. The goal runtime also needs an indexing result event and a version pinned to the decision that used the document.

Code evidence

samora-be/services/kbase_service/init.go:20-65; samora-be/database/schemas/kbase.sql:6-86

The missing part is a control plane, not another tool

What happens now. Individual services know how to create agents, store documents, send messages, run workflow graphs, and manage conversations. No one durable record owns a free-form objective that crosses those services.

Why this blocks the desired behavior. Without a goal contract, resource scope, subject runs, event ledger, decision record, dynamic work, approval state, and completion test, a later worker cannot know why earlier actions happened or what remains.

Goal and resource truth

Objective, revisions, selected subjects, pinned versions, authority, budget, success test, stop test, and result.

Continuous work state

Decisions, work items, dependencies, waits, attempts, approvals, conflicts, cancellations, and settlement.

One audit story

Events that link model proposals, policy decisions, Samora mutations, provider outcomes, human actions, and completion evidence.

Domain records still matter

A contact is not a lead. An agent is not its current configuration version. A campaign is not each recipient's execution. A conversation is not the full customer relationship. The new goal layer links these records. It must not collapse their meanings into one generic object.

The machine

What happens. A durable goal workflow owns the objective. It starts subject runs where independent progress is needed. Each run alternates among runnable work, blocked work, waiting, human attention, and resolved states. New events trigger a fresh bounded decision.

Why. This lets 100 contacts diverge while an agent configuration change remains one coordinated operation. Any worker can recover after a crash because ownership lives in records, not in process memory.

In simple terms: Temporal remembers when to wake. PostgreSQL remembers what is true. Agent workers think briefly. Existing services act.

DIAGRAM 02Work to execution to result
Runnable workTyped obligation, resource version, policy scope, repeat-protection key
Temporary leaseOne worker claims it for a bounded time
Samora serviceCreate, update, send, call, test, launch, assign, or query
Attempt resultChanged resource, provider receipt, safe error, cost, and timestamps
Result eventStored fact available to the next decision
DIAGRAM 03Result or event to context to decision
New eventReply, config edit, test result, callback, timer, or human instruction
CorrelateWorkspace, goal, subject, resource versions, work, and cause
Build contextCurrent facts, history, pending work, waits, rules, and available tools
Decision proposalTyped next intent with evidence and preconditions
DIAGRAM 04Decision to new work
Typed proposalAction, wait, ask, delegate, revise, resolve, or stop
Policy gateUser authority, resource scope, risk, conflict, budget, current version
Work materializerWrites work, dependency, approval, and wait records in one change
Queue or blockRunnable now, scheduled, waiting for an event, or waiting for a person

Reasoning side

  • Read bounded context
  • Call read-only helpers
  • Ask specialist subagents
  • Return a typed proposal
POLICY GATE

Execution side

  • Recheck identity and scope
  • Claim the work and repeat-protection key
  • Call an existing Samora service
  • Store the receipt and event

The records that make the machine real

What happens. These records survive every model call and worker. Each has one job. Together they answer why work exists, what it may touch, what happened, what is pending, and whether the objective is done.

Why. A single prompt, transcript, or JSON state blob cannot safely represent authorization, product truth, retries, waits, and audit history.

01

Goal contract

Represents
The requested outcome, resource scope, success and stop rules, time, budget, authority, and autonomy level.
Creation and change
Compiled from chat and confirmed by the user. Material changes create a new revision.
Causes and relations
Starts a goal workflow, subject runs, initial work, and final assessment.
02

Directive

Represents
A dated human instruction that changes scope, priority, constraints, or direction.
Creation and change
Written through chat or a control action with author and effective time.
Causes and relations
Wakes the goal, invalidates stale work, and may create a new contract revision.
03

Resource scope

Represents
The exact Samora objects and selectors the goal may read or change, plus pinned versions where drift matters.
Creation and change
A resolver turns names and filters into typed references. Expansion needs authority and is recorded.
Causes and relations
Limits context, tools, subject runs, conflict checks, and completion aggregation.
04

Subject

Represents
The domain object or business case under work, such as a campaign, contact, conversation, agent, tool, document, integration, queue, report, or workflow execution.
Creation and change
Most subjects already exist in Samora. A lead or opportunity is a new business record when commercial state is required.
Causes and relations
Provides stable identity and concurrency keys. It does not contain the goal.
05

Subject run

Represents
One goal's long-lived pursuit for one independent subject or case. This is the unit that can wait and wake.
Creation and change
The goal workflow creates only the runs needed for independent progress.
Causes and relations
Owns work and waits. It moves through active, waiting, needs-human, resolved, stopped, or failed states.
06

Plan

Represents
A versioned hypothesis about useful work, not a fixed future and not system truth.
Creation and change
The compiler makes an initial plan. Decisions revise it as evidence changes.
Causes and relations
Explains intent and can seed work. Events and policy may supersede it.
07

Event

Represents
An immutable fact such as a message, action result, resource edit, timer expiry, approval, failure, or human direction.
Creation and change
Provider adapters, Samora services, workflows, timers, and people write through a deduplicated inbox.
Causes and relations
Updates projections and wakes relevant goals or subject runs. Events never change after storage.
08

Context snapshot

Represents
A bounded, redacted view of facts needed for one decision. It includes source references and versions.
Creation and change
A context builder reads current product data, events, work, waits, policy, and selected history.
Causes and relations
Feeds one agent turn. A later event creates a newer snapshot.
09

Decision proposal

Represents
A typed recommendation with action kind, target, evidence, confidence, preconditions, expected result, and alternatives.
Creation and change
A bounded agent turn produces it. Fixed code validates it.
Causes and relations
May become work, waiting, a human request, a goal revision, or a resolution assessment. It never authorizes itself.
10

Work item

Represents
A bounded obligation that can be claimed, blocked, retried, cancelled, or finished.
Creation and change
The materializer writes it only after schema, scope, conflict, and policy checks.
Causes and relations
A worker lease starts an attempt. A result emits an event and may unlock dependent work.
11

Dependency

Represents
A named condition that must settle before another item can run.
Creation and change
Work materialization links items to results, approvals, waits, or resource versions.
Causes and relations
Satisfaction makes work eligible. Failure or cancellation follows explicit propagation rules.
12

Wait condition

Represents
A durable subscription to event patterns plus an optional deadline.
Creation and change
A decision or deterministic operation creates it when useful progress depends on reality.
Causes and relations
A matching event or deadline wakes the run. The wait becomes satisfied, expired, or superseded.
13

Action attempt and result

Represents
The exact authorized mutation and what Samora or an external provider reported.
Creation and change
The executor stores an attempt before acting and later attaches a receipt, result, or unknown outcome.
Causes and relations
The repeat-protection key prevents duplicate intent. The result becomes an event for a later decision.
14

Capability and policy

Represents
A capability says what operation exists. Policy says whether this actor, goal, subject, version, time, and risk level may use it.
Creation and change
Samora derives a versioned capability snapshot from routes, configuration, health, roles, and assignments. Administrators own policy.
Causes and relations
The gate allows, denies, or requires human approval. A model cannot add its own capability.
15

Human request or handoff

Represents
A durable question, approval, credential step, takeover, or ownership transfer that only an authorized person can settle.
Creation and change
Decision or policy creates it with choices, evidence, expiry, and allowed responders.
Causes and relations
The answer becomes an event, wakes the run, and may invalidate pending work.
16

Resolution assessment

Represents
A recorded finding that a subject run or goal met a terminal rule and has no required unsettled work.
Creation and change
Fixed rules assess known facts. A model may summarize evidence but does not mark success by itself.
Causes and relations
Closes a run as successful, partial, stopped, failed, superseded, or needing attention. The parent goal aggregates these results.

What happens after a user gives Samora a goal

What happens. Samora turns the message into a goal contract, resolves exact resources and authority, creates the smallest useful run tree, then repeats context, decision, checked work, result, and waiting until resolution.

Capture the exact request

Store the user's words, identity, workspace, selected objects, attachments, and timestamp.

Resolve identity and authority

Calculate the user's current workspace role and permissions before asking a model what to do.

Compile the goal contract

Extract outcome, scope, success, stop, deadline, budget, autonomy, approval rules, and unknowns.

Ask only material questions

Stop for information that cannot be safely inferred. For example, which production campaign may be retried or whether a customer-facing instruction may change.

Pin the resource scope

Resolve IDs, filters, current versions, exclusions, and conflict keys. Record later scope changes as revisions.

Start the goal workflow

A durable coordinator owns pause, resume, cancellation, budgets, aggregate progress, and completion.

Create subject runs

Fan out only where pieces can progress or wait independently. Record parent and dependency links.

Create initial decision work

A run may start with inspection, research, validation, drafting, a direct safe action, or a human question.

Build bounded context

Load authoritative facts and the smallest useful history. Remove secrets and unrelated personal data.

Produce a typed proposal

A short-lived OpenAI Agents SDK run may use read tools or specialist agents. It returns a schema-valid intent.

Authorize and materialize

Fixed code rechecks permissions, scope, versions, conflicts, budgets, and approval rules before writing work.

Execute through Samora

A worker calls the existing domain service. It records the attempt, repeat-protection key, changed rows, receipt, and safe error.

Interpret the result

Normalize fixed outcomes first. Use bounded language analysis only for content that needs interpretation.

Wait without keeping compute alive

Record event predicates and a deadline. Temporal sleeps. No model or worker remains assigned.

Wake and reconsider

Store the incoming event, supersede stale work, rebuild context, and create a new decision turn.

Resolve subjects and the goal

Close only when terminal rules pass and required work, approvals, and waits have settled. Report business outcome separately from execution health.

DIAGRAM 09One lead journey inside the general machine
Opportunity runGoal says qualify and hand off interest
SMS sentAttempt and provider receipt stored
WaitReply event or four-hour review
Pricing questionReply wakes the run after ten minutes
ApprovalPricing material needs a person
Call requestedSchedule and observe the call
Sales handoffPerson accepts with context
ResolvedInterested and handed off, not yet won

How Samora decides what to do next

What happens. A decision worker receives one versioned envelope. It compares the goal with the current subject, new events, prior results, other active work, waits, policy, available capabilities, and human instructions. It returns typed proposals, not executable prose.

Why. The component that understands a result should not automatically gain permission to mutate a resource. Keeping four stages apart gives Samora a clear audit trail and safe retries.

1. ExecuteAn approved worker invokes one capability.
2. ObserveA result adapter records what happened.
3. UnderstandCode or a model derives useful facts.
4. DecideAn agent proposes the next intent.
5. AuthorizeFixed policy permits, denies, or asks.
6. MaterializeCode writes new work and waits.

The decision envelope

InputQuestion it answersSource
Goal and current revisionWhat outcome and limits govern this turn?Goal store
Subject reference and versionWhich exact Samora object or case is being considered?Domain service and scope snapshot
Recent facts and relevant historyWhat changed and what evidence led here?Event ledger and domain records
Open work, dependencies, waits, and approvalsWhat is already happening or blocked?Goal runtime records
Capability snapshotWhich typed operations exist for this actor and subject now?Capability registry
Policy, budgets, risk, and conflictsWhat may happen, what requires a person, and what is forbidden?Authorization and policy service
Other goals touching conflict keysWould this action contradict or duplicate other work?Conflict index
DecisionProposal { intent: inspect | draft | act | wait | ask_human | delegate | revise | resolve | stop target: { subject_type, subject_id, expected_version } capability_id?: string arguments?: object evidence_event_ids: string[] rationale_summary: string confidence: number preconditions: string[] expected_result: string wait_spec?: { event_patterns: object[], deadline?: timestamp } }

Store conclusions, not hidden reasoning

Keep the structured decision, short rationale, cited evidence, confidence, model and prompt version, policy result, and usage. Do not store private chain-of-thought. The next worker needs evidence and conclusions.

Waiting is stored state, not an idle agent

What happens. A wait records which events can satisfy it and when to reassess if none arrive. Temporal suspends the run without holding a worker. The first relevant event or deadline causes one serialized re-evaluation.

Why. A four-hour timer cannot ignore a reply after ten minutes. A provider callback cannot be lost because a model process exited. A human approval may take days.

DIAGRAM 05Work to wait to external event to reactivation
Action resultMessage queued, integration started, document uploaded, or retry requested
Wait recordEvent predicates, correlation keys, deadline, current context version
First trigger winsExternal event, human answer, dependency result, or deadline
Store and signalPersist the fact before waking the durable workflow
Fresh decisionRe-read current state and supersede stale work
Waiting forEarly wake eventDeadline behavior
SMS, WhatsApp, email, or chat replyInbound message linked to conversation and attemptReassess silence and choose follow-up, another channel, or stop.
Call completionProvider or voice-agent final resultReconcile an unknown call state before retry.
Integration authorizationVerified provider connection callbackRemind the authorized user or stop without exposing credentials.
Knowledge processingIndexing success or failureInspect status and escalate a stalled document.
Human approval or handoffApproved, rejected, answered, accepted, or declinedExpire safely, notify, and choose a fallback.
Another work itemDependency settledApply the recorded propagation rule.

Race rule

If an event and deadline arrive together, store both and serialize the next decision for that subject run. The context version and repeat-protection keys prevent two contradictory changes. A late relevant event can cause another decision.

Agents are temporary decision workers

What happens. Any compatible worker can claim a bounded item, load its durable context, run one agent turn or one deterministic action, write the result, and release the lease. The durable goal workflow is the coordinator. It is code, not a permanent language model.

Why. Permanent model ownership traps state inside a process, makes failover hard, and wastes compute while the system waits. The work queue should own availability. Records should own memory.

DIAGRAM 07Agents pick up and release work
Runnable poolDecision, analysis, drafting, verification, and deterministic action work
Worker claimsLease, deadline, attempt number, context version
Bounded executionMain agent may call specialist agents as tools
Persist resultOutput, evidence, trace link, usage, error class
ReleaseNo private memory or ownership remains

How many agent types?

Start with one manager agent contract and a small set of narrow specialists. Add a specialist only when it needs different instructions, tools, output schema, risk policy, or evaluation. Do not create an agent for every database table. Use agents-as-tools for bounded research, classification, summarization, and drafting while the manager retains decision ownership. Use an SDK handoff only when another agent should own the rest of the current conversational turn.

Main agent versus subagents

The goal workflow is the durable main system. The SDK manager agent is temporary. Its subagents are even narrower and live only inside that turn. None owns a subject, timer, credential, or canonical memory.

Persistent state versus temporary execution

What happens. Samora stores every fact needed to resume or explain a goal. Workers and agent call stacks may disappear after each bounded turn.

DIAGRAM 08What survives and what may vanish

Persistent Samora state

Goal and revisionsResource scope
Subject runsEvents
DecisionsWork and waits
Attempts and receiptsApprovals
Versions and policyResolution

Temporary execution

Worker processCall stack
Model connectionToken stream
Subagent instancesRebuildable cache
Private reasoningRendered client view
Truth ownerOwnsMust not own
PostgreSQLProduct objects, goal contracts, directives, events, proposals, work, approvals, attempts, audit, and projections.A sleeping process or hidden model memory.
TemporalDurable progression, timers, signals, retries, cancellation, and serialized lifecycle transitions.Contacts, agent settings, transcripts, or business outcome truth.
OpenAI Agents SDKOne bounded turn, tool loop, specialist calls, guardrails, structured output, and short approval continuation state.Days-long product continuity, tenant policy, provider credentials, or canonical memory.
Existing Samora servicesAuthorized domain mutations and reads, provider adapters, and resource-specific validation.High-level goal selection.

In simple terms: if every model process stops tonight, Samora must know exactly what to do when an event arrives tomorrow.

Events turn reality into new work

What happens. An adapter authenticates and deduplicates an incoming event, stores it, correlates it to affected resources and goals, updates projections, then signals the relevant Temporal workflows. Each awakened run rebuilds context before deciding.

external callback, Samora mutation, timer, human answer, or work result -> authenticate and normalize -> deduplicate by source and external event ID -> persist immutable event -> correlate workspace, goal, subject, conversation, work, attempt, and cause -> update rebuildable views -> signal affected Temporal workflow IDs -> serialize each subject's next decision -> create newly authorized work
DIAGRAM 06Many pieces of work coexist

Goal A: recover campaign

Campaign diagnosis
Execution 17 retry approval
Execution 44 waiting for callback

Goal B: prepare renewal agent

Instructions awaiting review
Knowledge indexing
Test conversation running

Goal C: work 100 contacts

31 waiting for replies
8 calls active
2 human handoffs

Shared controls

Workspace budgets
Resource conflict keys
Provider and channel limits

Concurrency rules

  • Each subject run serializes its decisions so simultaneous events cannot create contradictory work.
  • Different runs execute concurrently under workspace, provider, channel, model, and cost limits.
  • A resource and operation conflict key prevents two goals from changing the same agent version or contacting the same person through the same channel at once.
  • Human takeover, opt-out, legal blocks, and current permissions override older goals.
  • Every item carries the goal revision, subject version, capability version, and policy version it was created under. A mismatch forces revalidation.
  • The goal workflow aggregates summaries. It does not put every subject's raw history into one model conversation.

Humans are part of the state machine

What happens. Samora creates a durable human request with the exact question, proposed change, evidence, choices, allowed responders, expiry, and blocked work. The answer is an authenticated event.

Why. Approval cannot be a transient chat message. Configuration changes, credentials, customer promises, destructive actions, uncertainty, and ownership transfers need accountable people.

Human caseSystem behaviorAfter the response
Missing informationAsk a concrete question and block only dependent work.Record a directive, rebuild context, continue.
Sensitive mutationShow the exact resource diff, impact, and rollback before approval.Recheck current version and permission, then execute or reject.
Integration credential stepSend the authorized user through the provider-owned connection flow.Store only safe connection status and wake on verification.
Conversation or sales handoffTransfer the conversation and relevant goal context, then wait for acceptance.Change operational ownership and continue or resolve under the goal rule.
Manual overridePause or cancel conflicting automated work before the person acts.Record the human action and reconsider the remaining objective.

Directions preserve history

If the user says "do not launch; update only the draft agent," Samora writes a new directive, blocks the launch, cancels work that has not started, preserves completed facts, and creates a fresh decision. It never rewrites history as though the first instruction did not exist.

This is not a larger workflow graph

What happens. Traditional automation selects the next prewritten edge. The desired runtime decides which work should exist after reading the current goal and facts.

Traditional workflow

  1. Start at a known node.
  2. Execute that node.
  3. Map its result to a prewritten edge.
  4. Continue to a predefined end.

The graph defines the possible future.

Goal-driven runtime

  1. Load the goal and current facts.
  2. Choose or revise bounded work.
  3. Authorize and execute it.
  4. Observe and interpret the result.
  5. Create work that may not have existed earlier.
  6. Assess resolution against the goal contract.

Facts are truth. Plans may change.

Keep deterministic workflows

Agentic choice should sit above reliable automation. A decision may choose "launch this published campaign" or "send this approved WhatsApp template." Existing code still validates the campaign or template, dispatches it, handles callbacks, and records outcomes. Do not turn compliance and delivery mechanics into prompts.

DIAGRAM 10How a goal reaches resolution
Subject resultsSuccessful, partial, stopped, failed, superseded, or needs attention
Settlement checkNo required action, approval, dependency, or wait remains
Goal rulesAll resolved, target met, deadline reached, budget spent, or human stop
AssessmentEvidence-backed outcome and unresolved exceptions
Final reportBusiness result, system changes, costs, failures, and audit links

Technical shape, after the system model

What happens. Samora adds a goal control plane above current services. Temporal owns durable progression. PostgreSQL owns product and audit facts. A private OpenAI Agents SDK runtime performs one bounded reasoning turn. A fixed gate converts allowed proposals into durable work. Existing services execute it.

Why. Samora already has useful service APIs, durable contact workflows, timers, signals, retries, dispatch leases, provider correlation, human queues, and permission checks. Replacing those would create competing sources of truth.

Chat and goal APIAccept objectives and directives. Stream safe status, questions, approvals, evidence, and results. The chat is a control view, not the process.
Goal serviceCompile and version contracts. Resolve typed resources, authority, conflicts, budget, and completion rules.
Temporal workflowsOwn goal and subject lifecycle, signals, timers, retries, cancellation, fan-out, fan-in, and reactivation.
Context builderCreate a bounded, redacted, versioned decision snapshot from product facts and goal state.
OpenAI decision runtimeRun one manager agent turn, optional specialist agents, read tools, guardrails, and structured output.
Policy and capability gateRecheck permissions, scope, risk, versions, conflicts, limits, approvals, and repeat protection.
Work and action layerWrite work first. Workers call existing Samora APIs, dispatchers, providers, and human operations.
Event and audit layerStore normalized events, decisions, attempts, receipts, approvals, costs, and resolution evidence.

OpenAI boundary

The Agents SDK is the reasoning loop inside one activity. It is not the day-scale scheduler, database, authorization service, event bus, or provider executor. SDK session or resume state is a convenience checkpoint. It never replaces Samora's canonical records.

Read the implementation specificationConcrete services, contracts, proposed tables, SDK mapping, tool gateway, Temporal sequences, failure rules, security, tests, and rollout.

Open-source and existing-system evaluation

What happens. Existing projects can supply orchestration, agent loops, UI events, or tool protocols. None supplies Samora's complete product truth, workspace policy, channels, human lifecycle, and audit model.

Why. Selecting an "agent framework" by name can hide the hard requirements: durable events, event or deadline races, exactly-once intent, cross-goal conflicts, authorization, and business completion.

Temporal

Official project information

What it solves

Durable workflows, timers, signals, retries, cancellation, and history.

What it covers here

The long-lived goal coordinator and logical subject workflows for the resources being changed or observed. Samora already uses it.

What Samora still builds

Goal records, context, decisions, policy, capability discovery, product audit views, and Samora domain semantics.

Verdict and constraint

Best foundation. Keep it as the only lifecycle scheduler. A second scheduler would split timer and retry ownership.

OpenAI Agents SDK

Official project information

What it solves

A model-driven agent loop with tools, handoffs, guardrails, sessions, and tracing helpers.

What it covers here

One bounded decision turn, specialist delegation, structured tool use, and handoff patterns.

What Samora still builds

Days-long business continuity, event inbox, timers, product state, tenant authorization, duplicate-action controls, and Samora domain records.

Verdict and constraint

Useful inside the decision service. It is not the durable goal runtime. Samora still owns storage, deployment, tools, approvals, and execution.

LangGraph

Official project information

What it solves

A stateful Python or TypeScript graph for agent reasoning, checkpoints, and human interrupts.

What it covers here

Complex reasoning inside one decision turn or a specialist analysis sidecar.

What Samora still builds

The product ledger, provider action safety, workspace policy, and current Temporal lifecycle.

Verdict and constraint

Optional sidecar. Do not let it become a second scheduler for the same subject.

Hatchet

Official project information

What it solves

A task and agent orchestration service with durable waits, events, retries, concurrency, rate limits, and a web view.

What it covers here

Most orchestration mechanics in a greenfield product.

What Samora still builds

Samora-specific product truth, policy, channels, and migration from current Temporal histories.

Verdict and constraint

Strong greenfield alternative. In Samora it duplicates an existing runtime, so adoption would be a migration project.

Restate

Official project information

What it solves

Durable execution, stateful services, events, timers, retries, and introspection.

What it covers here

A different durable base with a good Go fit.

What Samora still builds

All Samora domain semantics, policy, UI, and a safe migration from Temporal. License terms also need review.

Verdict and constraint

Technically credible alternative, not an additive component. Do not run both for the same subject.

MCP

Official project information

What it solves

A standard protocol for exposing tools and context to a model client.

What it covers here

A capability adapter for approved Samora tools such as read contact, draft reply, or request handoff.

What Samora still builds

Scheduling, durable state, audit, policy, event correlation, waiting, and memory.

Verdict and constraint

Use for tool interoperability if useful. Never mistake it for the machine.

AG-UI

Official project information

What it solves

An event protocol between agent backends and interactive user interfaces.

What it covers here

Streaming goal progress, work updates, approvals, and tool results to the chat control surface.

What Samora still builds

The canonical database, scheduler, authorization, and provider execution.

Verdict and constraint

Optional transport. It can make the system visible but cannot keep it alive.

Codex as a product analogy

Official subagent guide
Official long-running work guide

What it solves

A chat-led workspace where a coordinating agent uses tools, delegates bounded work to subagents, asks for approval, and reports results.

What it covers here

The user mental model for goals, task trees, specialist workers, permissions, and visible artifacts.

What Samora still builds

Real-world product and customer events, day-scale waits, provider callbacks, consent, cross-goal conflict control, and CRM truth.

Verdict and constraint

Copy the interaction contract, not the coding runtime. Codex is an analogy, not Samora's lifecycle engine.

Hermes Agent

Official project information

What it solves

A personal agent loop with tools, skills, memory, subagents, scheduled jobs, and messaging gateways.

What it covers here

A sandboxed operator assistant, research helper, or reference for bounded subagent delegation.

What Samora still builds

Multi-tenant goal state, reliable event waits, provider dedupe, fixed policy, business records, and product audit.

Verdict and constraint

Useful for experiments. Do not give it permanent subject ownership or direct provider credentials.

CrewAI

Official project information

What it solves

Role-based agent crews, tools, and event-driven flows for coordinated model work.

What it covers here

Offline experiments, message drafting, research, or a bounded decision-sidecar implementation.

What Samora still builds

Durable timers, provider action safety, tenant policy, product truth, event correlation, and the complete lifecycle.

Verdict and constraint

Use for evaluation or specialist reasoning, not as the lead runtime.

n8n

Official project information

What it solves

Visual integration workflows, connectors, webhooks, schedules, scripts, and internal automation.

What it covers here

One-off integrations, back-office glue, and low-risk operator automation.

What Samora still builds

The authoritative per-subject runtime, event truth, conflict rules, policy, and compliant action ledger.

Verdict and constraint

Keep it at the edge. Its separate runtime and source-available license make it a poor lifecycle owner.

Windmill

Official project information

What it solves

Scripts, jobs, flows, schedules, webhooks, forms, and internal operational tools.

What it covers here

Reconciliation utilities, admin tools, data repair, and isolated integration jobs.

What Samora still builds

Goal and subject continuity, event correlation, provider idempotency, product authorization, and audit truth.

Verdict and constraint

Useful for internal tooling. Do not add its scheduler to the same subject lifecycle without a migration decision and license review.

Recommended combination

Keep Temporal as the durable owner. Add the goal and subject records in PostgreSQL. Put a typed decision service behind a Temporal activity. Reuse existing Samora action paths and human queues. Add inbox and outbox records, reconciliation, a capability registry, fixed policy, and a product-safe event stream. Use the OpenAI Agents SDK only for bounded reasoning turns. Keep every durable wait, business record, authorization decision, and external side effect under Samora control. The separate technical specification gives the exact boundary.

What this feels like through chat

What happens. The user talks to one goal thread while a visible work tree changes below it. Samora shows what it understood, what it will touch, what is running, why it is waiting, which decision needs a person, and how the goal ended.

Why. A Codex-like experience comes from persistent goals, tools, task state, evidence, approvals, and bounded specialists. It does not require a model process to remain alive.

Configure and launch

User
  "Prepare a renewal agent for WhatsApp and web chat. Use the new pricing guide.
   Run a test. If it passes, launch the September renewal campaign."

Samora
  stores Goal v1 and resolves the named agent, channels, document, workflow,
  campaign draft, permissions, current versions, and approval policy
  -> creates dependent runs for agent config, knowledge, test, and campaign
  -> an SDK turn proposes an instruction diff and document attachment
  -> fixed policy requires approval for customer-facing instruction change

User approves
  -> Samora rechecks versions and applies through existing agent and KBase APIs
  -> waits for knowledge indexing event or deadline
  -> runs a test conversation through the approved tool set
  -> evaluates the recorded test result
  -> asks for launch approval if policy requires it
  -> launches through the existing campaign service
  -> waits on campaign events and reports completion

Investigate and recover

User
  "Find why yesterday's campaign stalled. Retry only safe failures."

Samora
  resolves the campaign and affected workflow executions
  -> reads node events, provider results, dispatch attempts, and current state
  -> specialist agents classify failure patterns without changing anything
  -> manager proposes a recovery set with evidence and exclusions
  -> policy blocks unknown provider outcomes and destructive resets
  -> approved retry work uses existing workflow retry paths
  -> Samora waits for new results, then reports recovered and unresolved cases

Work a lead cohort

User
  "Qualify these 100 contacts and hand interested people to sales."

Samora
  creates one goal and independent opportunity or contact runs
  -> each run can send, call, wait, answer, stop, or ask for a person
  -> inbound events wake only affected runs
  -> contact and channel conflict keys prevent duplicate outreach
  -> the goal aggregates results without placing 100 histories in one prompt
  -> final report separates interested, handed off, unreachable, opted out,
     failed, and unresolved outcomes

Information the user should always be able to ask for

  • "What did you understand, and what are you allowed to change?"
  • "What is running, waiting, blocked, or finished?"
  • "Why did you choose this action, and which evidence did you use?"
  • "Which rows or external systems changed?"
  • "What requires my approval?"
  • "Stop, revise the objective, or undo what is safely reversible."

Decision and delivery record

What happened. This cycle broadened the model from lead conversion to authorized work across Samora and produced a separate OpenAI Agents SDK technical specification. It did not implement the runtime or change product data.

Decision

Build a general goal control plane. A goal scopes typed Samora subjects. Durable workflows own continuity. Short-lived agent turns propose next work. Fixed policy and existing services own execution.

Alternatives rejected

A lead-only runtime, permanent model ownership, one giant workspace agent, raw model access to providers or SQL, a rigid generated workflow, and a second scheduler beside Temporal.

Trade-offs

The system needs explicit records, version checks, event correlation, and a capability gateway. That cost buys recovery, audit, safe concurrency, and human control.

What changed

This report, the new technical specification, the report hub, and the two Markdown source-of-truth files. The full-server-URL rule was already present in AGENTS.md and CLAUDE.md, so it was verified rather than duplicated.

What did not change

No Samora product source, dependency, database row, Activity row, provider, campaign, workflow execution, firewall, DNS record, or public-ingress rule changed.

Deployment boundary

The team site contains only an index and the two architecture documents. Repository source and the rest of the local report archive are not published. Deployed copies show file-path citations as text.

Recovery

For the repository, remove the new report card and technical-spec file, then restore this report and the appended Markdown entries. For Pages, roll back to a prior successful production deployment in the dashboard or delete the isolated project.

Acceptance

Both reports must pass link, citation, HTML, responsive, and HTTP checks. The workspace quiz gate then requires at least 80%.

Primary local evidence

  • Frontend product routes: samora-fe/src/app.tsx:216-880
  • Agent operations: samora-be/services/agent_service/init.go:20-48
  • Tool operations: samora-be/services/tools_service/init.go:18-40
  • Knowledge operations: samora-be/services/kbase_service/init.go:20-65
  • Integration operations: samora-be/services/integrations_service/init.go:39-61
  • Contact workflows: samora-workflows/internal/workflows/contact.go:180-840
  • Inbound correlation: samora-workflows/internal/triggers/router.go:927-1093
  • Workflow records: samora-be/database/schemas/workflows.sql:1-255
  • Human operations: samora-be/services/human_operations_service/dispatch.go:173-767
  • Realtime broker: samora-be/services/realtime_service/broker.go:21-64,122-203

Mandatory understanding quiz

Status: not accepted. Score: 0/8 pending. A passing score is 7/8.

Reply with answers numbered 1 through 8. The session stays open until the answers pass.

What is the thing that stays alive for days or weeks?

Your answer: pending.
Correct answer

The durable goal workflow and its stored subject runs, events, work, waits, approvals, and results. A model process does not stay running.

Why is a lead no longer the main runtime object?

Your answer: pending.
Correct answer

Samora must also operate agents, tools, knowledge, integrations, campaigns, workflows, conversations, queues, and reports. A typed subject can represent any of them. A lead or opportunity is one subject type.

A four-hour wait exists, but a matching event arrives after ten minutes. What happens?

Your answer: pending.
Correct answer

Store and deduplicate the event, correlate it, satisfy or supersede the wait, signal the durable run, rebuild current context, and decide again. Do not wait the remaining time.

Why must understanding, deciding, authorizing, and executing stay separate?

Your answer: pending.
Correct answer

They have different evidence, retry, security, and audit needs. A model may interpret and propose, but fixed code must authorize and existing services must perform side effects.

What survives when an SDK worker disappears?

Your answer: pending.
Correct answer

The goal and revisions, resource scope, subject runs, events, context references, decisions, work, dependencies, waits, attempts, approvals, policy and capability versions, and resolution state.

What role does the OpenAI Agents SDK play?

Your answer: pending.
Correct answer

It runs one bounded reasoning turn with tools, specialists, guardrails, and structured output. It does not own long-lived scheduling, product truth, authorization, or provider side effects.

Two goals try to edit the same agent version. What prevents contradictory writes?

Your answer: pending.
Correct answer

A resource-operation conflict key, expected resource version, serialized subject decision, current permission check, and repeat-protection key. A mismatch forces a fresh decision or human choice.

What should Samora reuse, and what must it add?

Your answer: pending.
Correct answer

Reuse Temporal, PostgreSQL domain records, current services, dispatchers, provider adapters, conversations, human queues, auth, and configuration. Add goal and subject state, the event ledger, context builder, SDK decision runtime, capability and policy gate, dynamic work, waits, approvals, conflict control, and completion logic.