L0.5 Operating Layer Wiring Plan
Created: 2026-06-09
Status: IN PROGRESS
Authority: Nirmal (Founder) approval required for deployment
Executive Summary
This document outlines the systematic wiring of the L0.5 Operating Layer (Cloudflare Durable Execution substrate) to transform IntegrateWise from a reactive application into an autonomous operating system.
L0.5 Components:
- Cloudflare Workflows → Durable, multi-step, stateful execution
- Cloudflare Queues → Async processing with guaranteed delivery + DLQs
- Cron Triggers → Scheduled, policy-bounded automation
- Durable Objects → Stateful long-lived coordination (HITL gates, watchers)
Current State Analysis (Updated 2026-06-09 Phase 2)
✅ CONNECTED (Working)
pipeline-processqueue →integratewise-pipelineconsumersignalsqueue →integratewise-intelligenceconsumerintelligence-eventsqueue →integratewise-intelligenceconsumerknowledge-ingestqueue →integratewise-knowledgeconsumermemory-consolidation→integratewise-knowledgeconsumerops-dlq→integratewise-intelligenceconsumerconnector-syncqueue →connector-syncconsumer (webhook-driven + hourly cron)intelligence-actqueue → producer binding added (Phase 2) ✅
⚠️ NEEDS MANUAL WIRING (Phase 2 Code Deployed)
continuity-triagequeue → consumer code deployed, needs Dashboard wiring ⏳
⚠️ CRON GAPS
connector-sync: Was 6 hours, needs webhook-driven (hourly backup)continuity: Has handler, missing morning brief + backup cronsintelligence: No cron for morning brief or signal sweeps
⚠️ MISSING WORKFLOWS
TriageWorkflow→ exists in code, needs activationSyncWorkflow→ missing, needed for connector deltaSignalWorkflow→ missing, needed for spine→signal automationMorningBriefWorkflow→ missing, needed for 7am briefActWorkflow→ missing, needed for approved→execute
TASK 1: FIX CRON TRIGGERS
1.1 connector-sync: Hourly + Webhook-Driven
File: services/connector-sync/wrangler.toml
Change:
# OLD
# crons = ["0 */6 * * *"] # Every 6 hours
# NEW
[triggers]
crons = ["0 * * * *"] # Every hour (backup sweep)
# Real-time syncs triggered by Nango webhooks at /webhooks/nango
Rationale: Nango webhooks (/webhooks/nango) provide real-time sync triggers. Hourly cron is backup sweep for missed events.
Status: ✅ DONE
1.2 continuity: Morning Brief + Daily Backup
File: services/continuity/wrangler.toml
Change:
# OLD
[triggers]
crons = ["0 */6 * * *"] # TTL cleanup only
# NEW
[triggers]
crons = [
"0 7 * * *", # Morning brief at 7am
"0 0 * * *", # Daily reindex + backup at midnight
"0 */6 * * *" # TTL cleanup every 6 hours
]
Handler Logic:
async scheduled(event: ScheduledEvent, env: Env): Promise<void> {
const cron = event.cron;
if (cron === "0 7 * * *") {
// Morning brief: trigger MorningBriefWorkflow
// TODO: Wire to WORKFLOW service binding
}
else if (cron === "0 0 * * *") {
// Daily backup: D1 → R2 + Vectorize reindex
// TODO: Replace with AI Search (PRIORITY 4)
}
else if (cron === "0 */6 * * *") {
// TTL cleanup (existing)
await handleScheduled(event, env);
}
}
Status: ✅ DONE (wrangler.toml), ⏳ PENDING (handler impl)
1.3 intelligence: Morning Brief + Signal Sweep
File: services/intelligence/wrangler.toml
Change:
# NEW
[triggers]
crons = [
"0 7 * * *", # Morning brief at 7am
"0 */6 * * *" # Signal analysis sweep every 6 hours
]
Status: ✅ DONE
TASK 2: FIX QUEUE WIRING
2.1 continuity-triage Queue
Problem: Producers exist (20), no consumer wired
Solution: Add consumer to continuity worker
File: services/continuity/wrangler.toml
[[queues.consumers]]
queue = "continuity-triage"
max_batch_size = 10
max_batch_timeout = 30
Status: ⏳ PENDING
2.2 intelligence-act Queue
Problem: Consumer exists (intelligence), nothing produces to it
Solution: Wire Act service to publish to queue after HITL approval
File: services/intelligence/src/act/*.ts
// After HITL approval in govern flow:
await env.INTELLIGENCE_ACT_QUEUE.send({
action_id: proposal.id,
action_type: proposal.action_type,
tenant_id: proposal.tenant_id,
approved_by: approval.user_id,
approved_at: new Date().toISOString(),
});
Status: ⏳ PENDING (needs queue producer binding)
2.3 connector-sync Queue
Problem: Consumer exists, nothing produces
Solution: Nango webhook handler triggers sync jobs
File: services/webhook-ingress/src/index.ts
Already wired! Nango webhook handler sends to connector-sync queue:
if (eventType === "connection.created" || eventType === "sync.success") {
await env.CONNECTOR_SYNC_QUEUE.send({
tenant_id: tenantId,
provider: provider,
sync_type: "delta",
triggered_by: "webhook",
});
}
Status: ✅ ALREADY WIRED (verify producer binding exists)
2.4 execution-outcomes Queue
Problem: Completely disconnected (0 producers, 0 consumers)
Decision:
- Option A: Delete the queue (unused)
- Option B: Wire to Act service for execution tracking
Recommendation: DELETE - execution tracking happens via D1 action_executions table
Status: ⏳ PENDING DECISION
TASK 3: CREATE AI SEARCH INSTANCE
3.1 Current L4 Library Architecture
Current Flow:
Knowledge content → R2 bucket → Manual vectorization → Vectorize index → D1 cache
Problems:
- Manual indexing required
- No built-in search API
- No MCP endpoint
- No chat completions interface
3.2 AI Search Migration
New Flow:
Knowledge content → AI Search index → /search API + /chat/completions + MCP
Benefits:
- Managed indexing (auto-sync from R2/D1)
- Built-in search and chat APIs
- MCP-compatible endpoint
- Versioning and rollback
- Hybrid search (vector + keyword)
3.3 Implementation Steps
Step 1: Create AI Search Index
wrangler ai-search create integratewise-knowledge \
--namespace=knowledge \
--description="IntegrateWise L4 Library - org_memory + KB" \
--embedding-model=@cf/baai/bge-base-en-v1.5
Step 2: Wire to Knowledge Worker
File: services/knowledge/wrangler.toml
[[ai_search_namespaces]]
binding = "AI_SEARCH"
namespace = "integratewise-knowledge"
Step 3: Migrate Content
// Bulk upload from existing org_memory
const documents = await fetchOrgMemory();
await env.AI_SEARCH.upsert(
documents.map((doc) => ({
id: doc.id,
text: doc.content_md,
metadata: {
title: doc.title,
tags: doc.tags,
topics: doc.topics,
governance_state: doc.governance_state,
},
}))
);
Step 4: Update Search Endpoints
File: services/knowledge/src/index.ts
// OLD: Manual Vectorize query
app.get("/search", async (c) => {
const results = await vectorizeQuery(c.env.VECTOR_INDEX, query);
// ...
});
// NEW: AI Search API
app.get("/search", async (c) => {
const results = await c.env.AI_SEARCH.search(query, {
limit: 10,
includeVectors: false,
});
// ...
});
Status: ⏳ PENDING (AI Search in beta, verify availability)
TASK 4: DEPLOY MISSING WORKFLOWS
4.1 TriageWorkflow
Status: ✅ EXISTS in services/intelligence/src/workflows/triage-workflow.ts
Binding: ✅ ALREADY CONFIGURED in intelligence/wrangler.toml
Action: Verify it's being invoked correctly
4.2 Missing Workflows
MorningBriefWorkflow
- Purpose: Generate 7am brief for /desk
- Triggers: 7am cron (continuity, intelligence)
- Steps:
- Fetch overnight signals
- Query Entity 360 changes
- Generate brief via AI
- Store in D1 cache
- Broadcast to connected clients
Status: ⏳ TODO
SignalWorkflow
- Purpose: Spine change → signal generation → broadcast
- Triggers: Pipeline writes, hourly sweep
- Steps:
- Detect spine changes
- Run signal analyzer
- Create signal records
- Broadcast to workspaces
Status: ⏳ TODO
ActWorkflow
- Purpose: Approved proposal → execute action
- Triggers: HITL approval, intelligence-act queue
- Steps:
- Fetch approved proposal
- Resolve target tool
- Execute via connector
- Track outcome
- Update proposal status
Status: ⏳ TODO
Deployment Sequence
Phase 1: Cron Fixes (Safe, No Breaking Changes) — ✅ DEPLOYED
- ✅ connector-sync: hourly cron (wrangler.toml)
- ✅ continuity: +7am, +midnight crons (wrangler.toml)
- ✅ intelligence: +7am, +6h crons (wrangler.toml)
- ✅ Implement continuity scheduled handler
- ✅ Implement intelligence scheduled handler
- ✅ DEPLOYED 2026-06-09 (manual cron wiring required via Dashboard)
Phase 2: Queue Wiring (Requires Testing) — ✅ DEPLOYED
- ✅ Add continuity-triage consumer (wrangler.toml + handler)
- ✅ Wire intelligence-act producer binding
- ✅ Verify connector-sync webhook flow (already wired)
- ✅ Delete execution-outcomes queue (done)
- ✅ DEPLOYED 2026-06-09 (manual queue consumer wiring required via Dashboard)
See: L05_PHASE2_DEPLOYMENT_SUMMARY.md for full deployment details.
Phase 3: AI Search (Requires Beta Access) — ⏳ NEXT
- Add continuity-triage consumer
- Wire intelligence-act producer
- Verify connector-sync webhook flow
- Delete execution-outcomes queue
- Deploy + test each queue independently
Phase 3: AI Search (Requires Beta Access)
- Create AI Search index
- Bulk upload org_memory content
- Update search endpoints
- Test MCP integration
- Deprecate manual Vectorize flow
Phase 4: Workflows (Requires Development)
- Implement MorningBriefWorkflow
- Implement SignalWorkflow
- Implement ActWorkflow
- Wire cron triggers
- Test durable execution + retries
Verification Commands
Check Deployed Crons
wrangler deployments list --name integratewise-connector-sync
wrangler deployments list --name continuity
wrangler deployments list --name intelligence
List Queues
wrangler queues list
Check Queue Consumers
wrangler queues consumer list continuity-triage
wrangler queues consumer list intelligence-act
Test Webhook Flow
curl -X POST 'https://ingress.dev.integratewise.ai/webhooks/nango' \
-H 'Content-Type: application/json' \
-d '{"type":"sync.success","connectionId":"iw-customer-zero","provider":"hubspot"}'
Success Criteria
L0.5 Fully Operational When:
- ✅ All cron triggers deployed and running
- ✅ All queue consumers wired with producers
- ✅ Workflows executing durably with retries
- ✅ AI Search replacing manual vectorization
- ✅ Morning brief generated daily at 7am
- ✅ Signal analysis sweep running every 6 hours
- ✅ Connector sync webhook-driven with hourly backup
- ✅ Act workflow executing approved proposals
Next Actions
PHASE 1 COMPLETE — READY FOR DEPLOYMENT:
All Phase 1 code changes are complete:
- ✅ Cron triggers added to wrangler.toml files (connector-sync, continuity, intelligence)
- ✅ Continuity scheduled handler implemented (7am brief, midnight backup, 6h cleanup)
- ✅ Intelligence scheduled handler implemented (7am brief, 6h signal sweep)
AWAITING NIRMAL APPROVAL TO DEPLOY:
# Unset Cloudflare API token (critical - see AGENTS.md Hard Rules)
unset CLOUDFLARE_API_TOKEN
# Deploy Phase 1 changes
wrangler deploy --env="" services/connector-sync
wrangler deploy --env="" services/continuity
wrangler deploy --env="" services/intelligence
AFTER PHASE 1 DEPLOYMENT:
- Monitor cron triggers in Cloudflare dashboard
- Verify scheduled handlers execute correctly
- Proceed to Phase 2: Queue Wiring
PHASE 2 QUEUE WIRING (After Phase 1 approval):
- Add continuity-triage consumer
- Wire intelligence-act producer
- Verify connector-sync webhook flow
- Delete execution-outcomes queue
PHASE 3 AI SEARCH (After Phase 2):
- Request AI Search beta access
- Create AI Search index
- Bulk upload org_memory content
- Update search endpoints
PHASE 4 WORKFLOWS (After Phase 3):
- Develop MorningBriefWorkflow
- Develop SignalWorkflow
- Develop ActWorkflow
- Wire workflow triggers
Document Status: Phase 1 READY FOR DEPLOYMENT
Last Updated: 2026-06-09T13:15:00Z
Next Review: After Phase 1 deployment + monitoring