yttcom.net · CAI Document Library
↓ Download MD
▶ READING Initializing...
Architecture · Proposal · Admin [00]

CAI Synchronous Communication Backbone

Date: 07/18/26 Author: Admin [00] + USR369 Version: v1.0 File: CAI-SYNC-COMMS.md Proposal — Pending Approval
Contents
The Problem What Real Systems Do What CAI Has Today The Design Layer 1 — Registry Layer 2 — Format Layer 3 — Token Layer 4 — Router Layer 5 — Circuit Breaker Layer 6 — Traffic Log Before & After Build Order What This Is Not Risks Open Questions Approval

The Problem — Plainly Stated

CAI has 11 systems. They don't actually talk to each other.

What exists today is a shared inbox that the AI reads manually each session and carries information between systems in conversation. That is not inter-system communication. That is a human-shaped messenger doing what code should do.

The result: information arrives late, gets dropped, or requires David to be in the loop for things that should resolve automatically.

What Real Systems Do

Synchronous inter-service communication means:

This is called REST/RPC (Remote Procedure Call). It is the backbone of how Netflix, Amazon, and every modern distributed system works.

Key rule from the research: Never use synchronous chains deeper than 2 hops. Cascading timeouts create failures worse than a monolith. For CAI: System A calls System B. System B does NOT then call System C to answer.

What CAI Has Today — Honest Assessment

TypeItemStatus
StrengthEach system has its own api.php — a real service endpointEXISTS
StrengthCommunity inbox — IS a message bus (async)EXISTS
StrengthTransfers API — inter-system data passingEXISTS
Strengthrecords.db — shared ledger, correct patternEXISTS
WeaknessNo system can call another system's api.php directlyMISSING
WeaknessNo system knows where the other systems' endpoints areMISSING
WeaknessNo standard request/response format between systemsMISSING
WeaknessNo circuit breaker — if one system is down, callers hangMISSING
WeaknessThe inbox is async and the AI is the only consumer acting on itMISSING

The Design — CAI Synchronous Backbone

Layer 1 — Service Registry (the directory)

Every system registers itself: who it is, where its api.php lives, what actions it accepts, and whether it is up. This already partially exists as jurisdiction.db — we extend it into a live service registry.

Table: service_registry
Columns: decade, system_name, api_endpoint, status, last_ping, actions[]

Owner:    Admin [00]
Location: systems/community/registry/api.php

A system that doesn't know where Finance [60] lives asks the registry. The registry answers. No hardcoded URLs between systems.

Layer 2 — Standard Request Format (the language)

Every inter-system call uses the same envelope:

{
  "action":       "inter_system_request",
  "from_system":  "80",
  "to_system":    "60",
  "request_type": "get_balance",
  "payload":      { ... },
  "token":        "[inter-system token]",
  "request_id":   "uuid"
}

Response:
{
  "status":      "ok" | "error",
  "from_system": "60",
  "request_id":  "uuid",
  "data":        { ... },
  "timestamp":   "..."
}

Owner: Server [40] — add inter_system_request handler to all api.php files.

Layer 3 — Inter-System Token (security)

Today each system has its own token. System-to-system calls need a shared token that is not the owner token (USR369's token).

Owner: Admin [00] — generate and distribute via Server [40].

Layer 4 — The Router (the switchboard)

A single PHP endpoint that any system can POST to with a destination and payload. The router looks up the destination in the registry, forwards the request, and returns the response.

Location: systems/community/router/router.php
Owner:    Server [40] to build, Admin [00] to own

Why a router and not direct calls?

Kitchen [80] router.php Finance [60] response router.php Kitchen [80]

Layer 5 — Circuit Breaker (failure protection)

If Finance [60] is down, Kitchen [80] shouldn't hang waiting. The router tracks failure counts per system. After 3 failures: mark system unavailable, return error immediately, log to Admin [00] inbox.

Simple implementation: router tracks per-decade fail counts in SQLite. Reset on next successful call. No external library needed — approximately 20 lines of PHP.

Layer 6 — Traffic Log (visibility)

Every inter-system call gets logged: who called who, what action, response status, response time in ms, and timestamp.

Location: systems/community/router/traffic.db
Viewer:   backend/sys-com/traffic.html (Admin [00] to build)

This solves a problem that exists today: when something goes wrong between systems, nobody can see what happened. The log makes it visible.

How This Changes the Platform

Before (today)

Kitchen [80] needs a budget check from Finance [60]
Kitchen drops a message to inbox
David opens a session
AI reads the inbox
AI carries the question to Finance manually
Finance answers in conversation
AI reports back to Kitchen in conversation

After (with backbone)

Kitchen [80] needs a budget check from Finance [60]
Kitchen's api.php calls router.php
Router looks up Finance [60] endpoint in registry
Router POSTs to Finance api.php
Finance returns balance JSON
Router returns it to Kitchen
Kitchen has the answer in under 500ms
Everything logged automatically

David is not in the loop. The AI is not the messenger. It just works.

Build Order — Task List

These are proposed tasks. Master [10] assigns. Nothing starts until USR369 approves this document.

Phase 1 — Foundation

TaskOwnerDescription
T-NEW-AAdmin [00]Extend jurisdiction.db into service_registry — add api_endpoint, status, last_ping, supported_actions — seed all 11 systems
T-NEW-BServer [40]Generate inter-system token — store in Server config — distribute to all 11 system configs
T-NEW-CServer [40]Add inter_system_request handler stub to all 11 api.php files — stub returns ok — proves format works end to end

Phase 2 — The Router

TaskOwnerDescription
T-NEW-DServer [40]Build router.php — accepts from/to/action/payload/token — looks up registry — forwards via curl — returns response — logs to traffic.db
T-NEW-EAdmin [00]Build circuit breaker in router.php — per-decade fail counts — short-circuit after 3 — notify Admin inbox
T-NEW-FAdmin [00]Build traffic viewer at backend/sys-com/traffic.html — timestamp / from / to / action / status / ms

Phase 3 — First Real Use Cases

TaskOwnerDescription
T-NEW-GFinance [60] + Kitchen [80]Kitchen requests budget summary from Finance — action: get_category_budget
T-NEW-HMaster [10] + records.dbAny system requests its task list via router instead of hitting records-api.php directly
T-NEW-IAdmin [00]Health check on session open — Admin pings all 11 via router — replaces manual checks

Phase 4 — Reduce Inbox Noise

TaskOwnerDescription
T-NEW-JAdmin [00]Audit inbox message types — retire workaround types as sync calls replace them one by one

What This Is Not

Risks

Tight coupling: Synchronous calls mean if the router is down, inter-system calls fail. Mitigated by circuit breaker + fallback to current inbox method during outage.

Scope creep: Phase 3 use cases could multiply. Rule: only wire calls that TODAY require the AI to manually carry information. Everything else stays async until proven necessary.

Token security: Inter-system token must never appear in frontend JS. All calls are server-to-server only.

Open Questions for David

  1. Do you want the router to log to traffic.db automatically, or only on errors?
  2. The inter-system token — do you want it in NordPass like the other tokens, or managed differently?
  3. Phase 3 use cases — are those the right first wires, or do you have higher-priority cross-system needs?

Approval

This document requires USR369 approval before any build begins.

Approved by USR369
Assigned to Master [10] for task distribution
T-NEW-A through T-NEW-J added to records.db
Build start authorized