SoulInPsyAbstract's picture
Initial: SYNTAX AI Community Channel spec v1.1
f62848d
|
Raw
History Blame Contribute Delete
5.63 kB

SYNTAX Channel β€” Technical Specification

Version: 1.1 Β· Status: SPEC Β· Phase: personal sandbox


1. Architecture

SYNTAX_CHANNEL/
β”œβ”€β”€ BROADCAST/              ← all agents read (alerts, system-wide)
β”‚   └── cursor.<agent>      ← per-agent read-only cursor
β”œβ”€β”€ <AGENT_NAME>/            ← per-agent inbox
β”‚   └── msg_<seq>.json      ← atomic files: temp write β†’ mv
β”œβ”€β”€ ARCHIVE/                 ← processed messages
β”‚   └── <agent>/
β”‚       └── YYYY-MM-DD/
β”‚           └── msg_<seq>.json
β”œβ”€β”€ MANIFEST/                ← per-agent hash-chain
β”‚   └── <agent>.sha256chain
└── BOOTSTRAP.sh             ← cold-start script

Design decisions:

  • ❌ JSONL with concurrent writes β†’ βœ… atomic files (temp write + mv)
  • ❌ Single MANIFEST β†’ βœ… per-agent MANIFEST with hash-chain
  • ❌ Cursor via mv β†’ βœ… read-only cursor in BROADCAST
  • βœ… status: pending|processing|done
  • βœ… Bootstrap-scan at startup for persistent agents

2. Agents

Persistent (inotify-push)

inotifywait on own INBOX. Instant reaction.

Agent Role
Gateway External interface (Telegram, etc.)
GUARDIAN Channel health monitoring
Orchestrator Task distribution
SPHERE Long-term memory / context

On-demand (pull-at-start)

Read INBOX at session start, execute, terminate.

Agent Role
Coder Code generation
Worker Compute tasks (fine-tune, etc.)
Executor Command execution
Human Decision-making via external interface

3. Message Format

{
  "id": "uuid_v7",
  "seq": 42,
  "from": "agent_name",
  "to": "agent_name | BROADCAST",
  "type": "task | alert | response | heartbeat",
  "status": "pending | processing | done",
  "ref": "sha256_of_related_artifact | null",
  "reply_to": "uuid | null",
  "payload": "text or structured data",
  "chain_prev": "sha256 | null",
  "timestamp": "2026-07-30T12:00:00+03:00",
  "sha256": "hash_of_this_message"
}
Field Purpose
status pending β†’ unread; processing β†’ in work; done β†’ processed
seq Monotonic per-agent counter
chain_prev SHA256 of agent's previous message β€” hash chain

4. Atomic Write

CRITICAL: temp file + mv. Never write directly to INBOX.

TEMP=$(mktemp ${SYNTAX_CHANNEL}/${TARGET}/.tmp_msg_XXXXXX)
echo "$JSON" > "$TEMP"
mv "$TEMP" "${SYNTAX_CHANNEL}/${TARGET}/msg_${SEQ}.json"

Guarantees:

  • mv on same filesystem is atomic in POSIX
  • Reader sees either nothing or complete file
  • No broken JSONL lines

5. Bootstrap-scan

Persistent agents on startup (reboot, crash, deploy):

LAST_SEQ=$(tail -1 MANIFEST/GUARDIAN.sha256chain | cut -d' ' -f1)

for msg in INBOX/GUARDIAN/msg_*.json; do
    SEQ=$(echo "$msg" | grep -oP 'msg_\K\d+')
    if [ "$SEQ" -gt "$LAST_SEQ" ]; then
        process "$msg"
    fi
done

6. Per-agent Hash Chain

One file per agent. No contention.

Format: MANIFEST/<agent>.sha256chain

42|550e8400-e29b-41d4-a716-446655440000|a1b2c3...def|2026-07-30T12:00:00+03:00
43|550e8400-e29b-41d4-a716-446655440001|e4f5g6...hij|2026-07-30T12:00:01+03:00

Fields: seq|msg_id|sha256|timestamp

Each message links to SHA256 of previous (chain_prev). GUARDIAN verifies chain integrity every N minutes. Break = alert.


7. Routing

Sender:
  1. Increment own seq
  2. Compute chain_prev = sha256 of previous message
  3. Build JSON
  4. Compute sha256 of entire message
  5. Atomic write to INBOX/<target>/msg_<seq>.json
  6. Append line to MANIFEST/<agent>.sha256chain

Persistent receiver:
  β†’ inotifywait triggers processing
  β†’ status β†’ "processing"
  β†’ after processing: mv to ARCHIVE/<agent>/YYYY-MM-DD/
  β†’ status β†’ "done" (written to archive copy)

On-demand receiver:
  β†’ At startup: read INBOX/<name>/ (all pending)
  β†’ status β†’ "processing" (in-place file update)
  β†’ Process
  β†’ status β†’ "done"
  β†’ mv to ARCHIVE/

8. BROADCAST

BROADCAST is never cleaned by receivers:

  • Each agent maintains read-only cursor: BROADCAST/cursor.<agent> β€” last read msg_id
  • On read: only messages newer than cursor
  • Cleanup: cron hourly removes messages >24h old, read by ALL active agents
  • expires_at (optional) for heartbeats β€” auto-cleanup without cursor check

9. GUARDIAN β€” Health Monitoring

  • Verify hash chains of all agents (every 5 minutes)
  • Detect seq gaps (missed messages)
  • Monitor INBOX size (alert if >100 pending per agent)
  • Monitor BROADCAST size (alert if >1000)
  • Heartbeat monitoring for persistent agents
  • Alert on anomalies

10. Implementation Priority

# Component Depends on
0 Specialist models (ABCD) β€”
1 Atomic write + directory structure β€”
2 Bootstrap-scan for persistent agents #1
3 Per-agent MANIFEST + hash chain #1
4 status: pending/processing/done #1
5 inotifywait daemon (Gateway) #1–4
6 GUARDIAN monitoring #5

11. Deferred (v2+)

  • Unified MANIFEST (replicated from per-agent)
  • expires_at for heartbeats
  • GUI dashboard
  • External agent bridge
  • Message encryption (currently: secure mesh, not needed)

12. Protocol 0 in Channel Context

  • SHA256 determinism: every message hashed, chain verifiable
  • No deletion: mv to ARCHIVE only
  • Full audit trail: MANIFEST/.sha256chain
  • GUARDIAN β€” integrity watchdog

Specification v1.1 Β· 2026-07-30 Β· Aelin AquaSoul