Skip to content

Make SkyTwin actually work end-to-end: adapter layer, execution persistence, safety gaps #3

@jayzalowitz

Description

@jayzalowitz

Problem

SkyTwin has a working decision pipeline on paper, but nothing persists to the database at runtime. The domain layer defines port interfaces with methods like saveDecision(), save(), saveOutcome(). The DB layer defines concrete repositories with different names: create(), recordOutcome(), addCandidateAction(). The as never casts at events.ts:39-42 suppress TypeScript errors but at runtime produce "saveDecision is not a function."

Additionally:

  • Approved actions never trigger execution (approvals.ts responds but never calls IronClaw)
  • Auto-executed actions never persist their execution plan or result
  • No daily spend limit tracking
  • No trust tier auto-progression
  • No undo/rollback flow

Plan (5 phases)

Phase 1: Make the Core Loop Work

  • Build adapter layer: 5 adapter classes bridging port interfaces to DB repositories
  • Replace as never casts in events.ts and approvals.ts with proper adapters
  • Add execution-repository.ts for persisting plans + results
  • Execute approved actions after user approves (approvals.ts)
  • Fix approval_requests.updated_at schema gap
  • Integration tests for pipeline + approval execution

Phase 2: Safety Gaps

  • Daily spend limit tracking (daily_spend_ledger table + policy evaluator check)
  • Trust tier auto-progression (TrustProgressionEvaluator + thresholds)
  • Undo/rollback flow (POST /decisions/:id/undo)
  • Populate twin profile fields (risk_tolerance, spend_norms, routines, etc.)

Phase 3: UX Completeness (parallel with Phase 4)

  • Domain-specific trust tiers
  • Approval auto-expiry (1 hour default)
  • In-app notification system
  • Quiet hours

Phase 4: Infrastructure (parallel with Phase 3)

  • Job queue for worker (replace synchronous HTTP)
  • Background token refresh
  • Policy CRUD API

Phase 5: Polish

  • SSE for real-time dashboard
  • Edit feedback flow
  • Structured logging

Critical Files

File Issue
events.ts:39-42 as never casts hide port/repo method mismatch
approvals.ts:97-134 Approve response never triggers execution
decision-maker.ts:28-38 DecisionRepositoryPort to implement
explanation-generator.ts:18-22 ExplanationRepositoryPort to implement
twin-service.ts:21-49 TwinRepositoryPort + PatternRepositoryPort
policy-evaluator.ts Missing daily spend, quiet hours, domain trust

Sequencing

Phase 1 → Phase 2 → Phase 3 + Phase 4 (parallel) → Phase 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions