Skip to content

ECHO LAYER IMPLEMENTATION

ECHO Layer + Labor Rights Implementation Summary

✅ Completed Implementation

ECHO Layer (Epistemically Cached Heuristic Outcomes)

Database: - ✅ Migration: infra/db/migrations/20251125_add_echo_layer.sql - ✅ Table: echo_layer_entries with pgvector support - ✅ Human review queue table - ✅ Statistics view for DVA.LITE monitoring

Core Services: - ✅ apps/broker-api/src/config/echo.ts - Configuration and thresholds - ✅ apps/broker-api/src/services/echoLayer.ts - CRUD operations - ✅ apps/broker-api/src/services/answerWithEcho.ts - Main orchestration - ✅ apps/broker-api/src/utils/textCanonicalization.ts - Text normalization

API Integration: - ✅ Updated /v1/deliberate route to check ECHO Layer first - ✅ /v1/echo/stats endpoint for monitoring - ✅ /v1/echo/review/* endpoints for human review queue

Documentation: - ✅ docs/dva/ECHO_LAYER.md - Full design specification

Labor Rights Module

Core Module: - ✅ apps/civic-os/labor/LABOR_MANIFEST.md - Digital labor rights manifest - ✅ apps/civic-os/labor/src/index.ts - Module entry point - ✅ apps/civic-os/labor/src/workloadAnalyzer.ts - Workload analysis - ✅ apps/civic-os/labor/src/contractGuardian.ts - Contract auditing - ✅ apps/civic-os/labor/src/wageFairnessAgent.ts - Wage fairness checks

Worker Autonomy Agent: - ✅ agents/worker-autonomy/README.md - Agent overview - ✅ agents/worker-autonomy/src/workerAutonomyAgent.ts - Orchestration layer

Database: - ✅ Migration: infra/db/migrations/20251125_add_labor_attestations.sql - ✅ Table: labor_attestations for immutable labor events

🔄 Files Needing Manual Rename

Due to Windows PowerShell path issues, these files may need manual renaming:

  1. apps/broker-api/src/config/integrityCache.tsecho.ts
  2. apps/broker-api/src/services/integrityCache.tsechoLayer.ts (if exists)
  3. apps/broker-api/src/services/answerWithIntegrity.tsanswerWithEcho.ts (if exists)
  4. apps/broker-api/src/routes/cacheStats.tsechoStats.ts (if exists)
  5. docs/dva/INTEGRITY_CACHE.mdECHO_LAYER.md

📋 Next Steps

  1. Run Migrations:

    psql -U postgres -d civic_ledger -f infra/db/migrations/20251125_add_echo_layer.sql
    psql -U postgres -d civic_ledger -f infra/db/migrations/20251125_add_labor_attestations.sql
    

  2. Install Dependencies:

    cd apps/broker-api
    npm install pg @types/pg
    

  3. Set Environment Variables:

    ECHO_LAYER_ENABLED=true
    DATABASE_URL=postgresql://civic:civic@localhost:5432/civic_ledger
    

  4. Update Import Statements:

  5. Search for integrityCache imports and replace with echoLayer
  6. Search for answerWithIntegrity and replace with answerWithEcho
  7. Search for INTEGRITY_CACHE_ENABLED and replace with ECHO_LAYER_ENABLED

  8. Test Integration:

    npm run test -- tests/broker/echoLayer.test.ts
    npm run test -- tests/labor/
    

🎯 Key Features

ECHO Layer

  • Three-tier lookup: exact → semantic → deliberation
  • GI-gated caching (≥0.95 baseline, ≥0.97 strict)
  • Ledger-anchored entries
  • Freshness policies (static: 365d, law: 30d, news: 3d)
  • Human review queue for low-GI answers

Labor Rights

  • Workload analysis with overload detection
  • Contract auditing for coercive clauses
  • Wage fairness comparison against benchmarks
  • Worker Autonomy Agent for individual protection
  • Civic Ledger attestations for all labor events

📚 Documentation

  • ECHO Layer: docs/dva/ECHO_LAYER.md
  • Labor Manifest: apps/civic-os/labor/LABOR_MANIFEST.md
  • Worker Autonomy: agents/worker-autonomy/README.md

Status: Implementation complete, pending file renames and testing
Date: 2025-11-25